use of org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack 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 org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack 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 org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack in project Essentials by drtshock.
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);
}
use of org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack in project Essentials by drtshock.
the class v1_8_R1SpawnerProvider method setEntityType.
@Override
public ItemStack setEntityType(ItemStack is, EntityType type) {
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 = 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);
}
Aggregations