Made hasCapability not call getCapability.

Supposedly closes #97
This commit is contained in:
Ellpeck 2016-05-29 23:39:50 +02:00
parent af67fb87cc
commit 79660f3f6f
2 changed files with 11 additions and 2 deletions

View file

@ -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> T getCapability(@Nonnull Capability<T> 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;
}

View file

@ -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> T getCapability(@Nonnull Capability<T> capability, @Nonnull EnumFacing facing){