use of net.minecraft.server.v1_8_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.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;
}
use of net.minecraft.server.v1_8_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;
}
use of net.minecraft.server.v1_8_R3.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());
}
use of net.minecraft.server.v1_8_R3.ItemStack in project acidisland by tastybento.
the class NMSHandler method setFlowerPotBlock.
/* (non-Javadoc)
* @see com.wasteofplastic.askyblock.nms.NMSAbstraction#setBlock(org.bukkit.block.Block, org.bukkit.inventory.ItemStack)
* Credis: Mister_Frans (THANK YOU VERY MUCH !)
*/
@Override
public void setFlowerPotBlock(Block block, ItemStack itemStack) {
Location loc = block.getLocation();
CraftWorld cw = (CraftWorld) block.getWorld();
BlockPosition bp = new BlockPosition(loc.getX(), loc.getY(), loc.getZ());
TileEntityFlowerPot te = (TileEntityFlowerPot) cw.getHandle().getTileEntity(bp);
// Bukkit.getLogger().info("Debug: flowerpot materialdata = " + (new ItemStack(potItem, 1,(short) potItemData).toString()));
net.minecraft.server.v1_8_R3.ItemStack cis = CraftItemStack.asNMSCopy(itemStack);
te.a(cis.getItem(), cis.getData());
te.update();
}
use of net.minecraft.server.v1_8_R3.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());
}
Aggregations