use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftInventory in project PublicCrafters by BananaPuncher714.
the class ContainerManager_v1_8_R3 method getLocation.
public Location getLocation(Inventory inventory) {
if (inventory == null) {
return null;
}
if (!(inventory instanceof CraftInventory)) {
return null;
}
try {
Field ic = CraftInventory.class.getDeclaredField("inventory");
ic.setAccessible(true);
Object crafting = ic.get(inventory);
if (crafting instanceof CustomInventoryCrafting) {
CustomInventoryCrafting table = (CustomInventoryCrafting) crafting;
return table.getLocation();
}
} catch (Exception exception) {
exception.printStackTrace();
}
return null;
}
use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftInventory in project PublicCrafters by BananaPuncher714.
the class ContainerManager_v1_18_R2 method getLocation.
public Location getLocation(Inventory inventory) {
if (inventory == null) {
return null;
}
if (!(inventory instanceof CraftInventory)) {
return null;
}
try {
Field ic = CraftInventory.class.getDeclaredField("inventory");
ic.setAccessible(true);
Object crafting = ic.get(inventory);
if (crafting instanceof CustomInventoryCrafting) {
CustomInventoryCrafting table = (CustomInventoryCrafting) crafting;
return table.getLocation();
}
} catch (Exception exception) {
exception.printStackTrace();
}
return null;
}
use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftInventory in project PublicCrafters by BananaPuncher714.
the class ContainerManager_v1_9_R2 method getLocation.
public Location getLocation(Inventory inventory) {
if (inventory == null) {
return null;
}
if (!(inventory instanceof CraftInventory)) {
return null;
}
try {
Field ic = CraftInventory.class.getDeclaredField("inventory");
ic.setAccessible(true);
Object crafting = ic.get(inventory);
if (crafting instanceof CustomInventoryCrafting) {
CustomInventoryCrafting table = (CustomInventoryCrafting) crafting;
return table.getLocation();
}
} catch (Exception exception) {
exception.printStackTrace();
}
return null;
}
use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftInventory in project Mohist by MohistMC.
the class CraftChest method getInventory.
@Override
public Inventory getInventory() {
CraftInventory inventory = (CraftInventory) this.getBlockInventory();
if (!isPlaced() || isWorldGeneration()) {
return inventory;
}
// The logic here is basically identical to the logic in ChestBlock.interact
CraftWorld world = (CraftWorld) this.getWorld();
ChestBlock blockChest = (ChestBlock) (this.getType() == Material.CHEST ? Blocks.CHEST : Blocks.TRAPPED_CHEST);
MenuProvider nms = blockChest.getMenuProvider(data, world.getHandle(), this.getPosition(), true);
if (nms instanceof ChestBlock.DoubleInventory) {
inventory = new CraftInventoryDoubleChest((ChestBlock.DoubleInventory) nms);
}
return inventory;
}
use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftInventory 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