Search in sources :

Example 31 with CraftInventory

use of org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory in project PublicCrafters by BananaPuncher714.

the class ContainerManager_v1_18_R1 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;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventory) Field(java.lang.reflect.Field)

Example 32 with CraftInventory

use of org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory in project PublicCrafters by BananaPuncher714.

the class ContainerManager_v1_17_1 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;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventory) Field(java.lang.reflect.Field)

Example 33 with CraftInventory

use of org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory in project PublicCrafters by BananaPuncher714.

the class ContainerManager_v1_17_R1 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;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventory) Field(java.lang.reflect.Field)

Example 34 with CraftInventory

use of org.bukkit.craftbukkit.v1_18_R2.inventory.CraftInventory in project PublicCrafters by BananaPuncher714.

the class ContainerManager_v1_11_R1 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;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_11_R1.inventory.CraftInventory) Field(java.lang.reflect.Field)

Example 35 with CraftInventory

use of org.bukkit.craftbukkit.v1_18_R2.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)

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