Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the need for needsCustomInvWrapper #81

Open
wants to merge 1 commit into
base: 1.12
Choose a base branch
from
Open
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
17 changes: 9 additions & 8 deletions src/main/java/mcjty/lib/tileentity/GenericTileEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ public boolean receiveDataFromServer(String command, @Nonnull TypedMap result) {
}


@Deprecated
protected boolean needsCustomInvWrapper() {
return false;
}
Expand All @@ -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;
}
Expand All @@ -407,18 +408,18 @@ public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
@Override
public <T> T getCapability(Capability<T> 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);
Expand Down