Search in sources :

Example 31 with ItemStack

use of net.minecraft.server.v1_16_R3.ItemStack in project MyPet by xXKeyleXx.

the class EntityMyCow method handlePlayerInteraction.

public boolean handlePlayerInteraction(EntityHuman entityhuman) {
    if (super.handlePlayerInteraction(entityhuman)) {
        return true;
    }
    ItemStack itemStack = entityhuman.inventory.getItemInHand();
    if (getOwner().equals(entityhuman) && itemStack != null && canUseItem()) {
        if (itemStack.getItem() == Items.BUCKET && Configuration.MyPet.Cow.CAN_GIVE_MILK) {
            ItemStack milkBucket = new ItemStack(Items.MILK_BUCKET, 1, 0);
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, milkBucket);
            return true;
        } else if (Configuration.MyPet.Cow.GROW_UP_ITEM.compare(itemStack) && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) {
            if (!entityhuman.abilities.canInstantlyBuild) {
                if (--itemStack.count <= 0) {
                    entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null);
                }
            }
            getMyPet().setBaby(false);
            return true;
        }
    }
    return false;
}
Also used : ItemStack(net.minecraft.server.v1_8_R3.ItemStack)

Example 32 with ItemStack

use of net.minecraft.server.v1_16_R3.ItemStack in project MyPet by xXKeyleXx.

the class EntityMyOcelot method handlePlayerInteraction.

public boolean handlePlayerInteraction(EntityHuman entityhuman) {
    if (super.handlePlayerInteraction(entityhuman)) {
        return true;
    }
    ItemStack itemStack = entityhuman.inventory.getItemInHand();
    if (getOwner().equals(entityhuman)) {
        if (itemStack != null && canUseItem() && getOwner().getPlayer().isSneaking()) {
            if (Item.getId(itemStack.getItem()) == 351) {
                boolean colorChanged = false;
                if (itemStack.getData() == 11 && getMyPet().getCatType() != Type.WILD_OCELOT) {
                    getMyPet().setCatType(Type.WILD_OCELOT);
                    colorChanged = true;
                } else if (itemStack.getData() == 0 && getMyPet().getCatType() != Type.BLACK_CAT) {
                    getMyPet().setCatType(Type.BLACK_CAT);
                    colorChanged = true;
                } else if (itemStack.getData() == 14 && getMyPet().getCatType() != Type.RED_CAT) {
                    getMyPet().setCatType(Type.RED_CAT);
                    colorChanged = true;
                } else if (itemStack.getData() == 7 && getMyPet().getCatType() != Type.SIAMESE_CAT) {
                    getMyPet().setCatType(Type.SIAMESE_CAT);
                    colorChanged = true;
                }
                if (colorChanged) {
                    if (!entityhuman.abilities.canInstantlyBuild) {
                        if (--itemStack.count <= 0) {
                            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null);
                        }
                    }
                    return true;
                }
            } else if (Configuration.MyPet.Ocelot.GROW_UP_ITEM.compare(itemStack) && canUseItem() && getMyPet().isBaby() && getOwner().getPlayer().isSneaking()) {
                if (!entityhuman.abilities.canInstantlyBuild) {
                    if (--itemStack.count <= 0) {
                        entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, null);
                    }
                }
                getMyPet().setBaby(false);
                return true;
            }
        }
    }
    return false;
}
Also used : ItemStack(net.minecraft.server.v1_8_R3.ItemStack)

Example 33 with ItemStack

use of net.minecraft.server.v1_16_R3.ItemStack in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method getPlayerSkull.

@Override
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack itemStack, String texture) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound nbtTagCompound = nmsItem.getOrCreateTag();
    NBTTagCompound skullOwner = nbtTagCompound.hasKey("SkullOwner") ? nbtTagCompound.getCompound("SkullOwner") : new NBTTagCompound();
    NBTTagCompound properties = new NBTTagCompound();
    NBTTagList textures = new NBTTagList();
    NBTTagCompound signature = new NBTTagCompound();
    signature.setString("Value", texture);
    textures.add(signature);
    properties.set("textures", textures);
    skullOwner.set("Properties", properties);
    skullOwner.setString("Id", UUID.randomUUID().toString());
    nbtTagCompound.set("SkullOwner", skullOwner);
    nmsItem.setTag(nbtTagCompound);
    return CraftItemStack.asBukkitCopy(nmsItem);
}
Also used : NBTTagList(net.minecraft.server.v1_16_R3.NBTTagList) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_16_R3.ItemStack)

Example 34 with ItemStack

use of net.minecraft.server.v1_16_R3.ItemStack in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method setTag.

@Override
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
    tagCompound.set(key, NBTTagString.a(value));
    nmsItem.setTag(tagCompound);
    return CraftItemStack.asBukkitCopy(nmsItem);
}
Also used : NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_16_R3.ItemStack)

Example 35 with ItemStack

use of net.minecraft.server.v1_16_R3.ItemStack in project WildLoaders by BG-Software-LLC.

the class NMSAdapter_v1_12_R1 method getTag.

@Override
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key, String def) {
    ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
    if (!tagCompound.hasKeyOfType(key, 8))
        return def;
    return tagCompound.getString(key);
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Aggregations

CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)49 net.minecraft.server.v1_16_R3 (net.minecraft.server.v1_16_R3)28 InvocationTargetException (java.lang.reflect.InvocationTargetException)27 ItemStack (net.minecraft.server.v1_8_R3.ItemStack)27 ItemStack (net.minecraft.server.v1_12_R1.ItemStack)25 Pair (com.mojang.datafixers.util.Pair)22 ItemStack (net.minecraft.server.v1_16_R3.ItemStack)20 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)20 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)20 MyPetApi (de.Keyle.MyPet.MyPetApi)18 EntitySize (de.Keyle.MyPet.api.entity.EntitySize)18 MyPet (de.Keyle.MyPet.api.entity.MyPet)18 IconMenuItem (de.Keyle.MyPet.api.gui.IconMenuItem)18 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet)18 Bukkit (org.bukkit.Bukkit)18 Util (de.Keyle.MyPet.api.Util)17 EquipmentSlot (de.Keyle.MyPet.api.entity.EquipmentSlot)17 Arrays (java.util.Arrays)17 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)17 ENTITY_LIVING_broadcastItemBreak (de.Keyle.MyPet.compat.v1_16_R3.CompatManager.ENTITY_LIVING_broadcastItemBreak)15