Search in sources :

Example 36 with Slot

use of net.minecraft.server.v1_16_R3.Slot in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method shiftClick.

// Overrides 1.15.1
@Override
public ItemStack shiftClick(EntityHuman entityhuman, int i) {
    ItemStack itemstack = ItemStack.b;
    Slot slot = (Slot) this.slots.get(i);
    if (slot != null && slot.hasItem()) {
        ItemStack itemstack1 = slot.getItem();
        itemstack = itemstack1.cloneItemStack();
        if (i == 0) {
            this.containerAccess.a((world, blockposition) -> {
                itemstack1.getItem().b(itemstack1, world, entityhuman);
            });
            if (!this.a(itemstack1, 10, 46, true)) {
                return ItemStack.b;
            }
            slot.a(itemstack1, itemstack);
        } else if (i >= 10 && i < 46 ? !this.a(itemstack1, 1, 10, false) && (i < 37 ? !this.a(itemstack1, 37, 46, false) : !this.a(itemstack1, 10, 37, false)) : !this.a(itemstack1, 10, 46, false)) {
            return ItemStack.b;
        }
        if (itemstack1.isEmpty()) {
            slot.set(ItemStack.b);
        } else {
            slot.d();
        }
        if (itemstack1.getCount() == itemstack.getCount()) {
            return ItemStack.b;
        }
        ItemStack itemstack2 = slot.a(entityhuman, itemstack1);
        if (i == 0) {
            entityhuman.drop(itemstack2, false);
        }
    }
    return itemstack;
}
Also used : Slot(net.minecraft.server.v1_16_R2.Slot) ItemStack(net.minecraft.server.v1_16_R2.ItemStack)

Example 37 with Slot

use of net.minecraft.server.v1_16_R3.Slot in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method b.

/**
 * The shift clicking method
 */
@Override
public ItemStack b(EntityHuman entityhuman, int i) {
    ItemStack itemstack = ItemStack.a;
    Slot slot = (Slot) this.c.get(i);
    if ((slot != null) && (slot.hasItem())) {
        ItemStack itemstack1 = slot.getItem();
        itemstack = itemstack1.cloneItemStack();
        if (i == 0) {
            itemstack1.getItem().b(itemstack1, world, entityhuman);
            if (!a(itemstack1, 10, 46, true)) {
                return ItemStack.a;
            }
            slot.a(itemstack1, itemstack);
        } else if ((i >= 10) && (i < 37)) {
            if (!a(itemstack1, 37, 46, false)) {
                return ItemStack.a;
            }
        } else if ((i >= 37) && (i < 46)) {
            if (!a(itemstack1, 10, 37, false)) {
                return ItemStack.a;
            }
        } else if (!a(itemstack1, 10, 46, false)) {
            return ItemStack.a;
        }
        if (itemstack1.isEmpty()) {
            slot.set(ItemStack.a);
        } else {
            slot.f();
        }
        if (itemstack1.getCount() == itemstack.getCount()) {
            return ItemStack.a;
        }
        ItemStack itemstack2 = slot.a(entityhuman, itemstack1);
        if (i == 0) {
            entityhuman.drop(itemstack2, false);
        }
    }
    return itemstack;
}
Also used : Slot(net.minecraft.server.v1_11_R1.Slot) PacketPlayOutSetSlot(net.minecraft.server.v1_11_R1.PacketPlayOutSetSlot) ItemStack(net.minecraft.server.v1_11_R1.ItemStack)

Example 38 with Slot

use of net.minecraft.server.v1_16_R3.Slot in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method b.

/**
 * The shift clicking method
 */
@Override
public ItemStack b(EntityHuman entityhuman, int i) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.c.get(i);
    if ((slot != null) && (slot.hasItem())) {
        ItemStack itemstack1 = slot.getItem();
        itemstack = itemstack1.cloneItemStack();
        if (i == 0) {
            itemstack1.getItem().b(itemstack1, world, entityhuman);
            if (!a(itemstack1, 10, 46, true)) {
                return null;
            }
            slot.a(itemstack1, itemstack);
        } else if ((i >= 10) && (i < 37)) {
            if (!a(itemstack1, 37, 46, false)) {
                return null;
            }
        } else if ((i >= 37) && (i < 46)) {
            if (!a(itemstack1, 10, 37, false)) {
                return null;
            }
        } else if (!a(itemstack1, 10, 46, false)) {
            return null;
        }
        slot.f();
        if (itemstack1.count == itemstack.count) {
            return null;
        }
        slot.a(entityhuman, itemstack1);
        if (i == 0) {
            entityhuman.drop(itemstack1, false);
        }
    }
    return itemstack;
}
Also used : Slot(net.minecraft.server.v1_10_R1.Slot) PacketPlayOutSetSlot(net.minecraft.server.v1_10_R1.PacketPlayOutSetSlot) ItemStack(net.minecraft.server.v1_10_R1.ItemStack)

Example 39 with Slot

use of net.minecraft.server.v1_16_R3.Slot in project PublicCrafters by BananaPuncher714.

the class CustomContainerAnvil method b.

// Shift click
public ItemStack b(EntityHuman entityhuman, int i) {
    ItemStack itemstack = ItemStack.a;
    Slot slot = (Slot) this.c.get(i);
    if ((slot != null) && (slot.hasItem())) {
        ItemStack itemstack1 = slot.getItem();
        itemstack = itemstack1.cloneItemStack();
        if (i == 2) {
            if (!a(itemstack1, 3, 39, true)) {
                return ItemStack.a;
            }
            slot.a(itemstack1, itemstack);
        } else if ((i != 0) && (i != 1)) {
            if ((i >= 3) && (i < 39) && (!a(itemstack1, 0, 2, false))) {
                return ItemStack.a;
            }
        } else if (!a(itemstack1, 3, 39, false)) {
            return ItemStack.a;
        }
        if (itemstack1.isEmpty()) {
            slot.set(ItemStack.a);
        } else {
            slot.f();
        }
        if (itemstack1.getCount() == itemstack.getCount()) {
            return ItemStack.a;
        }
        slot.a(entityhuman, itemstack1);
    }
    return itemstack;
}
Also used : Slot(net.minecraft.server.v1_11_R1.Slot) ItemStack(net.minecraft.server.v1_11_R1.ItemStack)

Example 40 with Slot

use of net.minecraft.server.v1_16_R3.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_16_R3.Container) NbtTagCompound(com.ruinscraft.panilla.craftbukkit.v1_16_R3.nbt.NbtTagCompound) INbtTagCompound(com.ruinscraft.panilla.api.nbt.INbtTagCompound) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) INbtTagCompound(com.ruinscraft.panilla.api.nbt.INbtTagCompound) ItemStack(net.minecraft.server.v1_16_R3.ItemStack) FailedNbt(com.ruinscraft.panilla.api.exception.FailedNbt)

Aggregations

CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)19 Pair (com.mojang.datafixers.util.Pair)18 MyPetApi (de.Keyle.MyPet.MyPetApi)17 Util (de.Keyle.MyPet.api.Util)17 EntitySize (de.Keyle.MyPet.api.entity.EntitySize)17 EquipmentSlot (de.Keyle.MyPet.api.entity.EquipmentSlot)17 MyPet (de.Keyle.MyPet.api.entity.MyPet)17 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet)17 InvocationTargetException (java.lang.reflect.InvocationTargetException)17 Arrays (java.util.Arrays)17 net.minecraft.server.v1_16_R3 (net.minecraft.server.v1_16_R3)17 Bukkit (org.bukkit.Bukkit)17 ENTITY_LIVING_broadcastItemBreak (de.Keyle.MyPet.compat.v1_16_R3.CompatManager.ENTITY_LIVING_broadcastItemBreak)14 Configuration (de.Keyle.MyPet.api.Configuration)9 PetState (de.Keyle.MyPet.api.entity.MyPet.PetState)6 CompatManager (de.Keyle.MyPet.compat.v1_16_R3.CompatManager)3 ItemStack (net.minecraft.server.v1_16_R3.ItemStack)3 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)3 FailedNbt (com.ruinscraft.panilla.api.exception.FailedNbt)2 INbtTagCompound (com.ruinscraft.panilla.api.nbt.INbtTagCompound)2