Search in sources :

Example 6 with EntityHuman

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

the class NMSAdapter_v1_16_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_16_R3.EntityHuman) CraftHumanEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftHumanEntity) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_16_R3.ItemStack)

Example 7 with EntityHuman

use of net.minecraft.server.v1_13_R2.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 8 with EntityHuman

use of net.minecraft.server.v1_13_R2.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 9 with EntityHuman

use of net.minecraft.server.v1_13_R2.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 10 with EntityHuman

use of net.minecraft.server.v1_13_R2.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

LivingEntity (org.bukkit.entity.LivingEntity)15 EntityHuman (net.minecraft.server.v1_11_R1.EntityHuman)7 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 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)5 EntityHuman (net.minecraft.server.v1_15_R1.EntityHuman)5 EntityHuman (net.minecraft.server.v1_10_R1.EntityHuman)4 EntityHuman (net.minecraft.server.v1_13_R2.EntityHuman)4 Entity (net.minecraft.server.v1_11_R1.Entity)3 EntityLiving (net.minecraft.server.v1_11_R1.EntityLiving)3 EntityLiving (net.minecraft.server.v1_12_R1.EntityLiving)3 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)2 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)2 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)2 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)2 Entity (net.minecraft.server.v1_12_R1.Entity)2 EntityLiving (net.minecraft.server.v1_13_R2.EntityLiving)2 EntityLiving (net.minecraft.server.v1_15_R1.EntityLiving)2 EntityHuman (net.minecraft.server.v1_16_R3.EntityHuman)2