diff --git a/common/biomesoplenty/blocks/BlockHive.java b/common/biomesoplenty/blocks/BlockHive.java index 0559879d1..8b6d042cf 100644 --- a/common/biomesoplenty/blocks/BlockHive.java +++ b/common/biomesoplenty/blocks/BlockHive.java @@ -1,30 +1,92 @@ package biomesoplenty.blocks; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.AxisAlignedBB; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; import biomesoplenty.BiomesOPlenty; -import biomesoplenty.api.Items; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class BlockHive extends Block { + private static final String[] hiveTypes = new String[] {"honeycomb", "honeycombspawner", "hive", "hivespawner"}; + private Icon[] textures; + public BlockHive(int par1) { super(par1, Material.wood); this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty); } + + /** + * Returns a new instance of a block's tile entity class. Called on placing the block. + */ + public TileEntity createNewTileEntity(World par1World) + { + return new TileEntityMobSpawner(); + } @Override - public void registerIcons(IconRegister par1IconRegister) + public void registerIcons(IconRegister iconRegister) { - blockIcon = par1IconRegister.registerIcon("biomesoplenty:hive"); + textures = new Icon[hiveTypes.length]; + + for (int i = 0; i < hiveTypes.length; ++i) { + textures[i] = iconRegister.registerIcon("biomesoplenty:"+hiveTypes[i]); + } + } + + @Override + public Icon getIcon(int side, int meta) + { + return textures[meta]; + } + + @Override + public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) + { + for (int i = 0; i < hiveTypes.length; ++i) { + list.add(new ItemStack(blockID, 1, i)); + } + } + + @Override + public int damageDropped(int meta) + { + if (meta == 1) { + meta = 0; + } + if (meta == 3) { + meta = 2; + } + + return meta; + } + + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) + { + super.setBurnProperties(blockID, 2, 4); + return blockFlammability[blockID]; + } + + @Override + public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face) + { + return blockFireSpreadSpeed[blockID]; + } + + @Override + public boolean isFlammable(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) + { + return getFlammability(world, x, y, z, metadata, face) > 0; } } \ No newline at end of file diff --git a/common/biomesoplenty/configuration/BOPBlocks.java b/common/biomesoplenty/configuration/BOPBlocks.java index 98ba9453a..cc16f6ac3 100644 --- a/common/biomesoplenty/configuration/BOPBlocks.java +++ b/common/biomesoplenty/configuration/BOPBlocks.java @@ -64,6 +64,7 @@ import biomesoplenty.itemblocks.ItemBlockFoliage; import biomesoplenty.itemblocks.ItemBlockGlass; import biomesoplenty.itemblocks.ItemBlockGrass; import biomesoplenty.itemblocks.ItemBlockGrave; +import biomesoplenty.itemblocks.ItemBlockHive; import biomesoplenty.itemblocks.ItemBlockLeaves; import biomesoplenty.itemblocks.ItemBlockLog; import biomesoplenty.itemblocks.ItemBlockMoss; @@ -264,7 +265,7 @@ public class BOPBlocks GameRegistry.registerBlock(Blocks.moss.get(), ItemBlockMoss.class, "bop.moss"); GameRegistry.registerBlock(Blocks.cragRock.get(), "bop.cragRock"); GameRegistry.registerBlock(Blocks.cloud.get(), "bop.cloud"); - GameRegistry.registerBlock(Blocks.hive.get(), "bop.hive"); + GameRegistry.registerBlock(Blocks.hive.get(), ItemBlockHive.class, "bop.hive"); GameRegistry.registerBlock(Blocks.bones.get(), ItemBlockBones.class, "bop.bones"); GameRegistry.registerBlock(Blocks.glass.get(), ItemBlockGlass.class, "bop.glass"); diff --git a/common/biomesoplenty/itemblocks/ItemBlockHive.java b/common/biomesoplenty/itemblocks/ItemBlockHive.java new file mode 100644 index 000000000..b802815e1 --- /dev/null +++ b/common/biomesoplenty/itemblocks/ItemBlockHive.java @@ -0,0 +1,35 @@ +package biomesoplenty.itemblocks; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ItemBlockHive extends ItemBlock +{ + private static final String[] types = new String[] {"honeycomb", "honeycombspawner", "hive", "hivespawner"}; + + public ItemBlockHive(int par1) + { + super(par1); + setMaxDamage(0); + setHasSubtypes(true); + } + + @Override + public int getMetadata(int meta) + { + return meta & 15; + } + + @Override + public String getUnlocalizedName(ItemStack itemstack) { + int meta = itemstack.getItemDamage(); + if (meta < 0 || meta >= types.length) { + meta = 0; + } + + return super.getUnlocalizedName() + "." + types[meta]; + } +} diff --git a/common/biomesoplenty/worldgen/WorldGenHive.java b/common/biomesoplenty/worldgen/WorldGenHive.java index 336a832bf..dd28718bb 100644 --- a/common/biomesoplenty/worldgen/WorldGenHive.java +++ b/common/biomesoplenty/worldgen/WorldGenHive.java @@ -24,41 +24,50 @@ public class WorldGenHive extends WorldGenerator return false; } - for (int cubeno = 0; cubeno < 3; cubeno++) + for (int cubeno = 0; cubeno < 4; cubeno++) { float chance = 0.0F; + int meta = 0; switch (cubeno) { case 0: chance = 0.25F; + meta = 0; break; case 1: chance = 1.0F; + meta = 0; break; case 2: + chance = 1.0F; + meta = 2; + break; + + case 3: chance = 0.5F; + meta = 2; break; } int honeychance = rand.nextInt(2); //Top - generateHiveCubeSmall(world, x, y + cubeno, z, (baseHeight - 8) + (cubeno * 2), (baseWidth - 1) + cubeno, cubeno, chance); + generateHiveCubeSmall(world, x, y + cubeno, z, (baseHeight - 11) + (cubeno * 2), (baseWidth - 1) + cubeno, cubeno, chance, meta); //Middle - generateHiveCube(world, x, (y - 2) + cubeno, z, baseHeight + (cubeno * 2), baseWidth + cubeno, cubeno, chance, honeychance); + generateHiveCube(world, x, (y - 2) + cubeno, z, baseHeight + (cubeno * 2), baseWidth + cubeno, cubeno, chance, honeychance, meta); //Bottom - generateHiveCubeSmall(world, x, (y - (baseHeight + 4)) + cubeno, z, (baseHeight - 8) + (cubeno * 2), (baseWidth - 1) + cubeno, cubeno, chance); + generateHiveCubeSmall(world, x, (y - (baseHeight + 6)) + cubeno, z, (baseHeight - 10) + (cubeno * 2), (baseWidth - 1) + cubeno, cubeno, chance, meta); //Bottom 2 - generateHiveCubeSmall(world, x, (y - (baseHeight + 5)) + cubeno, z, (baseHeight - 7) + (cubeno * 2), (baseWidth - 2) + cubeno, cubeno, chance); + generateHiveCubeSmall(world, x, (y - (baseHeight + 7)) + cubeno, z, (baseHeight - 9) + (cubeno * 2), (baseWidth - 2) + cubeno, cubeno, chance, meta); //Bottom 3 - generateHiveCubeSmall(world, x, (y - (baseHeight + 7)) + cubeno, z, (baseHeight - 7) + (cubeno * 2), (baseWidth - 4) + cubeno, cubeno, chance); + generateHiveCubeSmall(world, x, (y - (baseHeight + 9)) + cubeno, z, (baseHeight - 9) + (cubeno * 2), (baseWidth - 4) + cubeno, cubeno, chance, meta); spawnWasps(world, rand, x, y, z, 15); } @@ -66,7 +75,7 @@ public class WorldGenHive extends WorldGenerator return true; } - public void generateHiveCube(World world, int origx, int origy, int origz, int height, int width, int cubeno, float chance, int honeychance) + public void generateHiveCube(World world, int origx, int origy, int origz, int height, int width, int cubeno, float chance, int honeychance, int meta) { for (int hLayer = 0; hLayer < height; hLayer++) { @@ -74,30 +83,33 @@ public class WorldGenHive extends WorldGenerator { for (int j = -width; j < width; j++) { - if ((hLayer == 0 || hLayer == (height - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID); - else if ((i == -width || i == (width - 1) || j == -width || j == (width - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID); + if ((hLayer == 0 || hLayer == (height - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID, meta, 2); + else if ((i == -width || i == (width - 1) || j == -width || j == (width - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID, meta, 2); if (hLayer > (height / 2)) { if (honeychance == 0) { if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) != Blocks.hive.get().blockID) world.setBlock(origx + i, origy - hLayer, origz + j, Fluids.honey.get().blockID); + if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) == Blocks.hive.get().blockID && world.getBlockMetadata(origx + i, origy - hLayer, origz + j) != 0) world.setBlock(origx + i, origy - hLayer, origz + j, Fluids.honey.get().blockID); } else { if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) != Blocks.hive.get().blockID) world.setBlockToAir(origx + i, origy - hLayer, origz + j); + if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) == Blocks.hive.get().blockID && world.getBlockMetadata(origx + i, origy - hLayer, origz + j) != 0) world.setBlockToAir(origx + i, origy - hLayer, origz + j); } } else { if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) != Blocks.hive.get().blockID) world.setBlockToAir(origx + i, origy - hLayer, origz + j); + if (cubeno < 2 && world.getBlockId(origx + i, origy - hLayer, origz + j) == Blocks.hive.get().blockID && world.getBlockMetadata(origx + i, origy - hLayer, origz + j) != 0) world.setBlockToAir(origx + i, origy - hLayer, origz + j); } } } } } - public void generateHiveCubeSmall(World world, int origx, int origy, int origz, int height, int width, int cubeno, float chance) + public void generateHiveCubeSmall(World world, int origx, int origy, int origz, int height, int width, int cubeno, float chance, int meta) { for (int hLayer = 0; hLayer < height; hLayer++) { @@ -105,8 +117,8 @@ public class WorldGenHive extends WorldGenerator { for (int j = -width; j < width; j++) { - if ((hLayer == 0 || hLayer == (height - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID); - else if ((i == -width || i == (width - 1) || j == -width || j == (width - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID); + if ((hLayer == 0 || hLayer == (height - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID, meta, 2); + else if ((i == -width || i == (width - 1) || j == -width || j == (width - 1)) && (world.rand.nextFloat() <= chance)) world.setBlock(origx + i, origy - hLayer, origz + j, Blocks.hive.get().blockID, meta, 2); } } } @@ -122,14 +134,29 @@ public class WorldGenHive extends WorldGenerator if (world.getBlockId(spawnx, spawny, spawnz) == Blocks.hive.get().blockID) { - world.setBlock(spawnx, spawny, spawnz, Block.mobSpawner.blockID); - - TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getBlockTileEntity(spawnx, spawny, spawnz); - - if (tileentitymobspawner != null) - { - tileentitymobspawner.getSpawnerLogic().setMobID("BiomesOPlenty.Wasp"); - } + if (world.getBlockMetadata(spawnx, spawny, spawnz) == 0) + { + world.setBlock(spawnx, spawny, spawnz, Blocks.hive.get().blockID, 1, 0); + + TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getBlockTileEntity(spawnx, spawny, spawnz); + + if (tileentitymobspawner != null) + { + tileentitymobspawner.getSpawnerLogic().setMobID("BiomesOPlenty.Wasp"); + } + } + + if (world.getBlockMetadata(spawnx, spawny, spawnz) == 2) + { + world.setBlock(spawnx, spawny, spawnz, Blocks.hive.get().blockID, 3, 0); + + TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getBlockTileEntity(spawnx, spawny, spawnz); + + if (tileentitymobspawner != null) + { + tileentitymobspawner.getSpawnerLogic().setMobID("BiomesOPlenty.Wasp"); + } + } } } } diff --git a/resources/assets/biomesoplenty/lang/en_US.lang b/resources/assets/biomesoplenty/lang/en_US.lang index 0e492cd02..e899514da 100644 --- a/resources/assets/biomesoplenty/lang/en_US.lang +++ b/resources/assets/biomesoplenty/lang/en_US.lang @@ -157,7 +157,10 @@ tile.bop.moss.name=Moss tile.bop.cloud.name=Cloud Block -tile.bop.hive.name=Hive +tile.bop.hive.honeycomb.name=Honeycomb Block +tile.bop.hive.honeycombspawner.name=Honeycomb Wasp Spawner +tile.bop.hive.hive.name=Hive Block +tile.bop.hive.hivespawner.name=Hive Wasp Spawner tile.bop.bones.bones_small.name=Small Bone Segment tile.bop.bones.bones_medium.name=Medium Bone Segment diff --git a/resources/assets/biomesoplenty/textures/blocks/hive.png b/resources/assets/biomesoplenty/textures/blocks/hive.png index 37f1e1be3..8dcbbace9 100644 Binary files a/resources/assets/biomesoplenty/textures/blocks/hive.png and b/resources/assets/biomesoplenty/textures/blocks/hive.png differ diff --git a/resources/assets/biomesoplenty/textures/blocks/hivespawner.png b/resources/assets/biomesoplenty/textures/blocks/hivespawner.png index d04b1d83c..ca39af014 100644 Binary files a/resources/assets/biomesoplenty/textures/blocks/hivespawner.png and b/resources/assets/biomesoplenty/textures/blocks/hivespawner.png differ diff --git a/resources/assets/biomesoplenty/textures/blocks/honeycomb.png b/resources/assets/biomesoplenty/textures/blocks/honeycomb.png new file mode 100644 index 000000000..37f1e1be3 Binary files /dev/null and b/resources/assets/biomesoplenty/textures/blocks/honeycomb.png differ diff --git a/resources/assets/biomesoplenty/textures/blocks/hivealt.png b/resources/assets/biomesoplenty/textures/blocks/honeycombalt.png similarity index 100% rename from resources/assets/biomesoplenty/textures/blocks/hivealt.png rename to resources/assets/biomesoplenty/textures/blocks/honeycombalt.png diff --git a/resources/assets/biomesoplenty/textures/blocks/honeycombspawner.png b/resources/assets/biomesoplenty/textures/blocks/honeycombspawner.png new file mode 100644 index 000000000..d04b1d83c Binary files /dev/null and b/resources/assets/biomesoplenty/textures/blocks/honeycombspawner.png differ