From bec6e0a1bb89069f56f7b720ce61cf385394d23c Mon Sep 17 00:00:00 2001 From: "Joseph C. Sible" Date: Tue, 12 Jun 2018 22:55:51 -0400 Subject: [PATCH] Remove the need for needsCustomInvWrapper --- .../mcjty/lib/tileentity/GenericTileEntity.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/mcjty/lib/tileentity/GenericTileEntity.java b/src/main/java/mcjty/lib/tileentity/GenericTileEntity.java index 232a3556..4a7b1038 100644 --- a/src/main/java/mcjty/lib/tileentity/GenericTileEntity.java +++ b/src/main/java/mcjty/lib/tileentity/GenericTileEntity.java @@ -387,6 +387,7 @@ public boolean receiveDataFromServer(String command, @Nonnull TypedMap result) { } + @Deprecated protected boolean needsCustomInvWrapper() { return false; } @@ -396,7 +397,7 @@ protected boolean needsCustomInvWrapper() { @Override public boolean hasCapability(Capability capability, EnumFacing facing) { - if (needsCustomInvWrapper()) { + if (facing == null ? this instanceof IInventory : this instanceof ISidedInventory) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return true; } @@ -407,18 +408,18 @@ public boolean hasCapability(Capability capability, EnumFacing facing) { @Override public T getCapability(Capability capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { - if (needsCustomInvWrapper()) { - if (facing == null) { + if (facing == null) { + if (this instanceof IInventory) { if (invHandlerNull == null) { invHandlerNull = new InvWrapper((IInventory) this); } return (T) invHandlerNull; - } else { - if (invHandlerSided == null) { - invHandlerSided = new NullSidedInvWrapper((ISidedInventory) this); - } - return (T) invHandlerSided; } + } else if (this instanceof ISidedInventory) { + if (invHandlerSided == null) { + invHandlerSided = new NullSidedInvWrapper((ISidedInventory) this); + } + return (T) invHandlerSided; } } return super.getCapability(capability, facing);