Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.OreIngredient;
Expand Down Expand Up @@ -410,7 +411,9 @@ public boolean supportsTool(ItemStack stack, ItemStack tool) {
}

private ToolStackHandler getHandler(ItemStack stack) {
return (ToolStackHandler) stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
IItemHandler handler = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (handler instanceof ToolStackHandler h) return h;
else return FALLBACK;
}

@Override
Expand Down Expand Up @@ -601,6 +604,8 @@ public void readNBTShareTag(ItemStack stack, NBTTagCompound nbt) {
stack.setTagCompound(nbt == null ? null : (nbt.hasKey("NBT") ? nbt.getCompoundTag("NBT") : null));
}

protected static final ToolStackHandler FALLBACK = new ToolStackHandler(0);

protected static class ToolStackHandler extends ItemStackHandler {

private static final Set<String> EMPTY = ImmutableSet.of();
Expand Down
Loading