use of net.minecraft.server.v1_8_R2.ItemStack in project Essentials by drtshock.
the class v1_8_R2SpawnerProvider method getEntityType.
@Override
public EntityType getEntityType(ItemStack is) {
net.minecraft.server.v1_8_R2.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);
}
use of net.minecraft.server.v1_8_R2.ItemStack in project Essentials by drtshock.
the class v1_8_R2SpawnerProvider method setEntityType.
@Override
public ItemStack setEntityType(ItemStack is, EntityType type) {
net.minecraft.server.v1_8_R2.ItemStack itemStack;
CraftItemStack craftStack = CraftItemStack.asCraftCopy(is);
itemStack = CraftItemStack.asNMSCopy(craftStack);
NBTTagCompound tag = itemStack.getTag();
if (tag == null) {
tag = new NBTTagCompound();
itemStack.setTag(tag);
}
if (!tag.hasKey("BlockEntityTag")) {
tag.set("BlockEntityTag", new NBTTagCompound());
}
tag = itemStack.getTag().getCompound("BlockEntityTag");
tag.setString("EntityId", type.getName());
ItemStack bukkitItemStack = CraftItemStack.asCraftMirror(itemStack).clone();
return setDisplayName(bukkitItemStack, type);
}
use of net.minecraft.server.v1_8_R2.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, ItemStack.a);
}
}
}
use of net.minecraft.server.v1_8_R2.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;
}
use of net.minecraft.server.v1_8_R2.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;
}
Aggregations