diff --git a/common/biomesoplenty/api/BlockReferences.java b/common/biomesoplenty/api/BlockReferences.java index d02d4147a..715aaf620 100644 --- a/common/biomesoplenty/api/BlockReferences.java +++ b/common/biomesoplenty/api/BlockReferences.java @@ -204,6 +204,9 @@ public class BlockReferences { bluebells (Blocks.flowers2, 5), minersdelight (Blocks.flowers2, 6), icyiris (Blocks.flowers2, 7), + + stalagmite (Blocks.stoneFormations, 0), + stalactite (Blocks.stoneFormations, 1), ; public Optional block; diff --git a/common/biomesoplenty/api/Blocks.java b/common/biomesoplenty/api/Blocks.java index 4a9135152..5bccaf088 100644 --- a/common/biomesoplenty/api/Blocks.java +++ b/common/biomesoplenty/api/Blocks.java @@ -87,6 +87,7 @@ public class Blocks public static Optional cloud = Optional.absent(); public static Optional hive = Optional.absent(); public static Optional honeyBlock = Optional.absent(); + public static Optional stoneFormations = Optional.absent(); //Nether public static Optional bones = Optional.absent(); diff --git a/common/biomesoplenty/biomes/BiomeDecoratorBOP.java b/common/biomesoplenty/biomes/BiomeDecoratorBOP.java index 19d67faa2..e4290a96a 100644 --- a/common/biomesoplenty/biomes/BiomeDecoratorBOP.java +++ b/common/biomesoplenty/biomes/BiomeDecoratorBOP.java @@ -243,6 +243,8 @@ public class BiomeDecoratorBOP extends BiomeDecorator public WorldGenerator koruGen; public WorldGenerator waspHiveGen; public WorldGenerator rootGen; + public WorldGenerator stalagmiteGen; + public WorldGenerator stalactiteGen; public WorldGenerator boneSpineGen; public WorldGenerator boneSpine2Gen; @@ -344,6 +346,8 @@ public class BiomeDecoratorBOP extends BiomeDecorator public int koruPerChunk; public int waspHivesPerChunk; public int rootsPerChunk; + public int stalagmitesPerChunk; + public int stalactitesPerChunk; public int boneSpinesPerChunk; public int boneSpines2PerChunk; @@ -555,6 +559,8 @@ public class BiomeDecoratorBOP extends BiomeDecorator redwoodShrubGen = new WorldGenRedwoodShrub(0,0); koruGen = new WorldGenTallGrass(Blocks.foliage.get().blockID, 12); rootGen = new WorldGenBOPTallGrass(Blocks.plants.get().blockID, 15); + stalagmiteGen = new WorldGenBOPTallGrass(Blocks.stoneFormations.get().blockID, 0); + stalactiteGen = new WorldGenBOPTallGrass(Blocks.stoneFormations.get().blockID, 1); pitGen = new WorldGenPit(Blocks.ash.get().blockID); waterlilyPerChunk = 0; lilyflowersPerChunk = 0; @@ -651,6 +657,8 @@ public class BiomeDecoratorBOP extends BiomeDecorator koruPerChunk = 0; waspHivesPerChunk = 0; rootsPerChunk = 9; + stalagmitesPerChunk = 3; + stalactitesPerChunk = 6; generateLakes = true; generateAsh = false; generateMycelium = false; @@ -1341,6 +1349,22 @@ public class BiomeDecoratorBOP extends BiomeDecorator rootGen.generate(currentWorld, randomGenerator, var3, var4, var5); } + for (var2 = 0; var2 < stalagmitesPerChunk; ++var2) + { + var3 = chunk_X + randomGenerator.nextInt(16) + 8; + var4 = randomGenerator.nextInt(64); + var5 = chunk_Z + randomGenerator.nextInt(16) + 8; + stalagmiteGen.generate(currentWorld, randomGenerator, var3, var4, var5); + } + + for (var2 = 0; var2 < stalactitesPerChunk; ++var2) + { + var3 = chunk_X + randomGenerator.nextInt(16) + 8; + var4 = randomGenerator.nextInt(64); + var5 = chunk_Z + randomGenerator.nextInt(16) + 8; + stalactiteGen.generate(currentWorld, randomGenerator, var3, var4, var5); + } + for (var2 = 0; var2 < waspHivesPerChunk; ++var2) { int var420 = randomGenerator.nextInt(4); diff --git a/common/biomesoplenty/biomes/BiomeGenOriginValley.java b/common/biomesoplenty/biomes/BiomeGenOriginValley.java index 277cd098b..9b172fac9 100644 --- a/common/biomesoplenty/biomes/BiomeGenOriginValley.java +++ b/common/biomesoplenty/biomes/BiomeGenOriginValley.java @@ -26,6 +26,9 @@ public class BiomeGenOriginValley extends BiomeGenBase customBiomeDecorator.sandPerChunk2 = 0; customBiomeDecorator.clayPerChunk = 0; customBiomeDecorator.rootsPerChunk = -999; + customBiomeDecorator.stalagmitesPerChunk = -999; + customBiomeDecorator.stalactitesPerChunk = -999; + customBiomeDecorator.minersDelightPerChunk = -999; } /** diff --git a/common/biomesoplenty/blocks/BlockStoneFormations.java b/common/biomesoplenty/blocks/BlockStoneFormations.java new file mode 100644 index 000000000..030bd0d6e --- /dev/null +++ b/common/biomesoplenty/blocks/BlockStoneFormations.java @@ -0,0 +1,173 @@ +package biomesoplenty.blocks; + +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFlower; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import biomesoplenty.BiomesOPlenty; +import biomesoplenty.api.Blocks; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockStoneFormations extends BlockFlower +{ + private static final String[] forms = new String[] {"stalagmite", "stalactite"}; + private Icon[] textures; + + protected BlockStoneFormations(int blockID, Material material) + { + super(blockID, material); + this.setTickRandomly(true); + float var4 = 0.2F; + this.setBlockBounds(0.5F - var4, 0.0F, 0.5F - var4, 0.5F + var4, var4 * 3.0F, 0.5F + var4); + this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty); + } + + public BlockStoneFormations(int blockID) + { + this(blockID, Material.rock); + } + + @Override + public void registerIcons(IconRegister iconRegister) + { + textures = new Icon[forms.length]; + + for (int i = 0; i < forms.length; ++i) { + textures[i] = iconRegister.registerIcon("biomesoplenty:" + forms[i]); + } + } + + @Override + public Icon getIcon(int side, int meta) + { + if (meta < 0 || meta >= textures.length) { + meta = 0; + } + + return textures[meta]; + } + + @Override + public int getRenderType() + { + return 1; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int par2, int par3, int par4) + { + int meta = world.getBlockMetadata(par2, par3, par4); + + switch (meta) + { + default: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + break; + } + } + + @Override + @SideOnly(Side.CLIENT) + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) { + for (int i = 0; i < forms.length; ++i) + { + list.add(new ItemStack(blockID, 1, i)); + } + } + + @Override + protected boolean canThisPlantGrowOnThisBlockID(int id) + { + return id == Block.stone.blockID; + } + + protected boolean canThisPlantGrowOnThisBlockID(int id, int metadata) + { + return id == Block.stone.blockID; + } + + @Override + public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side, ItemStack itemStack) + { + int idbottom = world.getBlockId(x, y - 1, z); + int idtop = world.getBlockId(x, y + 1, z); + int meta = itemStack.getItemDamage(); + //boolean sky = world.getFullBlockLightValue(x, y, z) >= 8 || world.canBlockSeeTheSky(x, y, z); + + if (itemStack.itemID == blockID) { + switch (meta) + { + case 0: // Stalagmite + return idbottom == Block.stone.blockID; + + case 1: // Stalactite + return idtop == Block.stone.blockID; + + default: + return idbottom == Block.stone.blockID; + } + } 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); + } + + @Override + public int getDamageValue(World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + + return meta; + } + + @Override + public int damageDropped(int meta) + { + return meta & 15; + } + + @Override + public boolean canBlockStay(World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + + if (world.getBlockId(x, y, z) != blockID) + { + if (meta == 1) + return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y + 1, z)); + else + return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z)); + } + else + { + if (meta == 1) + return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y + 1, z), world.getBlockMetadata(x, y, z)); + else + return this.canThisPlantGrowOnThisBlockID(world.getBlockId(x, y - 1, z), world.getBlockMetadata(x, y, z)); + } + } + + @Override + public boolean isBlockReplaceable(World world, int x, int y, int z) + { + return true; + } +} diff --git a/common/biomesoplenty/configuration/BOPBlocks.java b/common/biomesoplenty/configuration/BOPBlocks.java index 8a40eeba8..fbef66d8a 100644 --- a/common/biomesoplenty/configuration/BOPBlocks.java +++ b/common/biomesoplenty/configuration/BOPBlocks.java @@ -49,6 +49,7 @@ import biomesoplenty.blocks.BlockMud; import biomesoplenty.blocks.BlockOriginGrass; import biomesoplenty.blocks.BlockPromisedPortal; import biomesoplenty.blocks.BlockPuddle; +import biomesoplenty.blocks.BlockStoneFormations; import biomesoplenty.blocks.BlockTreeMoss; import biomesoplenty.blocks.BlockWillow; import biomesoplenty.configuration.configfile.BOPConfigurationIDs; @@ -79,6 +80,7 @@ import biomesoplenty.itemblocks.ItemBlockRedRock; import biomesoplenty.itemblocks.ItemBlockSapling; import biomesoplenty.itemblocks.ItemBlockSkystone; import biomesoplenty.itemblocks.ItemBlockSlab; +import biomesoplenty.itemblocks.ItemBlockStoneFormations; import biomesoplenty.items.ItemBOPAmethyst; import biomesoplenty.items.ItemBOPIvy; import biomesoplenty.items.ItemBOPWillow; @@ -136,6 +138,7 @@ public class BOPBlocks Blocks.plants = Optional.of((new BlockBOPPlant(BOPConfigurationIDs.plantsID)).setUnlocalizedName("bop.plants")); Blocks.flowers = Optional.of((new BlockBOPFlower(BOPConfigurationIDs.flowersID)).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("bop.flowers")); Blocks.flowers2 = Optional.of((new BlockBOPFlower2(BOPConfigurationIDs.flowers2ID)).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("bop.flowers2")); + Blocks.stoneFormations = Optional.of((new BlockStoneFormations(BOPConfigurationIDs.stoneFormationsID)).setHardness(0.5F).setStepSound(Block.soundStoneFootstep).setUnlocalizedName("bop.stoneFormations")); Blocks.mushrooms = Optional.of((new BlockBOPMushroom(BOPConfigurationIDs.mushroomsID)).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("bop.mushrooms")); Blocks.coral = Optional.of((new BlockBOPCoral(BOPConfigurationIDs.coralID)).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("bop.coral")); Blocks.willow = Optional.of((new BlockWillow(BOPConfigurationIDs.willowID)).setHardness(0.2F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("bop.willow")); @@ -228,6 +231,7 @@ public class BOPBlocks GameRegistry.registerBlock(Blocks.plants.get(), ItemBlockPlant.class, "bop.plants"); GameRegistry.registerBlock(Blocks.flowers.get(), ItemBlockFlower.class, "bop.flowers"); GameRegistry.registerBlock(Blocks.flowers2.get(), ItemBlockFlower2.class, "bop.flowers2"); + GameRegistry.registerBlock(Blocks.stoneFormations.get(), ItemBlockStoneFormations.class, "bop.stoneFormations"); GameRegistry.registerBlock(Blocks.mushrooms.get(), ItemBlockMushroom.class, "bop.mushrooms"); GameRegistry.registerBlock(Blocks.coral.get(), ItemBlockCoral.class, "bop.coral"); GameRegistry.registerBlock(Blocks.willow.get(), ItemBOPWillow.class, "bop.willow"); diff --git a/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java b/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java index 54a66f36d..6c34c2e7a 100644 --- a/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java +++ b/common/biomesoplenty/configuration/configfile/BOPConfigurationIDs.java @@ -98,7 +98,8 @@ public class BOPConfigurationIDs public static int cloudID; public static int hiveID; public static int honeyBlockID; - + public static int stoneFormationsID; + public static int bonesID; public static int glassID; public static int altarID; @@ -418,6 +419,7 @@ public class BOPConfigurationIDs honeyStillID = config.get("Liquid IDs", "Honey Still ID (ID before this must be free!)", 1989, null).getInt(); honeyBlockID = config.getBlock("Honey Block ID", 1991, null).getInt(); + stoneFormationsID = config.getBlock("Stone Formations ID", 1992, null).getInt(); // Get Item ID's foodID = config.getItem("Food ID", 21003, null).getInt(); diff --git a/common/biomesoplenty/itemblocks/ItemBlockStoneFormations.java b/common/biomesoplenty/itemblocks/ItemBlockStoneFormations.java new file mode 100644 index 000000000..7fc80b71f --- /dev/null +++ b/common/biomesoplenty/itemblocks/ItemBlockStoneFormations.java @@ -0,0 +1,118 @@ +package biomesoplenty.itemblocks; + +import java.util.Random; + +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; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import biomesoplenty.BiomesOPlenty; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemBlockStoneFormations extends ItemBlock +{ + private static final String[] forms = new String[] {"stalagmite", "stalactite"}; + @SideOnly(Side.CLIENT) + private Icon[] textures; + + public ItemBlockStoneFormations(int par1) + { + super(par1); + setMaxDamage(0); + setHasSubtypes(true); + } + + @Override + public String getUnlocalizedName(ItemStack itemStack) + { + int meta = itemStack.getItemDamage(); + if (meta < 0 || meta >= forms.length) { + meta = 0; + } + + return super.getUnlocalizedName() + "." + forms[meta]; + } + + @Override + public Icon getIconFromDamage(int meta) + { + return Block.blocksList[itemID].getIcon(0, meta); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean isFull3D() + { + return true; + } + + @Override + public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + { + int id = world.getBlockId(x, y, z); + + if (id == Block.snow.blockID && (world.getBlockMetadata(x, y, z) & 7) < 1) { + side = 1; + } else if (!Block.blocksList[id].isBlockReplaceable(world, x, y, z)) + { + if (side == 0) { + --y; + } + + if (side == 1) { + ++y; + } + + if (side == 2) { + --z; + } + + if (side == 3) { + ++z; + } + + if (side == 4) { + --x; + } + + if (side == 5) { + ++x; + } + } + + if (!player.canPlayerEdit(x, y, z, side, itemStack)) + return false; + else if (itemStack.stackSize == 0) + return false; + else + { + if (world.canPlaceEntityOnSide(this.getBlockID(), x, y, z, false, side, (Entity)null, itemStack)) + { + Block block = Block.blocksList[this.getBlockID()]; + int j1 = block.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, 0); + + if (world.setBlock(x, y, z, this.getBlockID(), itemStack.getItemDamage(), 3)) + { + + if (world.getBlockId(x, y, z) == this.getBlockID()) + { + Block.blocksList[this.getBlockID()].onBlockPlacedBy(world, x, y, z, player, itemStack); + Block.blocksList[this.getBlockID()].onPostBlockPlaced(world, x, y, z, j1); + } + + world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + --itemStack.stackSize; + } + } + + return true; + } + } +} diff --git a/resources/assets/biomesoplenty/lang/en_US.lang b/resources/assets/biomesoplenty/lang/en_US.lang index 42103a1ba..f45c1c440 100644 --- a/resources/assets/biomesoplenty/lang/en_US.lang +++ b/resources/assets/biomesoplenty/lang/en_US.lang @@ -60,6 +60,9 @@ tile.bop.flowers2.bluebells.name=Bluebells tile.bop.flowers2.minersdelight.name=Miner's Delight tile.bop.flowers2.icyiris.name=Icy Iris +tile.bop.stoneFormations.stalagmite.name=Stalagmite +tile.bop.stoneFormations.stalactite.name=Stalactite + tile.bop.foliage.algae.name=Algae tile.bop.foliage.shortgrass.name=Short Grass tile.bop.foliage.mediumgrass.name=Medium Grass diff --git a/resources/assets/biomesoplenty/textures/blocks/cragrock.png b/resources/assets/biomesoplenty/textures/blocks/cragrock.png index ea59ce1f8..7f402d12b 100644 Binary files a/resources/assets/biomesoplenty/textures/blocks/cragrock.png and b/resources/assets/biomesoplenty/textures/blocks/cragrock.png differ diff --git a/resources/assets/biomesoplenty/textures/blocks/stalactite.png b/resources/assets/biomesoplenty/textures/blocks/stalactite.png new file mode 100644 index 000000000..ce063466d Binary files /dev/null and b/resources/assets/biomesoplenty/textures/blocks/stalactite.png differ diff --git a/resources/assets/biomesoplenty/textures/blocks/stalagmite.png b/resources/assets/biomesoplenty/textures/blocks/stalagmite.png new file mode 100644 index 000000000..77799bbb8 Binary files /dev/null and b/resources/assets/biomesoplenty/textures/blocks/stalagmite.png differ