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 8d185397d..86747c189 100644 Binary files a/src/minecraft/mods/BiomesOPlenty/textures/blocks/glowshroom.png and b/src/minecraft/mods/BiomesOPlenty/textures/blocks/glowshroom.png differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_sunflower.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_sunflower.png new file mode 100644 index 000000000..24cfa7d29 Binary files /dev/null and b/src/minecraft/mods/BiomesOPlenty/textures/blocks/item_sunflower.png differ 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 000000000..93282efa0 Binary files /dev/null and b/src/minecraft/mods/BiomesOPlenty/textures/blocks/sunflowerbottom.png differ diff --git a/src/minecraft/mods/BiomesOPlenty/textures/blocks/sunflowertop.png b/src/minecraft/mods/BiomesOPlenty/textures/blocks/sunflowertop.png new file mode 100644 index 000000000..04ce44a2a Binary files /dev/null and b/src/minecraft/mods/BiomesOPlenty/textures/blocks/sunflowertop.png differ