Add in harvesting abilities of the items, should fix effectiveness

This commit is contained in:
Christian 2013-12-27 21:26:42 -05:00
parent b7eac150cc
commit 78b1b54e2b

View file

@ -152,17 +152,20 @@ public class ForgeHooks
toolInit = true;
Set<Block> blocks = ReflectionHelper.getPrivateValue(ItemPickaxe.class, null, 0);
setHarvestForItem(Arrays.asList(Items.wooden_pickaxe, Items.stone_pickaxe, Items.iron_pickaxe, Items.diamond_pickaxe), "pickaxe");
for (Block block : blocks)
{
block.setHarvestLevel("pickaxe", 0);
}
setHarvestForItem(Arrays.asList(Items.wooden_shovel, Items.stone_shovel, Items.iron_shovel, Items.diamond_shovel), "shovel");
blocks = ReflectionHelper.getPrivateValue(ItemSpade.class, null, 0);
for (Block block : blocks)
{
block.setHarvestLevel("shovel", 0);
}
setHarvestForItem(Arrays.asList(Items.wooden_axe, Items.stone_axe, Items.iron_axe, Items.diamond_axe), "axe");
blocks = ReflectionHelper.getPrivateValue(ItemAxe.class, null, 0);
for (Block block : blocks)
{
@ -180,6 +183,15 @@ public class ForgeHooks
Blocks.lapis_block.setHarvestLevel("pickaxe", 1);
}
private static void setHarvestForItem(List<Item> itemList, String toolClass)
{
for (int i = 0; i < itemList.size(); i++)
{
Item item = itemList.get(i);
item.setHarvestLevel("pickaxe", i);
}
}
public static int getTotalArmorValue(EntityPlayer player)
{
int ret = 0;
@ -325,7 +337,7 @@ public class ForgeHooks
{
for (int z2 = mZ; z2 < bb.maxZ; z2++)
{
block = world.func_147439_a(x2, y2, z2);
block = world.func_147439_a(x2, y2, z2);
if (block != null && block.isLadder(world, x2, y2, z2, entity))
{
return true;
@ -378,14 +390,14 @@ public class ForgeHooks
}
return event.component;
}
public static boolean canInteractWith(EntityPlayer player, Container openContainer)
{
PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer);
MinecraftForge.EVENT_BUS.post(event);
return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false;
}
public static BlockEvent.BreakEvent onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z)
{
// Logic from tryHarvestBlock for pre-canceling the event
@ -420,7 +432,7 @@ public class ForgeHooks
{
// Let the client know the block still exists
entityPlayer.playerNetServerHandler.func_147359_a(new S23PacketBlockChange(x, y, z, world));
// Update any tile entity data for this block
TileEntity tileentity = world.func_147438_o(x, y, z);
if (tileentity != null)