Search in sources :

Example 16 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_8_R3 method dropItemAsPlayer.

@Override
public void dropItemAsPlayer(HumanEntity humanEntity, org.bukkit.inventory.ItemStack bukkitItem) {
    EntityHuman entityHuman = ((CraftHumanEntity) humanEntity).getHandle();
    ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
    entityHuman.drop(itemStack, false);
}
Also used : EntityHuman(net.minecraft.server.v1_8_R3.EntityHuman) CraftHumanEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity) ItemStack(net.minecraft.server.v1_8_R3.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)

Example 17 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_12_R1 method dropItemAsPlayer.

@Override
public void dropItemAsPlayer(HumanEntity humanEntity, org.bukkit.inventory.ItemStack bukkitItem) {
    EntityHuman entityHuman = ((CraftHumanEntity) humanEntity).getHandle();
    ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
    entityHuman.drop(itemStack, false);
}
Also used : EntityHuman(net.minecraft.server.v1_12_R1.EntityHuman) CraftHumanEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftHumanEntity) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 18 with EntityHuman

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

the class CustomContainerAnvil method e.

public void e() {
    EntityHuman player = ((CraftHumanEntity) this.player).getHandle();
    ItemStack itemstack = subcontainer.getItem(0);
    this.a = 1;
    int i = 0;
    byte b0 = 0;
    byte b1 = 0;
    if (itemstack.isEmpty()) {
        CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a);
        this.a = 0;
    } else {
        ItemStack itemstack1 = itemstack.cloneItemStack();
        if ((itemstack1.getCount() > 1) && (!player.abilities.canInstantlyBuild) && (!(itemstack1.getItem() instanceof ItemNameTag))) {
            itemstack1.setCount(1);
        }
        ItemStack itemstack2 = subcontainer.getItem(1);
        Map map = EnchantmentManager.a(itemstack1);
        int j = b0 + itemstack.getRepairCost() + (itemstack2.isEmpty() ? 0 : itemstack2.getRepairCost());
        xpCost = 0;
        if (!itemstack2.isEmpty()) {
            boolean flag = (itemstack2.getItem() == Items.ENCHANTED_BOOK) && (!Items.ENCHANTED_BOOK.h(itemstack2).isEmpty());
            if ((itemstack1.f()) && (itemstack1.getItem().a(itemstack, itemstack2))) {
                int k = Math.min(itemstack1.i(), itemstack1.k() / 4);
                if (k <= 0) {
                    CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a);
                    this.a = 0;
                    return;
                }
                for (int l = 0; (k > 0) && (l < itemstack2.getCount()); l++) {
                    int i1 = itemstack1.i() - k;
                    itemstack1.setData(i1);
                    i++;
                    k = Math.min(itemstack1.i(), itemstack1.k() / 4);
                    xpCost = l;
                }
            } else {
                if ((!flag) && ((itemstack1.getItem() != itemstack2.getItem()) || (!itemstack1.f()))) {
                    CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a);
                    this.a = 0;
                    return;
                }
                if ((itemstack1.f()) && (!flag)) {
                    int k = itemstack.k() - itemstack.i();
                    int l = itemstack2.k() - itemstack2.i();
                    int i1 = l + itemstack1.k() * 12 / 100;
                    int j1 = k + i1;
                    int k1 = itemstack1.k() - j1;
                    if (k1 < 0) {
                        k1 = 0;
                    }
                    if (k1 < itemstack1.getData()) {
                        itemstack1.setData(k1);
                        i += 2;
                    }
                }
                Map<Enchantment, Integer> map1 = EnchantmentManager.a(itemstack2);
                boolean flag1 = false;
                boolean flag2 = false;
                Iterator iterator = map1.keySet().iterator();
                while (iterator.hasNext()) {
                    Enchantment enchantment = (Enchantment) iterator.next();
                    if (enchantment != null) {
                        int l1 = map.containsKey(enchantment) ? ((Integer) map.get(enchantment)).intValue() : 0;
                        int i2 = ((Integer) map1.get(enchantment)).intValue();
                        i2 = l1 == i2 ? i2 + 1 : Math.max(i2, l1);
                        boolean flag3 = enchantment.canEnchant(itemstack);
                        if ((player.abilities.canInstantlyBuild) || (itemstack.getItem() == Items.ENCHANTED_BOOK)) {
                            flag3 = true;
                        }
                        Iterator iterator1 = map.keySet().iterator();
                        while (iterator1.hasNext()) {
                            Enchantment enchantment1 = (Enchantment) iterator1.next();
                            if ((enchantment1 != enchantment) && (!enchantment.c(enchantment1))) {
                                flag3 = false;
                                i++;
                            }
                        }
                        if (!flag3) {
                            flag2 = true;
                        } else {
                            flag1 = true;
                            if (i2 > enchantment.getMaxLevel()) {
                                i2 = enchantment.getMaxLevel();
                            }
                            map.put(enchantment, Integer.valueOf(i2));
                            int j2 = 0;
                            switch(enchantment.e()) {
                                case COMMON:
                                    j2 = 1;
                                    break;
                                case RARE:
                                    j2 = 2;
                                    break;
                                case UNCOMMON:
                                    j2 = 4;
                                    break;
                                case VERY_RARE:
                                    j2 = 8;
                            }
                            if (flag) {
                                j2 = Math.max(1, j2 / 2);
                            }
                            i += j2 * i2;
                        }
                    }
                }
                if ((flag2) && (!flag1)) {
                    CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), ItemStack.a);
                    this.a = 0;
                    return;
                }
            }
        }
        if (StringUtils.isBlank(this.l)) {
            if (itemstack.hasName()) {
                b1 = 1;
                i += b1;
                itemstack1.s();
            }
        } else if (!this.l.equals(itemstack.getName())) {
            b1 = 1;
            i += b1;
            itemstack1.g(this.l);
        }
        this.a = (j + i);
        if (i <= 0) {
            itemstack1 = ItemStack.a;
        }
        if ((b1 == i) && (b1 > 0) && (this.a >= 40)) {
            this.a = 39;
        }
        if ((this.a >= 40) && (!player.abilities.canInstantlyBuild)) {
            itemstack1 = ItemStack.a;
        }
        if (!itemstack1.isEmpty()) {
            int k2 = itemstack1.getRepairCost();
            if ((!itemstack2.isEmpty()) && (k2 < itemstack2.getRepairCost())) {
                k2 = itemstack2.getRepairCost();
            }
            if ((b1 != i) || (b1 == 0)) {
                k2 = k2 * 2 + 1;
            }
            itemstack1.setRepairCost(k2);
            EnchantmentManager.a(map, itemstack1);
        }
        CraftEventFactory.callPrepareAnvilEvent(getBukkitView(), itemstack1);
        b();
    }
}
Also used : EntityHuman(net.minecraft.server.v1_11_R1.EntityHuman) ItemNameTag(net.minecraft.server.v1_11_R1.ItemNameTag) CraftHumanEntity(org.bukkit.craftbukkit.v1_11_R1.entity.CraftHumanEntity) Iterator(java.util.Iterator) ItemStack(net.minecraft.server.v1_11_R1.ItemStack) Enchantment(net.minecraft.server.v1_11_R1.Enchantment) Map(java.util.Map)

Example 19 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman 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_R3.Slot) ItemStack(net.minecraft.server.v1_16_R3.ItemStack)

Example 20 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project Citizens2 by CitizensDev.

the class NMSImpl method setHeadYaw.

@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
    if (!(entity instanceof LivingEntity))
        return;
    EntityLiving handle = (EntityLiving) getHandle(entity);
    yaw = Util.clampYaw(yaw);
    handle.aP = yaw;
    if (!(handle instanceof EntityHuman))
        handle.aO = yaw;
    handle.aQ = yaw;
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) EntityHuman(net.minecraft.server.v1_10_R1.EntityHuman) EntityLiving(net.minecraft.server.v1_10_R1.EntityLiving)

Aggregations

net.minecraft.server.v1_16_R3 (net.minecraft.server.v1_16_R3)20 CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)19 MyPetApi (de.Keyle.MyPet.MyPetApi)18 EntitySize (de.Keyle.MyPet.api.entity.EntitySize)18 MyPet (de.Keyle.MyPet.api.entity.MyPet)18 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet)18 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 Pair (com.mojang.datafixers.util.Pair)17 Util (de.Keyle.MyPet.api.Util)17 EquipmentSlot (de.Keyle.MyPet.api.entity.EquipmentSlot)17 Arrays (java.util.Arrays)17 Bukkit (org.bukkit.Bukkit)17 ENTITY_LIVING_broadcastItemBreak (de.Keyle.MyPet.compat.v1_16_R3.CompatManager.ENTITY_LIVING_broadcastItemBreak)15 LivingEntity (org.bukkit.entity.LivingEntity)15 Configuration (de.Keyle.MyPet.api.Configuration)10 EntityHuman (net.minecraft.server.v1_11_R1.EntityHuman)7 PetState (de.Keyle.MyPet.api.entity.MyPet.PetState)6 EntityHuman (net.minecraft.server.v1_12_R1.EntityHuman)6 EntityHuman (net.minecraft.server.v1_8_R3.EntityHuman)6 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)5