use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftInventory in project Magma-1.16.x by magmafoundation.
the class CraftLootTable method fillInventory.
@Override
public void fillInventory(Inventory inventory, Random random, LootContext context) {
net.minecraft.loot.LootContext nmsContext = convertContext(context);
CraftInventory craftInventory = (CraftInventory) inventory;
IInventory handle = craftInventory.getInventory();
// TODO: When events are added, call event here w/ custom reason?
getHandle().fill(handle, nmsContext);
}
use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftInventory in project Magma-1.16.x by magmafoundation.
the class CraftChest method getInventory.
@Override
public Inventory getInventory() {
CraftInventory inventory = (CraftInventory) this.getBlockInventory();
if (!isPlaced()) {
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);
INamedContainerProvider nms = blockChest.getMenuProvider(data, world.getHandle(), this.getPosition());
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 LoliServer by Loli-Server.
the class CraftChest method getInventory.
@Override
public Inventory getInventory() {
CraftInventory inventory = (CraftInventory) this.getBlockInventory();
if (!isPlaced()) {
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);
INamedContainerProvider nms = blockChest.getMenuProvider(data, world.getHandle(), this.getPosition());
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 Magma by magmafoundation.
the class CraftHumanEntity method openInventory.
public InventoryView openInventory(Inventory inventory) {
if (!(getHandle() instanceof EntityPlayerMP))
return null;
EntityPlayerMP player = (EntityPlayerMP) getHandle();
InventoryType type = inventory.getType();
Container formerContainer = getHandle().openContainer;
IInventory iinventory = (inventory instanceof CraftInventory) ? ((CraftInventory) inventory).getInventory() : new InventoryWrapper(inventory);
switch(type) {
case PLAYER:
case CHEST:
case ENDER_CHEST:
getHandle().displayGUIChest(iinventory);
break;
case DISPENSER:
if (iinventory instanceof TileEntityDispenser) {
getHandle().displayGUIChest((TileEntityDispenser) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:dispenser");
}
break;
case DROPPER:
if (iinventory instanceof TileEntityDropper) {
getHandle().displayGUIChest((TileEntityDropper) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:dropper");
}
break;
case FURNACE:
if (iinventory instanceof TileEntityFurnace) {
getHandle().displayGUIChest((TileEntityFurnace) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:furnace");
}
break;
case WORKBENCH:
openCustomInventory(inventory, player, "minecraft:crafting_table");
break;
case BREWING:
if (iinventory instanceof TileEntityBrewingStand) {
getHandle().displayGUIChest((TileEntityBrewingStand) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:brewing_stand");
}
break;
case ENCHANTING:
openCustomInventory(inventory, player, "minecraft:enchanting_table");
break;
case HOPPER:
if (iinventory instanceof TileEntityHopper) {
getHandle().displayGUIChest((TileEntityHopper) iinventory);
} else if (iinventory instanceof EntityMinecartHopper) {
getHandle().displayGUIChest((EntityMinecartHopper) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:hopper");
}
break;
case BEACON:
if (iinventory instanceof TileEntityBeacon) {
getHandle().displayGUIChest((TileEntityBeacon) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:beacon");
}
break;
case ANVIL:
if (iinventory instanceof BlockAnvil.Anvil) {
getHandle().displayGui((BlockAnvil.Anvil) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:anvil");
}
break;
case SHULKER_BOX:
if (iinventory instanceof TileEntityShulkerBox) {
getHandle().displayGUIChest((TileEntityShulkerBox) iinventory);
} else {
openCustomInventory(inventory, player, "minecraft:shulker_box");
}
break;
case CREATIVE:
case CRAFTING:
throw new IllegalArgumentException("Can't open a " + type + " inventory!");
}
if (getHandle().openContainer == formerContainer) {
return null;
}
getHandle().openContainer.checkReachable = false;
return getHandle().openContainer.getBukkitView();
}
use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftInventory in project PublicCrafters by BananaPuncher714.
the class ContainerManager_v1_13_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;
}
Aggregations