Search in sources :

Example 36 with CraftInventory

use of org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory in project Mohist by MohistMC.

the class CraftLootTable method fillInventory.

@Override
public void fillInventory(Inventory inventory, Random random, LootContext context) {
    net.minecraft.world.level.storage.loot.LootContext nmsContext = convertContext(context, random);
    CraftInventory craftInventory = (CraftInventory) inventory;
    Container handle = craftInventory.getInventory();
    // TODO: When events are added, call event here w/ custom reason?
    getHandle().fill(handle, nmsContext);
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory) Container(net.minecraft.world.Container)

Example 37 with CraftInventory

use of org.bukkit.craftbukkit.v1_12_R1.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);
}
Also used : IInventory(net.minecraft.inventory.IInventory) CraftInventory(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventory)

Example 38 with CraftInventory

use of org.bukkit.craftbukkit.v1_12_R1.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;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventory) INamedContainerProvider(net.minecraft.inventory.container.INamedContainerProvider) ChestBlock(net.minecraft.block.ChestBlock) CraftInventoryDoubleChest(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventoryDoubleChest) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 39 with CraftInventory

use of org.bukkit.craftbukkit.v1_12_R1.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;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventory) INamedContainerProvider(net.minecraft.inventory.container.INamedContainerProvider) ChestBlock(net.minecraft.block.ChestBlock) CraftInventoryDoubleChest(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventoryDoubleChest) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

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 IInventory (net.minecraft.inventory.IInventory)4 PlayerEnderChestContainer (net.minecraft.world.inventory.PlayerEnderChestContainer)4 INamedContainerProvider (net.minecraft.inventory.container.INamedContainerProvider)3 CraftInventory (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory)3 CraftInventory (org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventory)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 CraftInventoryDoubleChest (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventoryDoubleChest)2 CraftInventoryDoubleChest (org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventoryDoubleChest)2