From 231cde7958c23e55fe34e4ee49283c8d3bb48399 Mon Sep 17 00:00:00 2001 From: Matt Caughey Date: Tue, 14 May 2013 10:17:00 -0400 Subject: [PATCH] Added sunflowers --- .../biomes/BiomeDecoratorBOP.java | 13 ++++ .../biomes/BiomeGenForestNew.java | 1 + .../biomesoplenty/biomes/BiomeGenGarden.java | 7 +- .../biomesoplenty/biomes/BiomeGenMeadow.java | 1 + .../biomesoplenty/biomes/BiomeGenOrchard.java | 1 + .../biomes/BiomeGenPlainsNew.java | 1 + .../biomesoplenty/biomes/BiomeGenTropics.java | 1 + .../biomesoplenty/blocks/BlockBOPFlower.java | 68 +++++++++++++++--- .../biomesoplenty/items/ItemBOPFlower.java | 24 ++++++- .../worldgen/WorldGenSunflower.java | 43 +++++++++++ .../textures/blocks/glowshroom.png | Bin 317 -> 272 bytes .../textures/blocks/item_sunflower.png | Bin 0 -> 353 bytes .../textures/blocks/sunflowerbottom.png | Bin 0 -> 290 bytes .../textures/blocks/sunflowertop.png | Bin 0 -> 373 bytes 14 files changed, 145 insertions(+), 15 deletions(-) create mode 100644 src/minecraft/biomesoplenty/worldgen/WorldGenSunflower.java create mode 100644 src/minecraft/mods/BiomesOPlenty/textures/blocks/item_sunflower.png create mode 100644 src/minecraft/mods/BiomesOPlenty/textures/blocks/sunflowerbottom.png create mode 100644 src/minecraft/mods/BiomesOPlenty/textures/blocks/sunflowertop.png diff --git a/src/minecraft/biomesoplenty/biomes/BiomeDecoratorBOP.java b/src/minecraft/biomesoplenty/biomes/BiomeDecoratorBOP.java index 34452da15..07c841c2d 100644 --- a/src/minecraft/biomesoplenty/biomes/BiomeDecoratorBOP.java +++ b/src/minecraft/biomesoplenty/biomes/BiomeDecoratorBOP.java @@ -58,6 +58,7 @@ import biomesoplenty.worldgen.WorldGenShield; import biomesoplenty.worldgen.WorldGenSmolderingGrass; import biomesoplenty.worldgen.WorldGenSprout; import biomesoplenty.worldgen.WorldGenSteppe; +import biomesoplenty.worldgen.WorldGenSunflower; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; @@ -186,6 +187,7 @@ public class BiomeDecoratorBOP extends BiomeDecorator protected WorldGenerator quicksandGen; protected WorldGenerator quicksand2Gen; protected WorldGenerator poisonIvyGen; + protected WorldGenerator sunflowerGen; protected WorldGenerator crystalGen; protected WorldGenerator crystalGen2; @@ -259,6 +261,7 @@ public class BiomeDecoratorBOP extends BiomeDecorator protected int quicksandPerChunk; protected int quicksand2PerChunk; protected int poisonIvyPerChunk; + protected int sunflowersPerChunk; /** The amount of tall grass to generate per chunk. */ protected int grassPerChunk; @@ -393,6 +396,7 @@ public class BiomeDecoratorBOP extends BiomeDecorator this.holyTallGrassGen = new WorldGenBOPFlowers(Blocks.plants.get().blockID, 4); this.desertSproutsGen = new WorldGenBOPFlowers(Blocks.plants.get().blockID, 2); this.poisonIvyGen = new WorldGenBush(Blocks.foliage.get().blockID, 7); + this.sunflowerGen = new WorldGenSunflower(Blocks.flowers.get().blockID, 13); this.promisedWillowGen = new WorldGenPromisedWillow(); this.quicksandGen = new WorldGenQuicksand(); this.quicksand2Gen = new WorldGenQuicksand2(); @@ -459,6 +463,7 @@ public class BiomeDecoratorBOP extends BiomeDecorator this.portobellosPerChunk = 0; this.blueMilksPerChunk = 0; this.glowshroomsPerChunk = 0; + this.sunflowersPerChunk = 0; this.sproutsPerChunk = 0; this.bushesPerChunk = 0; this.tinyCactiPerChunk = 0; @@ -775,6 +780,14 @@ public class BiomeDecoratorBOP extends BiomeDecorator this.plantRedGen.generate(this.currentWorld, this.randomGenerator, var3, var4, var5); } + for (var2 = 0; var2 < this.sunflowersPerChunk; ++var2) + { + var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + var4 = this.randomGenerator.nextInt(128); + var5 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.sunflowerGen.generate(this.currentWorld, this.randomGenerator, var3, var4, var5); + } + for (var2 = 0; var2 < this.crystalsPerChunk; ++var2) { var3 = this.chunk_X + this.randomGenerator.nextInt(16) + 8; diff --git a/src/minecraft/biomesoplenty/biomes/BiomeGenForestNew.java b/src/minecraft/biomesoplenty/biomes/BiomeGenForestNew.java index 5b41eb3e5..d5cbf5090 100644 --- a/src/minecraft/biomesoplenty/biomes/BiomeGenForestNew.java +++ b/src/minecraft/biomesoplenty/biomes/BiomeGenForestNew.java @@ -27,6 +27,7 @@ public class BiomeGenForestNew extends BiomeGenBase this.customBiomeDecorator.whiteFlowersPerChunk = 1; this.customBiomeDecorator.reedsBOPPerChunk = 5; this.customBiomeDecorator.poisonIvyPerChunk = 2; + this.customBiomeDecorator.sunflowersPerChunk = 1; } /** diff --git a/src/minecraft/biomesoplenty/biomes/BiomeGenGarden.java b/src/minecraft/biomesoplenty/biomes/BiomeGenGarden.java index b0ef6b1d6..9863a0e12 100644 --- a/src/minecraft/biomesoplenty/biomes/BiomeGenGarden.java +++ b/src/minecraft/biomesoplenty/biomes/BiomeGenGarden.java @@ -30,8 +30,9 @@ public class BiomeGenGarden extends BiomeGenBase this.customBiomeDecorator.flowersPerChunk = 20; this.customBiomeDecorator.whiteFlowersPerChunk = 25; this.customBiomeDecorator.tinyFlowersPerChunk = 15; - this.customBiomeDecorator.hydrangeasPerChunk = 10; - this.customBiomeDecorator.sproutsPerChunk = 5; + this.customBiomeDecorator.hydrangeasPerChunk = 3; + this.customBiomeDecorator.sproutsPerChunk = 2; + this.customBiomeDecorator.sunflowersPerChunk = 4; this.customBiomeDecorator.rosesPerChunk = 20; this.customBiomeDecorator.grassPerChunk = 25; this.customBiomeDecorator.sandPerChunk = -999; @@ -48,7 +49,7 @@ public class BiomeGenGarden extends BiomeGenBase */ public WorldGenerator getRandomWorldGenForGrass(Random par1Random) { - return (par1Random.nextInt(3) == 0 ? new WorldGenTallGrass(Block.tallGrass.blockID, 1) : (par1Random.nextInt(4) == 0 ? new WorldGenTallGrass(Block.tallGrass.blockID, 2) : (par1Random.nextInt(2) == 0 ? new WorldGenTallGrass(Blocks.foliage.get().blockID, 2) : new WorldGenTallGrass(Blocks.foliage.get().blockID, 1)))); + return new WorldGenTallGrass(Block.tallGrass.blockID, 1); } /** diff --git a/src/minecraft/biomesoplenty/biomes/BiomeGenMeadow.java b/src/minecraft/biomesoplenty/biomes/BiomeGenMeadow.java index e8bdd0f02..48f24a33c 100644 --- a/src/minecraft/biomesoplenty/biomes/BiomeGenMeadow.java +++ b/src/minecraft/biomesoplenty/biomes/BiomeGenMeadow.java @@ -26,6 +26,7 @@ public class BiomeGenMeadow extends BiomeGenBase this.customBiomeDecorator.sandPerChunk = -999; this.customBiomeDecorator.sandPerChunk2 = -999; this.customBiomeDecorator.hydrangeasPerChunk = 3; + this.customBiomeDecorator.sunflowersPerChunk = 1; this.customBiomeDecorator.generatePumpkins = false; } diff --git a/src/minecraft/biomesoplenty/biomes/BiomeGenOrchard.java b/src/minecraft/biomesoplenty/biomes/BiomeGenOrchard.java index a9f7acdb9..c96c4de20 100644 --- a/src/minecraft/biomesoplenty/biomes/BiomeGenOrchard.java +++ b/src/minecraft/biomesoplenty/biomes/BiomeGenOrchard.java @@ -22,6 +22,7 @@ public class BiomeGenOrchard extends BiomeGenBase this.customBiomeDecorator.tinyFlowersPerChunk = 20; this.customBiomeDecorator.grassPerChunk = 15; this.customBiomeDecorator.portobellosPerChunk = 2; + this.customBiomeDecorator.sunflowersPerChunk = 1; } /** diff --git a/src/minecraft/biomesoplenty/biomes/BiomeGenPlainsNew.java b/src/minecraft/biomesoplenty/biomes/BiomeGenPlainsNew.java index c3e03c445..c6febeed3 100644 --- a/src/minecraft/biomesoplenty/biomes/BiomeGenPlainsNew.java +++ b/src/minecraft/biomesoplenty/biomes/BiomeGenPlainsNew.java @@ -24,6 +24,7 @@ public class BiomeGenPlainsNew extends BiomeGenBase this.customBiomeDecorator.grassPerChunk = 10; this.customBiomeDecorator.tinyFlowersPerChunk = 1; this.customBiomeDecorator.portobellosPerChunk = 1; + this.customBiomeDecorator.sunflowersPerChunk = 2; } /** diff --git a/src/minecraft/biomesoplenty/biomes/BiomeGenTropics.java b/src/minecraft/biomesoplenty/biomes/BiomeGenTropics.java index 50391665f..66128700a 100644 --- a/src/minecraft/biomesoplenty/biomes/BiomeGenTropics.java +++ b/src/minecraft/biomesoplenty/biomes/BiomeGenTropics.java @@ -29,6 +29,7 @@ public class BiomeGenTropics extends BiomeGenBase this.customBiomeDecorator.sandPerChunk2 = 50; this.customBiomeDecorator.orangeFlowersPerChunk = 10; this.customBiomeDecorator.whiteFlowersPerChunk = 4; + this.customBiomeDecorator.sunflowersPerChunk = 2; this.customBiomeDecorator.generatePumpkins = false; this.spawnableMonsterList.add(new SpawnListEntry(EntityJungleSpider.class, 12, 6, 6)); this.spawnableCreatureList.clear(); diff --git a/src/minecraft/biomesoplenty/blocks/BlockBOPFlower.java b/src/minecraft/biomesoplenty/blocks/BlockBOPFlower.java index 88953edf9..ea0a03f76 100644 --- a/src/minecraft/biomesoplenty/blocks/BlockBOPFlower.java +++ b/src/minecraft/biomesoplenty/blocks/BlockBOPFlower.java @@ -1,5 +1,6 @@ package biomesoplenty.blocks; +import java.util.Random; import java.util.List; import net.minecraft.block.Block; @@ -24,6 +25,9 @@ public class BlockBOPFlower extends BlockFlower { private static final String[] plants = new String[] {"clover", "swampflower", "deadbloom", "glowflower", "hydrangea", "daisy", "tulip", "wildflower", "violet", "anemone", "lilyflower", "cactus", "aloe", "sunflowerbottom", "sunflowertop", "dandelion"}; private Icon[] textures; + + private static final int SUNFLOWERTOP = 14; + private static final int SUNFLOWERBOTTOM = 13; protected BlockBOPFlower(int blockID, Material material) { @@ -117,7 +121,12 @@ public class BlockBOPFlower extends BlockFlower @SuppressWarnings({ "rawtypes", "unchecked" }) public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) { for (int i = 0; i < plants.length; ++i) - list.add(new ItemStack(blockID, 1, i)); + { + if (i != 14) + { + list.add(new ItemStack(blockID, 1, i)); + } + } } protected boolean canThisPlantGrowOnThisBlockID(int id) @@ -133,8 +142,10 @@ public class BlockBOPFlower extends BlockFlower return id == Block.waterlily.blockID; if (metadata == 11) //Cactus return id == Block.sand.blockID || id == Blocks.redRock.get().blockID; - if (metadata == 12) //Yucca + if (metadata == 12) //Aloe return id == Blocks.hardDirt.get().blockID || id == Blocks.redRock.get().blockID || id == Block.sand.blockID; + if (metadata == 14) //Sunflower Top + return id == this.blockID; else return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID; } @@ -158,8 +169,11 @@ public class BlockBOPFlower extends BlockFlower case 11: // Cactus return id == Blocks.redRock.get().blockID || id == Block.sand.blockID; - case 12: // Yucca + case 12: // Aloe return id == Blocks.hardDirt.get().blockID || id == Blocks.redRock.get().blockID || id == Block.sand.blockID; + + case 14: // Sunflower Top + return id == this.blockID; default: return id == Block.grass.blockID || id == Block.dirt.blockID || id == Block.tilledField.blockID; @@ -167,7 +181,49 @@ public class BlockBOPFlower extends BlockFlower else return this.canPlaceBlockOnSide(world, x, y, z, side); } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, int neighborID) + { + super.onNeighborBlockChange(world, x, y, z, neighborID); + this.checkFlowerChange(world, x, y, z); + if (world.getBlockMetadata(x, y, z) == SUNFLOWERTOP && world.getBlockId(x, y - 1, z) == this.blockID && world.getBlockMetadata(x, y - 1, z) != SUNFLOWERBOTTOM) + world.setBlockToAir(x, y, z); + //if (world.getBlockMetadata(x, y, z) == CATTAILBOTTOM && world.getBlockId(x, y + 1, z) != this.blockID) + // world.setBlock(x, y, z, this.blockID, 7, 2); + } + @Override + public int getDamageValue(World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta == SUNFLOWERTOP) + meta = 13; + return meta; + } + + @Override + public int damageDropped(int meta) + { + if (meta == 14) + { + return 13 & 15; + } + else + { + return meta & 15; + } + } + + @Override + public int quantityDropped(int meta, int fortune, Random random) + { + if (meta == 13) + return 0; + else + return 1; + } + @Override public boolean canBlockStay(World world, int x, int y, int z) { @@ -178,10 +234,4 @@ public class BlockBOPFlower extends BlockFlower return (world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z)) && this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z)); } - - @Override - public int damageDropped(int meta) - { - return meta & 15; - } } diff --git a/src/minecraft/biomesoplenty/items/ItemBOPFlower.java b/src/minecraft/biomesoplenty/items/ItemBOPFlower.java index cd6f65514..409f0460a 100644 --- a/src/minecraft/biomesoplenty/items/ItemBOPFlower.java +++ b/src/minecraft/biomesoplenty/items/ItemBOPFlower.java @@ -4,6 +4,7 @@ import biomesoplenty.BiomesOPlenty; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; @@ -15,7 +16,10 @@ import net.minecraft.world.World; public class ItemBOPFlower extends ItemBlock { private static final String[] plants = new String[] {"clover", "swampflower", "deadbloom", "glowflower", "hydrangea", "daisy", "tulip", "wildflower", "violet", "anemone", "lilyflower", "cactus", "aloe", "sunflowerbottom", "sunflowertop", "dandelion"}; - + @SideOnly(Side.CLIENT) + private Icon[] textures; + private static final int SUNFLOWERTOP = 14; + public ItemBOPFlower(int par1) { super(par1); @@ -28,17 +32,28 @@ public class ItemBOPFlower extends ItemBlock { return meta & 15; } + + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister iconRegister) + { + textures = new Icon[1]; + + textures[0] = iconRegister.registerIcon("BiomesOPlenty:item_sunflower"); + } @Override public String getUnlocalizedName(ItemStack itemStack) { return (new StringBuilder()).append(plants[itemStack.getItemDamage()]).toString(); } - + @Override public Icon getIconFromDamage(int meta) { - return Block.blocksList[this.itemID].getIcon(0, meta); + if (meta == 13) + return textures[0]; + else + return Block.blocksList[this.itemID].getIcon(0, meta); } @SideOnly(Side.CLIENT) @@ -126,6 +141,9 @@ public class ItemBOPFlower extends ItemBlock if (world.setBlock(x, y, z, this.getBlockID(), itemStack.getItemDamage(), 3)) { + if (itemStack.getItemDamage() == 13 && world.getBlockMaterial(x, y + 1, z).isReplaceable()) + world.setBlock(x, y + 1, z, this.getBlockID(), SUNFLOWERTOP, 2); + if (world.getBlockId(x, y, z) == this.getBlockID()) { Block.blocksList[this.getBlockID()].onBlockPlacedBy(world, x, y, z, player, itemStack); diff --git a/src/minecraft/biomesoplenty/worldgen/WorldGenSunflower.java b/src/minecraft/biomesoplenty/worldgen/WorldGenSunflower.java new file mode 100644 index 000000000..98425f675 --- /dev/null +++ b/src/minecraft/biomesoplenty/worldgen/WorldGenSunflower.java @@ -0,0 +1,43 @@ +package biomesoplenty.worldgen; + +import java.util.Random; + +import biomesoplenty.api.Blocks; +import biomesoplenty.configuration.BOPBlocks; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class WorldGenSunflower extends WorldGenerator +{ + /** The ID of the plant block used in this plant generator. */ + private int plantBlockId; + private int plantBlockMeta; + + public WorldGenSunflower(int par1, int meta) + { + this.plantBlockId = par1; + this.plantBlockMeta = meta; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + for (int l = 0; l < 64; ++l) + { + int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int j1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); + int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.isAirBlock(i1, j1, k1) && (!par1World.provider.hasNoSky || j1 < 127) && (par1World.getFullBlockLightValue(i1, j1, k1) >= 8 || par1World.canBlockSeeTheSky(i1, j1, k1)) + && Block.blocksList[this.plantBlockId].canPlaceBlockOnSide(par1World, i1, j1, k1, 1, new ItemStack(this.plantBlockId, 1, this.plantBlockMeta))) + { + par1World.setBlock(i1, j1, k1, Blocks.flowers.get().blockID, 13, 2); + par1World.setBlock(i1, j1 + 1, k1, Blocks.flowers.get().blockID, 14, 2); + } + } + + return true; + } +} diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/glowshroom.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/glowshroom.png index 8d185397d7f705daa048056cf27c1e0c8f672ed0..86747c18963843ea522d247d529ef10c7c7864bf 100644 GIT binary patch delta 186 zcmV;r07d`30+0fbB#|)~3c>&Y4#EKyC`y2lQz?IpNkl(v&pG;lD?T4u%0B z??IWE09kQ-r|W;$OalzfBzY^Q(d)lcoH1N+>MU!*-hz1p1fnYa|J#R{gZUsAfxHA_ o6Lca0$R-etYyh%L5P*RJ0P`<&ecm;u*8l(j07*qoM6N<$f(#8yc>n+a delta 229 zcmVo&?iU{%=Y#U`F_fc3fdyfZDzHGyYFx+rRrd=4Oz?Es zY51oCLf8AgmS}PvoyvHH{Vwy|exmhraO$r0rY#>fL}&8zruW)k=3&`h$a(lz(}CA4 z65`I67@By3U;jPJkdd<0HtT&p+lD==Iv3|1y!2YK_6X-R8IJs|ElN#mVjR{U=VW2@ uuJ>~ie2~VHUfWo3a*cSyfBgwxST9UHcxg}eZGE8M7(8A5T-G@yGywpXRfeJf literal 0 HcmV?d00001 diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/sunflowerbottom.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/sunflowerbottom.png new file mode 100644 index 0000000000000000000000000000000000000000..93282efa04950785e20e3f3d96697987eb99beeb GIT binary patch literal 290 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL8%hgh?3y^w370~qEv=}#LT=BJwMkFg)(D3 zQ$0figD*u3fvP5Yx;Tbd_%EH{$k(7Cz+Bm+ZvP^==37>Bn@B{`k;5%{3(vL*2?l@L ze5B0d*>@$=gWO9#&OKP5F{9Ph_zS;j@S}ak5-k_J>kr(rsuxX>-XI%t@o{v6C(N2NMT}%%llBSzMfYTqG|r3Z+_< z@?P0^M`vF0H$KaXd-u=GnLP7vy3K6fyZ`r|`N$D+K;WI0afYwe;%h7PgndPP{{G%s zdZ_pN%Kxk%7~0PDPCtC?2Ph=0E@qk!dc z?c1aoKiF5?c=#->@{0XD8{Jm|e;Q}~6!@yjIVD-lDCHbaQ)Q)h=Eda#Oc_tkzAt4s z!RWeR%7rzK{iiHv1YTVb>b!zgmEj7L=_=1mF)f#VhPgK<8(g`oWLQwu+>3s QK>sp$y85}Sb4q9e08amrcmMzZ literal 0 HcmV?d00001