2013-06-18 08:59:00 +00:00
|
|
|
package biomesoplenty.items;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.BlockFlower;
|
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
2013-07-02 03:57:49 +00:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2013-06-18 08:59:00 +00:00
|
|
|
import net.minecraft.item.EnumToolMaterial;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import biomesoplenty.BiomesOPlenty;
|
|
|
|
import biomesoplenty.api.Blocks;
|
|
|
|
import biomesoplenty.api.Items;
|
|
|
|
import biomesoplenty.configuration.BOPItems;
|
|
|
|
|
|
|
|
public class ItemBOPScythe extends Item
|
|
|
|
{
|
|
|
|
public int textureID = 0;
|
|
|
|
|
|
|
|
public int damageVsEntity;
|
|
|
|
|
|
|
|
protected EnumToolMaterial toolMaterial;
|
|
|
|
|
|
|
|
public ItemBOPScythe(int id, int damage, EnumToolMaterial enumtoolmat, int texture)
|
|
|
|
{
|
|
|
|
super(id);
|
|
|
|
this.toolMaterial = enumtoolmat;
|
|
|
|
this.maxStackSize = 1;
|
|
|
|
this.setMaxDamage(enumtoolmat.getMaxUses());
|
|
|
|
textureID = texture;
|
2013-07-02 03:57:49 +00:00
|
|
|
this.damageVsEntity = (int) (damage + enumtoolmat.getDamageVsEntity());
|
2013-06-18 08:59:00 +00:00
|
|
|
setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
|
|
|
|
}
|
|
|
|
|
2013-07-01 00:31:34 +00:00
|
|
|
@Override
|
2013-07-02 03:57:49 +00:00
|
|
|
public boolean onBlockDestroyed(ItemStack itemstack, World world, int meta, int x, int y, int z, EntityLivingBase entity)
|
2013-06-18 08:59:00 +00:00
|
|
|
{
|
|
|
|
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
|
|
|
int radius = 1;
|
|
|
|
int height = 3;
|
|
|
|
|
|
|
|
if (toolMaterial == EnumToolMaterial.IRON || toolMaterial == EnumToolMaterial.GOLD)
|
|
|
|
{
|
2013-06-18 09:31:22 +00:00
|
|
|
if (block != null)
|
|
|
|
{
|
|
|
|
if (block.isLeaves(world, x, y, z))
|
|
|
|
height = 2;
|
|
|
|
}
|
|
|
|
|
2013-06-18 08:59:00 +00:00
|
|
|
radius = 2;
|
|
|
|
}
|
|
|
|
else if (toolMaterial == EnumToolMaterial.EMERALD)
|
|
|
|
{
|
2013-06-18 09:31:22 +00:00
|
|
|
if (block != null)
|
|
|
|
{
|
|
|
|
if (block.isLeaves(world, x, y, z))
|
|
|
|
height = 3;
|
|
|
|
}
|
|
|
|
|
2013-06-18 08:59:00 +00:00
|
|
|
radius = 3;
|
|
|
|
}
|
|
|
|
else if (toolMaterial == BOPItems.EnumToolMaterialAmethyst)
|
|
|
|
{
|
2013-06-18 09:31:22 +00:00
|
|
|
if (block != null)
|
|
|
|
{
|
|
|
|
if (block.isLeaves(world, x, y, z))
|
|
|
|
height = 4;
|
|
|
|
}
|
|
|
|
|
2013-06-18 08:59:00 +00:00
|
|
|
radius = 4;
|
|
|
|
}
|
2013-06-18 09:31:22 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (block != null)
|
|
|
|
{
|
|
|
|
if (block.isLeaves(world, x, y, z))
|
|
|
|
height = 0;
|
|
|
|
}
|
|
|
|
}
|
2013-06-18 08:59:00 +00:00
|
|
|
|
|
|
|
if (block != null)
|
|
|
|
{
|
|
|
|
if (block.isLeaves(world, x, y, z))
|
|
|
|
{
|
2013-06-18 09:31:22 +00:00
|
|
|
if (height > 0)
|
|
|
|
{
|
2013-07-04 00:07:17 +00:00
|
|
|
trimLeaves(itemstack, entity, world, x, y, z, height, radius);
|
2013-06-18 08:59:00 +00:00
|
|
|
|
2013-06-18 09:31:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-06-18 08:59:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-04 00:07:17 +00:00
|
|
|
trimCutCorner(itemstack, entity, world, x, y, z, height, radius);
|
2013-06-18 08:59:00 +00:00
|
|
|
|
|
|
|
if (world.rand.nextInt(3) == 0)
|
|
|
|
{
|
2013-07-04 00:07:17 +00:00
|
|
|
trim(itemstack, entity, world, x, y, z, height, radius - 1);
|
2013-06-18 08:59:00 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-07-04 00:07:17 +00:00
|
|
|
public void trim(ItemStack stack, EntityLivingBase entity, World world, int x, int y, int z, int height, int radius)
|
2013-06-18 08:59:00 +00:00
|
|
|
{
|
|
|
|
for (int aX = -radius; aX <= radius; aX++)
|
|
|
|
{
|
|
|
|
for (int aY = 0; aY <= radius; aY++)
|
|
|
|
{
|
|
|
|
for (int aZ = -radius; aZ <= radius; aZ++)
|
|
|
|
{
|
|
|
|
Block block = Block.blocksList[world.getBlockId(x + aX, y + aY, z + aZ)];
|
|
|
|
int meta = world.getBlockMetadata(x + aX, y + aY, z + aZ);
|
|
|
|
|
|
|
|
if (block != null)
|
|
|
|
{
|
2013-07-04 00:07:17 +00:00
|
|
|
if (world.rand.nextInt(3) == 0)
|
|
|
|
{
|
|
|
|
stack.damageItem(1, entity);
|
|
|
|
}
|
|
|
|
|
2013-06-18 08:59:00 +00:00
|
|
|
if (block.blockID == Blocks.foliage.get().blockID && (meta == 1 || meta == 2 || meta == 6))
|
|
|
|
{
|
|
|
|
if (meta == 1)
|
|
|
|
{
|
|
|
|
block.dropBlockAsItem(world, x + aX, y + aY, z + aZ, meta, 0);
|
|
|
|
world.setBlockToAir(x + aX, y + aY, z + aZ);
|
|
|
|
}
|
|
|
|
else if (meta == 2)
|
|
|
|
{
|
|
|
|
block.dropBlockAsItem(world, x + aX, y + aY, z + aZ, meta, 0);
|
|
|
|
world.setBlock(x + aX, y + aY, z + aZ, Blocks.foliage.get().blockID, 1, 2);
|
|
|
|
}
|
|
|
|
else if (meta == 6)
|
|
|
|
{
|
|
|
|
block.dropBlockAsItem(world, x + aX, y + aY, z + aZ, meta, 0);
|
|
|
|
world.setBlockToAir(x + aX, y + aY, z + aZ);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (block.blockID == Block.tallGrass.blockID)
|
|
|
|
{
|
|
|
|
block.dropBlockAsItem(world, x + aX, y + aY, z + aZ, meta, 0);
|
|
|
|
world.setBlock(x + aX, y + aY, z + aZ, Blocks.foliage.get().blockID, 2, 2);
|
|
|
|
}
|
|
|
|
else if (block.blockID != Block.waterlily.blockID && block instanceof BlockFlower)
|
|
|
|
{
|
|
|
|
System.out.println(block.getBlockDropped(world, x + aX, y + aY, z + aZ, meta, 1));
|
|
|
|
|
|
|
|
block.dropBlockAsItem(world, x + aX, y + aY, z + aZ, meta, 0);
|
|
|
|
world.setBlockToAir(x + aX, y + aY, z + aZ);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-04 00:07:17 +00:00
|
|
|
public void trimLeaves(ItemStack stack, EntityLivingBase entity, World world, int x, int y, int z, int height, int radius)
|
2013-06-18 08:59:00 +00:00
|
|
|
{
|
|
|
|
for (int aX = -radius; aX <= radius; aX++)
|
|
|
|
{
|
|
|
|
for (int aY = -radius; aY <= radius; aY++)
|
|
|
|
{
|
|
|
|
for (int aZ = -radius; aZ <= radius; aZ++)
|
|
|
|
{
|
|
|
|
Block block = Block.blocksList[world.getBlockId(x + aX, y + aY, z + aZ)];
|
|
|
|
int meta = world.getBlockMetadata(x + aX, y + aY, z + aZ);
|
|
|
|
|
|
|
|
if (block != null)
|
2013-07-04 00:07:17 +00:00
|
|
|
{
|
2013-06-18 08:59:00 +00:00
|
|
|
if (block.isLeaves(world, x + aX, y + aY, z + aZ))
|
|
|
|
{
|
2013-07-04 00:07:17 +00:00
|
|
|
if (block.isLeaves(world, x + aX + 1, y + aY, z + aZ) && block.isLeaves(world, x + aX - 1, y + aY, z + aZ) && block.isLeaves(world, x + aX, y + aY, z + aZ + 1) && block.isLeaves(world, x + aX, y + aY, z + aZ - 1))
|
|
|
|
{
|
|
|
|
if (world.rand.nextInt(6) == 0)
|
|
|
|
{
|
|
|
|
stack.damageItem(1, entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
block.dropBlockAsItem(world, x + aX, y + aY, z + aZ, meta, 0);
|
|
|
|
world.setBlockToAir(x + aX, y + aY, z + aZ);
|
|
|
|
}
|
2013-06-18 08:59:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-04 00:07:17 +00:00
|
|
|
public void trimCutCorner(ItemStack stack, EntityLivingBase entity, World world, int x, int y, int z, int height, int radius)
|
2013-06-18 08:59:00 +00:00
|
|
|
{
|
|
|
|
for (int aX = -radius; aX <= radius; aX++)
|
|
|
|
{
|
|
|
|
for (int aY = 0; aY <= radius; aY++)
|
|
|
|
{
|
|
|
|
for (int aZ = -radius; aZ <= radius; aZ++)
|
|
|
|
{
|
|
|
|
if ((aX + aZ < radius * 2) && (-aX + aZ < radius * 2) && (aX + -aZ < radius * 2) && (-aX + -aZ < radius * 2))
|
|
|
|
{
|
|
|
|
Block block = Block.blocksList[world.getBlockId(x + aX, y + aY, z + aZ)];
|
|
|
|
int meta = world.getBlockMetadata(x + aX, y + aY, z + aZ);
|
|
|
|
|
|
|
|
if (block != null)
|
|
|
|
{
|
2013-07-04 00:07:17 +00:00
|
|
|
if (world.rand.nextInt(4) == 0)
|
|
|
|
{
|
|
|
|
stack.damageItem(1, entity);
|
|
|
|
}
|
|
|
|
|
2013-06-18 08:59:00 +00:00
|
|
|
if (block.blockID == Blocks.foliage.get().blockID && (meta == 1 || meta == 2 || meta == 6))
|
|
|
|
{
|
|
|
|
if (meta == 1)
|
|
|
|
{
|
|
|
|
block.dropBlockAsItem(world, x + aX, y + aY, z + aZ, meta, 0);
|
|
|
|
world.setBlockToAir(x + aX, y + aY, z + aZ);
|
|
|
|
}
|
|
|
|
else if (meta == 2)
|
|
|
|
{
|
|
|
|
block.dropBlockAsItem(world, x + aX, y + aY, z + aZ, meta, 0);
|
|
|
|
world.setBlock(x + aX, y + aY, z + aZ, Blocks.foliage.get().blockID, 1, 2);
|
|
|
|
}
|
|
|
|
else if (meta == 6)
|
|
|
|
{
|
|
|
|
block.dropBlockAsItem(world, x + aX, y + aY, z + aZ, meta, 0);
|
|
|
|
world.setBlockToAir(x + aX, y + aY, z + aZ);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (block.blockID == Block.tallGrass.blockID)
|
|
|
|
{
|
|
|
|
block.dropBlockAsItem(world, x + aX, y + aY, z + aZ, meta, 0);
|
|
|
|
world.setBlock(x + aX, y + aY, z + aZ, Blocks.foliage.get().blockID, 2, 2);
|
|
|
|
}
|
|
|
|
else if (block.blockID != Block.waterlily.blockID && block instanceof BlockFlower)
|
|
|
|
{
|
|
|
|
block.dropBlockAsItem(world, x + aX, y + aY, z + aZ, meta, 0);
|
|
|
|
world.setBlockToAir(x + aX, y + aY, z + aZ);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
|
|
|
|
{
|
|
|
|
float strength = 0;
|
|
|
|
|
|
|
|
if (Blocks.shearBlockIds.get(par2Block.blockID) != null)
|
|
|
|
{
|
|
|
|
strength = Float.parseFloat(Blocks.shearBlockIds.get(par2Block.blockID).toString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strength = super.getStrVsBlock(par1ItemStack, par2Block);
|
|
|
|
}
|
|
|
|
|
|
|
|
return strength;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemEnchantability()
|
|
|
|
{
|
|
|
|
return this.toolMaterial.getEnchantability();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
|
|
|
|
{
|
|
|
|
if (textureID == 0 && par2ItemStack.itemID == Block.wood.blockID)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (textureID == 1 && par2ItemStack.itemID == Block.cobblestone.blockID)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (textureID == 2 && par2ItemStack.itemID == Item.ingotIron.itemID)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (textureID == 3 && par2ItemStack.itemID == Item.ingotGold.itemID)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (textureID == 4 && par2ItemStack.itemID == Item.diamond.itemID)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (textureID == 6 && par2ItemStack.itemID == Items.miscItems.get().itemID && par2ItemStack.getItemDamage() == 2)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isFull3D()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerIcons(IconRegister iconRegister)
|
|
|
|
{
|
|
|
|
if (textureID == 0)
|
|
|
|
{
|
2013-07-03 06:01:28 +00:00
|
|
|
itemIcon = iconRegister.registerIcon("biomesoplenty:woodscythe");
|
2013-06-18 08:59:00 +00:00
|
|
|
}
|
|
|
|
else if (textureID == 1)
|
|
|
|
{
|
2013-07-03 06:01:28 +00:00
|
|
|
itemIcon = iconRegister.registerIcon("biomesoplenty:stonescythe");
|
2013-06-18 08:59:00 +00:00
|
|
|
}
|
|
|
|
else if (textureID == 2)
|
|
|
|
{
|
2013-07-03 06:01:28 +00:00
|
|
|
itemIcon = iconRegister.registerIcon("biomesoplenty:ironscythe");
|
2013-06-18 08:59:00 +00:00
|
|
|
}
|
|
|
|
else if (textureID == 3)
|
|
|
|
{
|
2013-07-03 06:01:28 +00:00
|
|
|
itemIcon = iconRegister.registerIcon("biomesoplenty:goldscythe");
|
2013-06-18 08:59:00 +00:00
|
|
|
}
|
|
|
|
else if (textureID == 4)
|
|
|
|
{
|
2013-07-03 06:01:28 +00:00
|
|
|
itemIcon = iconRegister.registerIcon("biomesoplenty:diamondscythe");
|
2013-06-18 08:59:00 +00:00
|
|
|
}
|
|
|
|
else if (textureID == 5)
|
|
|
|
{
|
2013-07-03 06:01:28 +00:00
|
|
|
itemIcon = iconRegister.registerIcon("biomesoplenty:mudscythe");
|
2013-06-18 08:59:00 +00:00
|
|
|
}
|
|
|
|
else if (textureID == 6)
|
|
|
|
{
|
2013-07-03 06:01:28 +00:00
|
|
|
itemIcon = iconRegister.registerIcon("biomesoplenty:amethystscythe");
|
2013-06-18 08:59:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-03 06:01:28 +00:00
|
|
|
itemIcon = iconRegister.registerIcon("biomesoplenty:mudball");
|
2013-06-18 08:59:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|