Search in sources :

Example 1 with ItemStack

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

the class EntityMyBlaze 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 (getMyPet().isOnFire() && itemStack.getItem() == Items.GLASS_BOTTLE && itemStack.getData() == 0 && getOwner().getPlayer().isSneaking()) {
            getMyPet().setOnFire(false);
            makeSound("random.fizz", 1.0F, 1.0F);
            if (!entityhuman.abilities.canInstantlyBuild) {
                if (--itemStack.count <= 0) {
                    entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, new ItemStack(Items.GLASS_BOTTLE));
                } else {
                    if (!entityhuman.inventory.pickup(new ItemStack(Items.GLASS_BOTTLE))) {
                        entityhuman.drop(new ItemStack(Items.GLASS_BOTTLE), true);
                    }
                }
            }
            return true;
        } else if (!getMyPet().isOnFire() && itemStack.getItem() == Items.FLINT_AND_STEEL && getOwner().getPlayer().isSneaking()) {
            getMyPet().setOnFire(true);
            makeSound("fire.ignite", 1.0F, 1.0F);
            if (!entityhuman.abilities.canInstantlyBuild) {
                itemStack.damage(1, entityhuman);
            }
            return true;
        }
    }
    return false;
}
Also used : ItemStack(net.minecraft.server.v1_7_R4.ItemStack)

Example 2 with ItemStack

use of net.minecraft.server.v1_13_R1.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.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_7_R4.ItemStack)

Example 3 with ItemStack

use of net.minecraft.server.v1_13_R1.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_7_R4.ItemStack)

Example 4 with ItemStack

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

the class IconMenuInventory method update.

@Override
public void update(IconMenu menu) {
    for (int slot = 0; slot < size; slot++) {
        IconMenuItem menuItem = menu.getOption(slot);
        if (menuItem != null) {
            ItemStack item = createItemStack(menuItem);
            minecraftInventory.setItem(slot, item);
        } else {
            minecraftInventory.setItem(slot, null);
        }
    }
}
Also used : IconMenuItem(de.Keyle.MyPet.api.gui.IconMenuItem) ItemStack(net.minecraft.server.v1_7_R4.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack)

Example 5 with ItemStack

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

the class IconMenuInventory method open.

@Override
public void open(IconMenu menu, HumanEntity player) {
    size = menu.getSize();
    minecraftInventory = new CustomInventory(size, menu.getTitle());
    for (int slot = 0; slot < size; slot++) {
        IconMenuItem menuItem = menu.getOption(slot);
        if (menuItem != null) {
            ItemStack item = createItemStack(menuItem);
            minecraftInventory.setItem(slot, item);
        }
    }
    player.openInventory(minecraftInventory.getBukkitInventory());
}
Also used : IconMenuItem(de.Keyle.MyPet.api.gui.IconMenuItem) ItemStack(net.minecraft.server.v1_7_R4.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack) CustomInventory(de.Keyle.MyPet.compat.v1_7_R4.util.inventory.CustomInventory)

Aggregations

ItemStack (net.minecraft.server.v1_8_R3.ItemStack)26 ItemStack (net.minecraft.server.v1_12_R1.ItemStack)24 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)20 ItemStack (net.minecraft.server.v1_16_R3.ItemStack)19 IconMenuItem (de.Keyle.MyPet.api.gui.IconMenuItem)18 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)17 CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)16 ItemStack (net.minecraft.server.v1_11_R1.ItemStack)13 ItemStack (net.minecraft.server.v1_7_R4.ItemStack)12 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)11 ItemStack (net.minecraft.server.v1_10_R1.ItemStack)10 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)10 TagCompound (de.keyle.knbt.TagCompound)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)9 Field (java.lang.reflect.Field)8 ItemStack (net.minecraft.server.v1_13_R2.ItemStack)8 ItemStack (net.minecraft.server.v1_15_R1.ItemStack)8 ItemStack (net.minecraft.server.v1_9_R2.ItemStack)8 Location (org.bukkit.Location)8