Skip to content

Commit

Permalink
Fix crafting stations exposing inventory that should not be exposed a…
Browse files Browse the repository at this point in the history
…s they are not modifiable. (#4304)
  • Loading branch information
alexbegt committed Apr 4, 2021
1 parent 7ca802a commit 65fd2dd
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import org.apache.commons.lang3.tuple.Pair;
import slimeknights.tconstruct.common.config.Config;
import slimeknights.tconstruct.smeltery.tileentity.CastingTileEntity;
Expand Down Expand Up @@ -133,8 +134,15 @@ private static boolean isUsable(TileEntity tileEntity, PlayerEntity player) {
return !(tileEntity instanceof IInventory) || ((IInventory)tileEntity).isUsableByPlayer(player);
}

private static boolean hasItemHandler(TileEntity te, @Nullable Direction direction) {
return te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction).isPresent();
/**
* Checks to see if the given Tile Entity has an item handler that's compatible with the side inventory
* The Tile Entity's item handler must be an instance of IItemHandlerModifiable
* @param tileEntity Tile to check
* @param direction the given direction
* @return True if compatible.
*/
private static boolean hasItemHandler(TileEntity tileEntity, @Nullable Direction direction) {
return tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction).filter(cap -> cap instanceof IItemHandlerModifiable).isPresent();
}

@Override
Expand Down

0 comments on commit 65fd2dd

Please sign in to comment.