From 2c931fa8f45c7fa039c2e276aa1978d547f8db7a Mon Sep 17 00:00:00 2001 From: Amnet Date: Sun, 14 Apr 2013 00:16:42 +0200 Subject: [PATCH] Compression continues - Flowers --- .../biomesop/blocks/BlockBOPFlower.java | 66 +++++++++++++++++++ ...BlockFoliage.java => BlockBOPFoliage.java} | 6 +- .../biomesop/blocks/BlockBlueFlower.java | 1 + .../biomesop/blocks/BlockDeathbloom.java | 1 + .../biomesop/blocks/BlockGlowFlower.java | 1 + .../biomesop/blocks/BlockHydrangea.java | 1 + .../biomesop/blocks/BlockOrangeFlower.java | 1 + .../biomesop/blocks/BlockPinkFlower.java | 1 + .../biomesop/blocks/BlockPurpleFlower.java | 1 + .../tdwp_ftw/biomesop/blocks/BlockViolet.java | 1 + .../biomesop/blocks/BlockWhiteFlower.java | 1 + .../biomesop/configuration/BOPBlocks.java | 27 ++++++-- .../biomesop/items/ItemBOPFlower.java | 35 ++++++++++ 13 files changed, 135 insertions(+), 8 deletions(-) create mode 100644 src/minecraft/tdwp_ftw/biomesop/blocks/BlockBOPFlower.java rename src/minecraft/tdwp_ftw/biomesop/blocks/{BlockFoliage.java => BlockBOPFoliage.java} (93%) create mode 100644 src/minecraft/tdwp_ftw/biomesop/items/ItemBOPFlower.java diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBOPFlower.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBOPFlower.java new file mode 100644 index 000000000..319def097 --- /dev/null +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBOPFlower.java @@ -0,0 +1,66 @@ +package tdwp_ftw.biomesop.blocks; + +import java.util.List; + +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.item.ItemStack; +import net.minecraft.util.Icon; +import tdwp_ftw.biomesop.mod_BiomesOPlenty; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockBOPFlower extends BlockFlower +{ + private static final String[] plants = new String[] {"swampflower", "deadbloom", "glowflower", "hydrangea", "orangeflower", "pinkflower", "purpleflower", "violet", "whiteflower"}; + @SideOnly(Side.CLIENT) + private Icon[] textures; + + protected BlockBOPFlower(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(mod_BiomesOPlenty.tabBiomesOPlenty); + } + + public BlockBOPFlower(int blockID) + { + this(blockID, Material.plants); + } + + @Override + public void registerIcons(IconRegister iconRegister) + { + textures = new Icon[plants.length]; + + for (int i = 0; i < plants.length; ++i) + textures[i] = iconRegister.registerIcon("BiomesOPlenty:" + plants[i]); + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getBlockTextureFromSideAndMetadata(int side, int meta) + { + if (meta < 0 || meta >= textures.length) + meta = 0; + + return textures[meta]; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) { + for (int i = 0; i < plants.length; ++i) + list.add(new ItemStack(blockID, 1, i)); + } + + @Override + public int damageDropped(int meta) + { + return meta; + } +} diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockFoliage.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBOPFoliage.java similarity index 93% rename from src/minecraft/tdwp_ftw/biomesop/blocks/BlockFoliage.java rename to src/minecraft/tdwp_ftw/biomesop/blocks/BlockBOPFoliage.java index f0766cf11..463e7a6a2 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockFoliage.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBOPFoliage.java @@ -21,18 +21,18 @@ import tdwp_ftw.biomesop.configuration.BOPBlocks; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class BlockFoliage extends BlockFlower implements IShearable +public class BlockBOPFoliage extends BlockFlower implements IShearable { private static final String[] foliageTypes = new String[] {"shortgrass", "mediumgrass", "highgrassbottom", "highgrasstop"}; @SideOnly(Side.CLIENT) private Icon[] textures = {null, null, null, null}; private final int metadata; - public BlockFoliage(int blockID, int index) + public BlockBOPFoliage(int blockID, int index) { super(blockID, Material.vine); float f = 0.4F; - BlockFoliage.setBurnProperties(this.blockID, 60, 100); + BlockBOPFoliage.setBurnProperties(this.blockID, 60, 100); metadata = index; if (metadata == 3) diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBlueFlower.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBlueFlower.java index e352e1c8b..a0c657610 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBlueFlower.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBlueFlower.java @@ -9,6 +9,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import tdwp_ftw.biomesop.mod_BiomesOPlenty; +@Deprecated public class BlockBlueFlower extends Block { protected BlockBlueFlower(int par1, Material par3Material) diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockDeathbloom.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockDeathbloom.java index ce6dcda35..3427fb09a 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockDeathbloom.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockDeathbloom.java @@ -9,6 +9,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import tdwp_ftw.biomesop.mod_BiomesOPlenty; +@Deprecated public class BlockDeathbloom extends Block { protected BlockDeathbloom(int par1, Material par3Material) diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockGlowFlower.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockGlowFlower.java index bd29a6b9c..cfcc2bedd 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockGlowFlower.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockGlowFlower.java @@ -10,6 +10,7 @@ import net.minecraft.world.World; import tdwp_ftw.biomesop.mod_BiomesOPlenty; import tdwp_ftw.biomesop.configuration.BOPBlocks; +@Deprecated public class BlockGlowFlower extends Block { protected BlockGlowFlower(int par1, Material par3Material) diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockHydrangea.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockHydrangea.java index 6e0016ed5..76c6826af 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockHydrangea.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockHydrangea.java @@ -9,6 +9,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import tdwp_ftw.biomesop.mod_BiomesOPlenty; +@Deprecated public class BlockHydrangea extends Block { protected BlockHydrangea(int par1, Material par3Material) diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockOrangeFlower.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockOrangeFlower.java index 391a40e4d..1180edacb 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockOrangeFlower.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockOrangeFlower.java @@ -9,6 +9,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import tdwp_ftw.biomesop.mod_BiomesOPlenty; +@Deprecated public class BlockOrangeFlower extends Block { protected BlockOrangeFlower(int par1, Material par3Material) diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockPinkFlower.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockPinkFlower.java index 9881f28ca..9da0ccd7e 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockPinkFlower.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockPinkFlower.java @@ -10,6 +10,7 @@ import net.minecraft.world.World; import tdwp_ftw.biomesop.mod_BiomesOPlenty; import tdwp_ftw.biomesop.configuration.BOPBlocks; +@Deprecated public class BlockPinkFlower extends Block { protected BlockPinkFlower(int par1, Material par3Material) diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockPurpleFlower.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockPurpleFlower.java index 68463b192..84a0d4aff 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockPurpleFlower.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockPurpleFlower.java @@ -9,6 +9,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import tdwp_ftw.biomesop.mod_BiomesOPlenty; +@Deprecated public class BlockPurpleFlower extends Block { protected BlockPurpleFlower(int par1, Material par3Material) diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockViolet.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockViolet.java index 2bd0e3697..ff7dba85c 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockViolet.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockViolet.java @@ -9,6 +9,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import tdwp_ftw.biomesop.mod_BiomesOPlenty; +@Deprecated public class BlockViolet extends Block { protected BlockViolet(int par1, Material par3Material) diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockWhiteFlower.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockWhiteFlower.java index dd91ce790..9bfa54dbb 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockWhiteFlower.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockWhiteFlower.java @@ -9,6 +9,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import tdwp_ftw.biomesop.mod_BiomesOPlenty; +@Deprecated public class BlockWhiteFlower extends Block { protected BlockWhiteFlower(int par1, Material par3Material) diff --git a/src/minecraft/tdwp_ftw/biomesop/configuration/BOPBlocks.java b/src/minecraft/tdwp_ftw/biomesop/configuration/BOPBlocks.java index baf8955ba..bd0c7804f 100644 --- a/src/minecraft/tdwp_ftw/biomesop/configuration/BOPBlocks.java +++ b/src/minecraft/tdwp_ftw/biomesop/configuration/BOPBlocks.java @@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.oredict.OreDictionary; import tdwp_ftw.biomesop.blocks.*; +import tdwp_ftw.biomesop.items.ItemBOPFlower; import tdwp_ftw.biomesop.items.ItemBOPPlank; import tdwp_ftw.biomesop.items.ItemBOPSlab; import cpw.mods.fml.common.registry.GameRegistry; @@ -188,10 +189,12 @@ public class BOPBlocks { public static BlockHalfSlab holySingleSlab; public static Block holyStairs; - public static Block planks; - public static Block stairs; - public static BlockHalfSlab singleSlab; - public static BlockHalfSlab doubleSlab; + // New definitions +// public static Block planks; +// public static Block stairs; +// public static BlockHalfSlab singleSlab; +// public static BlockHalfSlab doubleSlab; +// public static Block flowers; public static void init() { @@ -428,8 +431,22 @@ public class BOPBlocks { LanguageRegistry.addName(new ItemStack(stairs,1,7), "Palm Wood Stairs"); LanguageRegistry.addName(new ItemStack(stairs,1,8), "Redwood Wood Stairs"); LanguageRegistry.addName(new ItemStack(stairs,1,9), "Willow Wood Stairs"); - */ + + // Flowers - mostly working, missing glow on Glowflower + flowers = (new BlockBOPFlower(2000)).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setUnlocalizedName("flowers"); + GameRegistry.registerBlock(flowers, ItemBOPFlower.class, "plants"); + LanguageRegistry.addName(new ItemStack(flowers,1,0), "Swampflower"); + LanguageRegistry.addName(new ItemStack(flowers,1,1), "Deathbloom"); + LanguageRegistry.addName(new ItemStack(flowers,1,2), "Glowflower"); + LanguageRegistry.addName(new ItemStack(flowers,1,3), "Hydrangea"); + LanguageRegistry.addName(new ItemStack(flowers,1,4), "Daisy"); + LanguageRegistry.addName(new ItemStack(flowers,1,5), "Tulip"); + LanguageRegistry.addName(new ItemStack(flowers,1,6), "Wildflower"); + LanguageRegistry.addName(new ItemStack(flowers,1,7), "Violet"); + LanguageRegistry.addName(new ItemStack(flowers,1,8), "Anemone"); + */ + // Add block registration GameRegistry.registerBlock(mud, "mud"); GameRegistry.registerBlock(driedDirt, "driedDirt"); diff --git a/src/minecraft/tdwp_ftw/biomesop/items/ItemBOPFlower.java b/src/minecraft/tdwp_ftw/biomesop/items/ItemBOPFlower.java new file mode 100644 index 000000000..84c410c88 --- /dev/null +++ b/src/minecraft/tdwp_ftw/biomesop/items/ItemBOPFlower.java @@ -0,0 +1,35 @@ +package tdwp_ftw.biomesop.items; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Icon; + +public class ItemBOPFlower extends ItemBlock +{ + private static final String[] plants = new String[] {"swampflower", "deadbloom", "glowflower", "hydrangea", "orangeflower", "pinkflower", "purpleflower", "violet", "whiteflower"}; + + public ItemBOPFlower(int par1) + { + super(par1); + setMaxDamage(0); + setHasSubtypes(true); + } + + @Override + public int getMetadata(int meta) + { + return meta; + } + + @Override + public String getUnlocalizedName(ItemStack itemStack) + { + return (new StringBuilder()).append(plants[itemStack.getItemDamage()]).toString(); + } + + public Icon getIconFromDamage(int meta) + { + return Block.blocksList[this.itemID].getBlockTextureFromSideAndMetadata(0, meta); + } +}