Changed various things to use IShearable.

Also some grass now can be replaced with blocks just like the vanilla
one.
This commit is contained in:
Amnet 2013-04-13 03:58:30 +02:00
parent c8f9b76d3c
commit 72bfd8af9d
13 changed files with 184 additions and 75 deletions

View file

@ -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;

View file

@ -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<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
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;
}
}

View file

@ -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<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z)));
return ret;
}
}

View file

@ -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<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z)));
return ret;
}
}

View file

@ -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;
}
}

View file

@ -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<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
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;
}
}

View file

@ -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<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
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;
}
}

View file

@ -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;
}
}

View file

@ -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<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
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;
}
}

View file

@ -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<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
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;
}
}

View file

@ -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<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune)
{
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z)));
return ret;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}