use of net.minecraft.tileentity.LockableTileEntity in project Magma-1.16.x by magmafoundation.
the class CraftHumanEntity method openInventory.
@Override
public InventoryView openInventory(Inventory inventory) {
if (!(getHandle() instanceof ServerPlayerEntity))
return null;
ServerPlayerEntity player = (ServerPlayerEntity) getHandle();
Container formerContainer = getHandle().containerMenu;
INamedContainerProvider iinventory = null;
if (inventory instanceof CraftInventoryDoubleChest) {
iinventory = ((CraftInventoryDoubleChest) inventory).tile;
} else if (inventory instanceof CraftInventory) {
CraftInventory craft = (CraftInventory) inventory;
if (craft.getInventory() instanceof INamedContainerProvider) {
iinventory = (INamedContainerProvider) craft.getInventory();
}
}
if (iinventory instanceof INamedContainerProvider) {
if (iinventory instanceof TileEntity) {
TileEntity te = (TileEntity) iinventory;
if (!te.hasLevel()) {
te.setLevelAndPosition(getHandle().level, getHandle().blockPosition());
}
}
}
ContainerType<?> container = CraftContainer.getNotchInventoryType(inventory);
if (iinventory instanceof LockableTileEntity) {
getHandle().openMenu(iinventory);
} else {
openCustomInventory(inventory, player, container);
}
if (getHandle().containerMenu == formerContainer) {
return null;
}
getHandle().containerMenu.checkReachable = false;
return getHandle().containerMenu.getBukkitView();
}
Aggregations