Skip to content

Commit

Permalink
Fix crash from class loading being dumb (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Dec 11, 2017
1 parent 9990eb6 commit 359da92
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -75,16 +77,19 @@ public ToolNBT buildTagData(List<Material> 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();
Expand All @@ -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
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -92,11 +93,13 @@ protected ToolNBT buildTagData(List<Material> 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);
Expand Down

0 comments on commit 359da92

Please sign in to comment.