From 79660f3f6fe44b0f33ec617361199de719611104 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 29 May 2016 23:39:50 +0200 Subject: [PATCH] Made hasCapability not call getCapability. Supposedly closes #97 --- .../mod/tile/TileEntityInventoryBase.java | 8 ++++++-- .../mod/tile/TileEntityPhantomItemface.java | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java index 1f2c8190d..884deb7c9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java @@ -223,13 +223,13 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements @Override public boolean hasCapability(@Nonnull Capability capability, @Nonnull EnumFacing facing){ - return this.getCapability(capability, facing) != null; + return this.canHandleCapability(capability) || super.hasCapability(capability, facing); } @Nonnull @Override public T getCapability(@Nonnull Capability capability, @Nonnull EnumFacing facing){ - if(this.hasInvWrapperCapabilities() && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY){ + if(this.canHandleCapability(capability)){ return (T)this.invWrappers[facing.ordinal()]; } else{ @@ -237,6 +237,10 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements } } + private boolean canHandleCapability(Capability capability){ + return this.hasInvWrapperCapabilities() && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY; + } + public boolean hasInvWrapperCapabilities(){ return true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java index 39b1e38b4..640885e50 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java @@ -122,6 +122,11 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{ return this.isBoundThingInRange() && (this.getSided() == null || this.getSided().canExtractItem(slot, stack, side)); } + @Override + public boolean hasCapability(@Nonnull Capability capability, @Nonnull EnumFacing facing){ + return this.isBoundThingInRange() ? this.worldObj.getTileEntity(this.boundPosition).hasCapability(capability, facing) : super.hasCapability(capability, facing); + } + @Nonnull @Override public T getCapability(@Nonnull Capability capability, @Nonnull EnumFacing facing){