From 359da927c59926f4c95239fad7fc745139d6e550 Mon Sep 17 00:00:00 2001 From: KnightMiner Date: Mon, 11 Dec 2017 08:59:37 -0600 Subject: [PATCH] Fix crash from class loading being dumb (#7) --- .../tcomplement/plugin/chisel/items/ItemChisel.java | 9 +++++++++ .../plugin/exnihilo/items/ItemSledgeHammer.java | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/knightminer/tcomplement/plugin/chisel/items/ItemChisel.java b/src/main/java/knightminer/tcomplement/plugin/chisel/items/ItemChisel.java index 80791a1..f01ac6b 100644 --- a/src/main/java/knightminer/tcomplement/plugin/chisel/items/ItemChisel.java +++ b/src/main/java/knightminer/tcomplement/plugin/chisel/items/ItemChisel.java @@ -11,6 +11,7 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.common.Optional; import slimeknights.tconstruct.library.materials.HandleMaterialStats; import slimeknights.tconstruct.library.materials.HeadMaterialStats; import slimeknights.tconstruct.library.materials.Material; @@ -30,6 +31,7 @@ import team.chisel.api.carving.ICarvingVariation; import team.chisel.api.carving.IChiselMode; +@Optional.Interface(iface="team.chisel.api.IChiselItem", modid="chisel") public class ItemChisel extends AoeToolCore implements IChiselItem { public static final float DURABILITY_MODIFIER = 2.25f; @@ -75,16 +77,19 @@ public ToolNBT buildTagData(List materials) { } /* Chisel logic */ + @Optional.Method(modid="chisel") @Override public boolean canOpenGui(World world, EntityPlayer player, EnumHand hand) { return !ToolHelper.isBroken(player.getHeldItem(hand)); } + @Optional.Method(modid="chisel") @Override public IChiselGuiType getGuiType(World world, EntityPlayer player, EnumHand hand) { return ChiselGuiType.NORMAL; } + @Optional.Method(modid="chisel") @Override public boolean supportsMode(EntityPlayer player, ItemStack stack, IChiselMode mode) { String name = mode.name(); @@ -109,17 +114,20 @@ public boolean supportsMode(EntityPlayer player, ItemStack stack, IChiselMode mo return false; } + @Optional.Method(modid="chisel") @Override public boolean onChisel(World world, EntityPlayer player, ItemStack chisel, ICarvingVariation target) { return true; } + @Optional.Method(modid="chisel") @Override public boolean canChisel(World world, EntityPlayer player, ItemStack chisel, ICarvingVariation target) { // block if broken return !ToolHelper.isBroken(chisel); } + @Optional.Method(modid="chisel") @Override public boolean canChiselBlock(World world, EntityPlayer player, EnumHand hand, BlockPos pos, IBlockState state) { // block if broken @@ -132,6 +140,7 @@ public boolean canChiselBlock(World world, EntityPlayer player, EnumHand hand, B return ToolHelper.getHarvestLevelStat(chisel) >= state.getBlock().getHarvestLevel(state); } + @Optional.Method(modid="chisel") @Override public ItemStack craftItem(ItemStack chisel, ItemStack source, ItemStack target, EntityPlayer player) { int toCraft = Math.min(source.getCount(), target.getMaxStackSize()); diff --git a/src/main/java/knightminer/tcomplement/plugin/exnihilo/items/ItemSledgeHammer.java b/src/main/java/knightminer/tcomplement/plugin/exnihilo/items/ItemSledgeHammer.java index 68843d4..a9a434e 100644 --- a/src/main/java/knightminer/tcomplement/plugin/exnihilo/items/ItemSledgeHammer.java +++ b/src/main/java/knightminer/tcomplement/plugin/exnihilo/items/ItemSledgeHammer.java @@ -9,6 +9,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fml.common.Optional; import slimeknights.tconstruct.library.materials.Material; import slimeknights.tconstruct.library.tinkering.Category; import slimeknights.tconstruct.library.tinkering.PartMaterialType; @@ -21,7 +22,7 @@ import slimeknights.tconstruct.tools.TinkerTools; // apparently Forge does not like that this class is referenced from ExNihiloPlugin -//@Optional.Interface(iface="exnihilocreatio.items.tools.IHammer", modid="exnihilocreatio") +@Optional.Interface(iface="exnihilocreatio.items.tools.IHammer", modid="exnihilocreatio") public class ItemSledgeHammer extends AoeToolCore implements IHammer { public ItemSledgeHammer() { @@ -92,11 +93,13 @@ protected ToolNBT buildTagData(List materials) { } /* Hammer things */ + @Optional.Method(modid="exnihilocreatio") @Override public boolean isHammer(ItemStack stack) { return true; } + @Optional.Method(modid="exnihilocreatio") @Override public int getMiningLevel(ItemStack stack) { return ToolHelper.getHarvestLevelStat(stack);