Search in sources :

Example 21 with CraftInventory

use of org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory in project Denizen-For-Bukkit by DenizenScript.

the class ImprovedOfflinePlayer_v1_10_R1 method getEnderChest.

@Override
public Inventory getEnderChest() {
    if (offlineEnderChests.containsKey(getUniqueId())) {
        return offlineEnderChests.get(getUniqueId());
    }
    InventoryEnderChest endchest = new InventoryEnderChest();
    endchest.a(((CompoundTag_v1_10_R1) this.compound).toNMSTag().getList("EnderItems", 10));
    org.bukkit.inventory.Inventory inv = new CraftInventory(endchest);
    offlineEnderChests.put(getUniqueId(), inv);
    return inv;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_10_R1.inventory.CraftInventory) CompoundTag_v1_10_R1(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_10_R1) Inventory(org.bukkit.inventory.Inventory)

Example 22 with CraftInventory

use of org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory in project solinia3-core by mixxit.

the class PatchUtils method listToInventory.

public Inventory listToInventory(NBTTagList nbttaglist) {
    TileEntityChest tileentitychest = new TileEntityChest();
    for (int i = 0; i < nbttaglist.size(); i++) {
        NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.get(i);
        int j = nbttagcompound.getByte("Slot") & 0xFF;
        if (j >= 0 && j < 27) {
            tileentitychest.setItem(j, net.minecraft.server.v1_15_R1.ItemStack.a(nbttagcompound));
        }
    }
    return new CraftInventory(tileentitychest);
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventory) TileEntityChest(net.minecraft.server.v1_15_R1.TileEntityChest) NBTTagCompound(net.minecraft.server.v1_15_R1.NBTTagCompound)

Example 23 with CraftInventory

use of org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory in project Denizen by DenizenScript.

the class ImprovedOfflinePlayerImpl method getEnderChest.

@Override
public Inventory getEnderChest() {
    if (offlineEnderChests.containsKey(getUniqueId())) {
        return offlineEnderChests.get(getUniqueId());
    }
    PlayerEnderChestContainer endchest = new PlayerEnderChestContainer(null);
    endchest.fromTag(((CompoundTagImpl) this.compound).toNMSTag().getList("EnderItems", 10));
    org.bukkit.inventory.Inventory inv = new CraftInventory(endchest);
    offlineEnderChests.put(getUniqueId(), inv);
    return inv;
}
Also used : PlayerEnderChestContainer(net.minecraft.world.inventory.PlayerEnderChestContainer) CraftInventory(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventory) Inventory(org.bukkit.inventory.Inventory) CompoundTagImpl(com.denizenscript.denizen.nms.v1_17.impl.jnbt.CompoundTagImpl)

Example 24 with CraftInventory

use of org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory in project Denizen by DenizenScript.

the class ImprovedOfflinePlayerImpl method getEnderChest.

@Override
public Inventory getEnderChest() {
    if (offlineEnderChests.containsKey(getUniqueId())) {
        return offlineEnderChests.get(getUniqueId());
    }
    PlayerEnderChestContainer endchest = new PlayerEnderChestContainer(null);
    endchest.fromTag(((CompoundTagImpl) this.compound).toNMSTag().getList("EnderItems", 10));
    org.bukkit.inventory.Inventory inv = new CraftInventory(endchest);
    offlineEnderChests.put(getUniqueId(), inv);
    return inv;
}
Also used : PlayerEnderChestContainer(net.minecraft.world.inventory.PlayerEnderChestContainer) CraftInventory(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory) Inventory(org.bukkit.inventory.Inventory) CompoundTagImpl(com.denizenscript.denizen.nms.v1_18.impl.jnbt.CompoundTagImpl)

Example 25 with CraftInventory

use of org.bukkit.craftbukkit.v1_18_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();
}
Also used : IInventory(net.minecraft.inventory.IInventory) TileEntityHopper(net.minecraft.tileentity.TileEntityHopper) CraftInventory(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory) TileEntityBeacon(net.minecraft.tileentity.TileEntityBeacon) InventoryWrapper(org.bukkit.craftbukkit.v1_12_R1.inventory.InventoryWrapper) TileEntityDropper(net.minecraft.tileentity.TileEntityDropper) InventoryType(org.bukkit.event.inventory.InventoryType) BlockAnvil(net.minecraft.block.BlockAnvil) TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace) TileEntityDispenser(net.minecraft.tileentity.TileEntityDispenser) BlockAnvil(net.minecraft.block.BlockAnvil) TileEntityShulkerBox(net.minecraft.tileentity.TileEntityShulkerBox) EntityMinecartHopper(net.minecraft.entity.item.EntityMinecartHopper) CraftContainer(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftContainer) Container(net.minecraft.inventory.Container) TileEntityBrewingStand(net.minecraft.tileentity.TileEntityBrewingStand) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Aggregations

Field (java.lang.reflect.Field)16 Inventory (org.bukkit.inventory.Inventory)10 CraftInventory (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventory)9 CraftInventory (org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory)5 PlayerEnderChestContainer (net.minecraft.world.inventory.PlayerEnderChestContainer)4 CraftInventory (org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventory)4 IInventory (net.minecraft.inventory.IInventory)3 INamedContainerProvider (net.minecraft.inventory.container.INamedContainerProvider)3 CraftInventory (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory)3 CraftInventoryDoubleChest (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventoryDoubleChest)3 CompoundTagImpl (com.denizenscript.denizen.nms.v1_16.impl.jnbt.CompoundTagImpl)2 CompoundTagImpl (com.denizenscript.denizen.nms.v1_17.impl.jnbt.CompoundTagImpl)2 CompoundTagImpl (com.denizenscript.denizen.nms.v1_18.impl.jnbt.CompoundTagImpl)2 ChestBlock (net.minecraft.block.ChestBlock)2 MenuProvider (net.minecraft.world.MenuProvider)2 CraftInventory (org.bukkit.craftbukkit.v1_10_R1.inventory.CraftInventory)2 CraftInventory (org.bukkit.craftbukkit.v1_11_R1.inventory.CraftInventory)2 CraftInventory (org.bukkit.craftbukkit.v1_15_R1.inventory.CraftInventory)2 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)2 CraftInventory (org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventory)2