Search in sources :

Example 21 with Slot

use of net.minecraft.server.v1_15_R1.Slot in project Panilla by ds58.

the class InventoryCleaner method clean.

@Override
public void clean(IPanillaPlayer player) {
    CraftPlayer craftPlayer = (CraftPlayer) player.getHandle();
    Container container = craftPlayer.getHandle().activeContainer;
    for (int slot = 0; slot < container.slots.size(); slot++) {
        ItemStack itemStack = container.getSlot(slot).getItem();
        if (itemStack == null || !itemStack.hasTag()) {
            continue;
        }
        NBTTagCompound nmsTag = itemStack.getTag();
        INbtTagCompound tag = new NbtTagCompound(nmsTag);
        String itemName = itemStack.getItem().getName();
        if (nmsTag == null || itemName == null) {
            continue;
        }
        FailedNbt failedNbt = NbtChecks.checkAll(tag, itemName, panilla);
        if (FailedNbt.failsThreshold(failedNbt)) {
            container.getSlot(slot).getItem().setTag(null);
        } else if (FailedNbt.fails(failedNbt)) {
            nmsTag.remove(failedNbt.key);
            container.getSlot(slot).getItem().setTag(nmsTag);
        }
    }
}
Also used : Container(net.minecraft.server.v1_15_R1.Container) NbtTagCompound(com.ruinscraft.panilla.craftbukkit.v1_15_R1.nbt.NbtTagCompound) INbtTagCompound(com.ruinscraft.panilla.api.nbt.INbtTagCompound) NBTTagCompound(net.minecraft.server.v1_15_R1.NBTTagCompound) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) INbtTagCompound(com.ruinscraft.panilla.api.nbt.INbtTagCompound) ItemStack(net.minecraft.server.v1_15_R1.ItemStack) FailedNbt(com.ruinscraft.panilla.api.exception.FailedNbt)

Example 22 with Slot

use of net.minecraft.server.v1_15_R1.Slot in project PaperDev by Kamillaova.

the class CraftContainer method setupWorkbench.

private void setupWorkbench(IInventory top, IInventory bottom) {
    // This code copied from ContainerWorkbench
    this.a(new Slot(top, 0, 124, 35));
    int row;
    int col;
    for (row = 0; row < 3; ++row) {
        for (col = 0; col < 3; ++col) {
            this.a(new Slot(top, 1 + col + row * 3, 30 + col * 18, 17 + row * 18));
        }
    }
    for (row = 0; row < 3; ++row) {
        for (col = 0; col < 9; ++col) {
            this.a(new Slot(bottom, col + row * 9 + 9, 8 + col * 18, 84 + row * 18));
        }
    }
    for (col = 0; col < 9; ++col) {
        this.a(new Slot(bottom, col, 8 + col * 18, 142));
    }
// End copy from ContainerWorkbench
}
Also used : Slot(net.minecraft.server.v1_12_R1.Slot)

Aggregations

Slot (net.minecraft.server.v1_12_R1.Slot)3 ItemStack (net.minecraft.server.v1_15_R1.ItemStack)3 NBTTagCompound (net.minecraft.server.v1_15_R1.NBTTagCompound)3 FailedNbt (com.ruinscraft.panilla.api.exception.FailedNbt)2 INbtTagCompound (com.ruinscraft.panilla.api.nbt.INbtTagCompound)2 HardwareTokenType (ee.ria.xroad.signer.tokenmanager.token.HardwareTokenType)2 Slot (iaik.pkcs.pkcs11.Slot)2 ArrayList (java.util.ArrayList)2 ItemStack (net.minecraft.server.v1_11_R1.ItemStack)2 Slot (net.minecraft.server.v1_11_R1.Slot)2 ItemStack (net.minecraft.server.v1_12_R1.ItemStack)2 CraftItemStack (org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack)2 ItemStack (org.bukkit.inventory.ItemStack)2 NbtTagCompound (com.ruinscraft.panilla.craftbukkit.v1_12_R1.nbt.NbtTagCompound)1 NbtTagCompound (com.ruinscraft.panilla.craftbukkit.v1_15_R1.nbt.NbtTagCompound)1 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)1 ISoliniaQuest (com.solinia.solinia.Interfaces.ISoliniaQuest)1 TokenType (ee.ria.xroad.signer.tokenmanager.token.TokenType)1 PKCS11Exception (iaik.pkcs.pkcs11.wrapper.PKCS11Exception)1 Field (java.lang.reflect.Field)1