From 72bfd8af9d46f138074e36ca1fdc1c039e942518 Mon Sep 17 00:00:00 2001 From: Amnet Date: Sat, 13 Apr 2013 03:58:30 +0200 Subject: [PATCH] Changed various things to use IShearable. Also some grass now can be replaced with blocks just like the vanilla one. --- .../tdwp_ftw/biomesop/blocks/BlockAlgae.java | 4 ++- .../tdwp_ftw/biomesop/blocks/BlockBush.java | 34 ++++++++++++------ .../biomesop/blocks/BlockDeadGrass.java | 28 +++++++++------ .../biomesop/blocks/BlockDesertGrass.java | 30 +++++++++------- .../biomesop/blocks/BlockHighGrassBottom.java | 6 ++++ .../biomesop/blocks/BlockHolyTallGrass.java | 8 +++++ .../biomesop/blocks/BlockMediumGrass.java | 34 ++++++++++++------ .../tdwp_ftw/biomesop/blocks/BlockMoss.java | 6 ++++ .../biomesop/blocks/BlockShortGrass.java | 36 ++++++++++++------- .../tdwp_ftw/biomesop/blocks/BlockSprout.java | 34 ++++++++++++------ .../tdwp_ftw/biomesop/blocks/BlockThorn.java | 28 +++++++++------ .../biomesop/blocks/BlockTreeMoss.java | 5 +++ .../tdwp_ftw/biomesop/blocks/BlockWillow.java | 6 ++++ 13 files changed, 184 insertions(+), 75 deletions(-) diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockAlgae.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockAlgae.java index 964d47c4e..25cfbf8c9 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockAlgae.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockAlgae.java @@ -6,9 +6,11 @@ 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.util.AxisAlignedBB; import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; public class BlockAlgae extends BlockFlower { @@ -33,7 +35,7 @@ public class BlockAlgae extends BlockFlower { this.blockIcon = par1IconRegister.registerIcon("BiomesOPlenty:algae"); } - + public int getBlockColor() { double var1 = 0.5D; diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBush.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBush.java index 4ae3f9cea..b3e25b3e4 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBush.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockBush.java @@ -1,5 +1,6 @@ package tdwp_ftw.biomesop.blocks; +import java.util.ArrayList; import java.util.Random; import net.minecraft.block.Block; @@ -14,9 +15,10 @@ import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.ColorizerGrass; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; import tdwp_ftw.biomesop.configuration.BOPItems; -public class BlockBush extends BlockFlower +public class BlockBush extends BlockFlower implements IShearable { public BlockBush(int par1) { @@ -106,15 +108,7 @@ public class BlockBush extends BlockFlower */ public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { - if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.itemID) - { - par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); - this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(BOPItems.bushItem, 1, par6)); - } - else - { - super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); - } + super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); } /** @@ -124,4 +118,24 @@ public class BlockBush extends BlockFlower { return BOPItems.bushItem.itemID; } + + @Override + public boolean isShearable(ItemStack item, World world, int x, int y, int z) + { + return true; + } + + @Override + public ArrayList onSheared(ItemStack item, World world, int x, int y, int z, int fortune) + { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(BOPItems.bushItem.itemID, 1, -1)); + return ret; + } + + @Override + public boolean isBlockReplaceable(World world, int x, int y, int z) + { + return true; + } } diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockDeadGrass.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockDeadGrass.java index 1cb5bd32e..11f59ae56 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockDeadGrass.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockDeadGrass.java @@ -1,5 +1,6 @@ package tdwp_ftw.biomesop.blocks; +import java.util.ArrayList; import java.util.Random; import net.minecraft.block.Block; @@ -11,10 +12,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.stats.StatList; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; import tdwp_ftw.biomesop.mod_BiomesOPlenty; import tdwp_ftw.biomesop.configuration.BOPBlocks; -public class BlockDeadGrass extends Block +public class BlockDeadGrass extends Block implements IShearable { protected BlockDeadGrass(int par1, Material par3Material) { @@ -137,14 +139,20 @@ public class BlockDeadGrass extends Block */ public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { - if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.itemID) - { - par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); - this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(BOPBlocks.deadGrass, 1, par6)); - } - else - { - super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); - } + super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); + } + + @Override + public boolean isShearable(ItemStack item, World world, int x, int y, int z) + { + return true; + } + + @Override + public ArrayList onSheared(ItemStack item, World world, int x, int y, int z, int fortune) + { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z))); + return ret; } } diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockDesertGrass.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockDesertGrass.java index 2c3556a3c..6c139cae5 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockDesertGrass.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockDesertGrass.java @@ -1,20 +1,20 @@ package tdwp_ftw.biomesop.blocks; +import java.util.ArrayList; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.stats.StatList; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; import tdwp_ftw.biomesop.mod_BiomesOPlenty; import tdwp_ftw.biomesop.configuration.BOPBlocks; -public class BlockDesertGrass extends Block +public class BlockDesertGrass extends Block implements IShearable { protected BlockDesertGrass(int par1, Material par3Material) { @@ -137,14 +137,20 @@ public class BlockDesertGrass extends Block */ public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { - if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.itemID) - { - par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); - this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(BOPBlocks.desertGrass, 1, par6)); - } - else - { - super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); - } + super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); + } + + @Override + public boolean isShearable(ItemStack item, World world, int x, int y, int z) + { + return true; + } + + @Override + public ArrayList onSheared(ItemStack item, World world, int x, int y, int z, int fortune) + { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z))); + return ret; } } diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockHighGrassBottom.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockHighGrassBottom.java index 7bbc8e844..2e6140530 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockHighGrassBottom.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockHighGrassBottom.java @@ -94,4 +94,10 @@ public class BlockHighGrassBottom extends BlockFlower { return -1; } + + @Override + public boolean isBlockReplaceable(World world, int x, int y, int z) + { + return true; + } } diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockHolyTallGrass.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockHolyTallGrass.java index 1a494fd79..accc16741 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockHolyTallGrass.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockHolyTallGrass.java @@ -130,15 +130,23 @@ public class BlockHolyTallGrass extends Block implements IShearable return 1; } + @Override public boolean isShearable(ItemStack item, World world, int x, int y, int z) { return true; } + @Override public ArrayList onSheared(ItemStack item, World world, int x, int y, int z, int fortune) { ArrayList ret = new ArrayList(); ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z))); return ret; } + + @Override + public boolean isBlockReplaceable(World world, int x, int y, int z) + { + return true; + } } diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockMediumGrass.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockMediumGrass.java index 67d608b1d..94bd5dea8 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockMediumGrass.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockMediumGrass.java @@ -1,5 +1,6 @@ package tdwp_ftw.biomesop.blocks; +import java.util.ArrayList; import java.util.Random; import net.minecraft.block.Block; @@ -14,9 +15,10 @@ import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.ColorizerGrass; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; import tdwp_ftw.biomesop.configuration.BOPItems; -public class BlockMediumGrass extends BlockFlower +public class BlockMediumGrass extends BlockFlower implements IShearable { public BlockMediumGrass(int par1) { @@ -106,15 +108,7 @@ public class BlockMediumGrass extends BlockFlower */ public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { - if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.itemID) - { - par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); - this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(BOPItems.mediumGrassItem, 1, par6)); - } - else - { - super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); - } + super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); } /** @@ -124,4 +118,24 @@ public class BlockMediumGrass extends BlockFlower { return BOPItems.mediumGrassItem.itemID; } + + @Override + public boolean isShearable(ItemStack item, World world, int x, int y, int z) + { + return true; + } + + @Override + public ArrayList onSheared(ItemStack item, World world, int x, int y, int z, int fortune) + { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(BOPItems.mediumGrassItem.itemID, 1, -1)); + return ret; + } + + @Override + public boolean isBlockReplaceable(World world, int x, int y, int z) + { + return true; + } } diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockMoss.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockMoss.java index a85ac000b..54969e1a3 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockMoss.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockMoss.java @@ -474,4 +474,10 @@ public class BlockMoss extends Block { return BOPItems.mossItem.itemID; } + + @Override + public boolean isBlockReplaceable(World world, int x, int y, int z) + { + return true; + } } diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockShortGrass.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockShortGrass.java index b4956e889..27f15c436 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockShortGrass.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockShortGrass.java @@ -1,5 +1,6 @@ package tdwp_ftw.biomesop.blocks; +import java.util.ArrayList; import java.util.Random; import net.minecraft.block.Block; @@ -7,16 +8,15 @@ import net.minecraft.block.BlockFlower; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.stats.StatList; import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.ColorizerGrass; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; import tdwp_ftw.biomesop.configuration.BOPItems; -public class BlockShortGrass extends BlockFlower +public class BlockShortGrass extends BlockFlower implements IShearable { public BlockShortGrass(int par1) { @@ -106,15 +106,7 @@ public class BlockShortGrass extends BlockFlower */ public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { - if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.itemID) - { - par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); - this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(BOPItems.shortGrassItem, 1, par6)); - } - else - { - super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); - } + super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); } /** @@ -124,4 +116,24 @@ public class BlockShortGrass extends BlockFlower { return BOPItems.shortGrassItem.itemID; } + + @Override + public boolean isShearable(ItemStack item, World world, int x, int y, int z) + { + return true; + } + + @Override + public ArrayList onSheared(ItemStack item, World world, int x, int y, int z, int fortune) + { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(BOPItems.shortGrassItem.itemID, 1, -1)); + return ret; + } + + @Override + public boolean isBlockReplaceable(World world, int x, int y, int z) + { + return true; + } } diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockSprout.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockSprout.java index 95fd1daec..92f980004 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockSprout.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockSprout.java @@ -1,5 +1,6 @@ package tdwp_ftw.biomesop.blocks; +import java.util.ArrayList; import java.util.Random; import net.minecraft.block.Block; @@ -14,9 +15,10 @@ import net.minecraft.world.ColorizerFoliage; import net.minecraft.world.ColorizerGrass; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; import tdwp_ftw.biomesop.configuration.BOPItems; -public class BlockSprout extends BlockFlower +public class BlockSprout extends BlockFlower implements IShearable { public BlockSprout(int par1) { @@ -106,15 +108,7 @@ public class BlockSprout extends BlockFlower */ public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { - if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.itemID) - { - par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); - this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(BOPItems.sproutItem, 1, par6)); - } - else - { - super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); - } + super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); } /** @@ -124,4 +118,24 @@ public class BlockSprout extends BlockFlower { return BOPItems.sproutItem.itemID; } + + @Override + public boolean isShearable(ItemStack item, World world, int x, int y, int z) + { + return true; + } + + @Override + public ArrayList onSheared(ItemStack item, World world, int x, int y, int z, int fortune) + { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(BOPItems.sproutItem.itemID, 1, -1)); + return ret; + } + + @Override + public boolean isBlockReplaceable(World world, int x, int y, int z) + { + return true; + } } diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockThorn.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockThorn.java index 2a37ffa39..da6dbaf1b 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockThorn.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockThorn.java @@ -1,5 +1,6 @@ package tdwp_ftw.biomesop.blocks; +import java.util.ArrayList; import java.util.Random; import net.minecraft.block.Block; @@ -13,10 +14,11 @@ import net.minecraft.stats.StatList; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; import tdwp_ftw.biomesop.mod_BiomesOPlenty; import tdwp_ftw.biomesop.configuration.BOPBlocks; -public class BlockThorn extends Block +public class BlockThorn extends Block implements IShearable { protected BlockThorn(int par1, Material par3Material) { @@ -146,14 +148,20 @@ public class BlockThorn extends Block */ public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { - if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.itemID) - { - par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); - this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(BOPBlocks.thorn, 1, par6)); - } - else - { - super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); - } + super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); + } + + @Override + public boolean isShearable(ItemStack item, World world, int x, int y, int z) + { + return true; + } + + @Override + public ArrayList onSheared(ItemStack item, World world, int x, int y, int z, int fortune) + { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z))); + return ret; } } diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockTreeMoss.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockTreeMoss.java index 11e2691b7..f2ae7ef15 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockTreeMoss.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockTreeMoss.java @@ -337,4 +337,9 @@ public class BlockTreeMoss extends Block implements IShearable ret.add(new ItemStack(this, 1, 0)); return ret; } + + public boolean isBlockReplaceable(World world, int x, int y, int z) + { + return true; + } } diff --git a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockWillow.java b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockWillow.java index 8a3c58706..69fca051b 100644 --- a/src/minecraft/tdwp_ftw/biomesop/blocks/BlockWillow.java +++ b/src/minecraft/tdwp_ftw/biomesop/blocks/BlockWillow.java @@ -358,4 +358,10 @@ public class BlockWillow extends Block implements IShearable ret.add(new ItemStack(this, 1, 0)); return ret; } + + @Override + public boolean isBlockReplaceable(World world, int x, int y, int z) + { + return true; + } }