use of org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryLectern in project Mohist by MohistMC.
the class CraftHumanEntity method openInventory.
@Override
public InventoryView openInventory(Inventory inventory) {
if (!(getHandle() instanceof ServerPlayer))
return null;
ServerPlayer player = (ServerPlayer) getHandle();
AbstractContainerMenu formerContainer = getHandle().containerMenu;
MenuProvider iinventory = null;
if (inventory instanceof CraftInventoryDoubleChest) {
iinventory = ((CraftInventoryDoubleChest) inventory).tile;
} else if (inventory instanceof CraftInventoryLectern) {
iinventory = ((CraftInventoryLectern) inventory).tile;
} else if (inventory instanceof CraftInventory) {
CraftInventory craft = (CraftInventory) inventory;
if (craft.getInventory() instanceof MenuProvider) {
iinventory = (MenuProvider) craft.getInventory();
}
}
if (iinventory instanceof MenuProvider) {
if (iinventory instanceof BlockEntity) {
BlockEntity te = (BlockEntity) iinventory;
if (!te.hasLevel()) {
te.setLevel(getHandle().level);
}
}
}
MenuType<?> container = CraftContainer.getNotchInventoryType(inventory);
if (iinventory instanceof MenuProvider) {
getHandle().openMenu(iinventory);
} else {
openCustomInventory(inventory, player, container);
}
if (getHandle().containerMenu == formerContainer) {
return null;
}
getHandle().containerMenu.checkReachable = false;
return getHandle().containerMenu.getBukkitView();
}
Aggregations