Search in sources :

Example 56 with ItemStack

use of net.minecraft.server.v1_8_R1.ItemStack in project Essentials by EssentialsX.

the class v1_8_R1SpawnerProvider method getEntityType.

@Override
public EntityType getEntityType(ItemStack is) {
    net.minecraft.server.v1_8_R1.ItemStack itemStack;
    CraftItemStack craftStack = CraftItemStack.asCraftCopy(is);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    NBTTagCompound tag = itemStack.getTag();
    if (tag == null || !tag.hasKey("BlockEntityTag")) {
        throw new IllegalArgumentException();
    }
    String name = tag.getCompound("BlockEntityTag").getString("EntityId");
    return EntityType.fromName(name);
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_8_R1.NBTTagCompound)

Example 57 with ItemStack

use of net.minecraft.server.v1_8_R1.ItemStack in project Citizens2 by CitizensDev.

the class CitizensBlockBreaker method strengthMod.

private float strengthMod(Block block) {
    ItemStack itemstack = getCurrentItem();
    float f = itemstack.a(block);
    if (entity instanceof EntityLiving) {
        EntityLiving handle = (EntityLiving) entity;
        if (f > 1.0F) {
            int i = EnchantmentManager.getDigSpeedEnchantmentLevel(handle);
            if (i > 0) {
                f += i * i + 1;
            }
        }
        if (handle.hasEffect(MobEffectList.FASTER_DIG)) {
            f *= (1.0F + (handle.getEffect(MobEffectList.FASTER_DIG).getAmplifier() + 1) * 0.2F);
        }
        if (handle.hasEffect(MobEffectList.SLOWER_DIG)) {
            float f1 = 1.0F;
            switch(handle.getEffect(MobEffectList.SLOWER_DIG).getAmplifier()) {
                case 0:
                    f1 = 0.3F;
                    break;
                case 1:
                    f1 = 0.09F;
                    break;
                case 2:
                    f1 = 0.0027F;
                    break;
                case 3:
                default:
                    f1 = 8.1E-4F;
            }
            f *= f1;
        }
        if ((handle.a(Material.WATER)) && (!EnchantmentManager.j(handle))) {
            f /= 5.0F;
        }
    }
    if (!entity.onGround) {
        f /= 5.0F;
    }
    return f;
}
Also used : EntityLiving(net.minecraft.server.v1_8_R3.EntityLiving) ItemStack(net.minecraft.server.v1_8_R3.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)

Example 58 with ItemStack

use of net.minecraft.server.v1_8_R1.ItemStack in project Citizens2 by CitizensDev.

the class CitizensBlockBreaker method strengthMod.

private float strengthMod(IBlockData block) {
    ItemStack itemstack = getCurrentItem();
    float f = itemstack.a(block);
    if (entity instanceof EntityLiving) {
        EntityLiving handle = (EntityLiving) entity;
        if (f > 1.0F) {
            int i = EnchantmentManager.getDigSpeedEnchantmentLevel(handle);
            if (i > 0) {
                f += i * i + 1;
            }
        }
        if (handle.hasEffect(MobEffects.FASTER_DIG)) {
            f *= (1.0F + (handle.getEffect(MobEffects.FASTER_DIG).getAmplifier() + 1) * 0.2F);
        }
        if (handle.hasEffect(MobEffects.SLOWER_DIG)) {
            float f1 = 1.0F;
            switch(handle.getEffect(MobEffects.SLOWER_DIG).getAmplifier()) {
                case 0:
                    f1 = 0.3F;
                    break;
                case 1:
                    f1 = 0.09F;
                    break;
                case 2:
                    f1 = 0.0027F;
                    break;
                case 3:
                default:
                    f1 = 8.1E-4F;
            }
            f *= f1;
        }
        if ((handle.a(Material.WATER)) && (!EnchantmentManager.i(handle))) {
            f /= 5.0F;
        }
    }
    if (!entity.onGround) {
        f /= 5.0F;
    }
    return f;
}
Also used : EntityLiving(net.minecraft.server.v1_12_R1.EntityLiving) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Aggregations

IconMenuItem (de.Keyle.MyPet.api.gui.IconMenuItem)18 TagCompound (de.keyle.knbt.TagCompound)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 CraftItemStack (org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack)9 NBTTagCompound (net.minecraft.server.v1_8_R1.NBTTagCompound)8 ItemStack (net.minecraft.server.v1_8_R3.ItemStack)8 ItemStack (net.minecraft.server.v1_7_R4.ItemStack)7 ItemStack (net.minecraft.server.v1_8_R1.ItemStack)7 ItemStack (net.minecraft.server.v1_8_R2.ItemStack)7 NBTTagString (net.minecraft.server.v1_8_R1.NBTTagString)5 CompoundTag (com.wasteofplastic.org.jnbt.CompoundTag)4 ListTag (com.wasteofplastic.org.jnbt.ListTag)4 StringTag (com.wasteofplastic.org.jnbt.StringTag)4 Tag (com.wasteofplastic.org.jnbt.Tag)4 Map (java.util.Map)4 ItemStack (net.minecraft.server.v1_10_R1.ItemStack)4 ItemStack (net.minecraft.server.v1_11_R1.ItemStack)4 ItemStack (net.minecraft.server.v1_12_R1.ItemStack)4 CraftItemStack (org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack)4 CraftItemStack (org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack)4