use of net.minecraft.server.v1_10_R1.NBTTagCompound in project Essentials by EssentialsX.
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);
}
use of net.minecraft.server.v1_10_R1.NBTTagCompound in project Essentials by EssentialsX.
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 net.minecraft.server.v1_10_R1.NBTTagCompound in project Essentials by EssentialsX.
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_10_R1.NBTTagCompound in project Ublisk by Derkades.
the class Item method setNBTValue.
public Item setNBTValue(String key, boolean bool) {
NBTTagCompound compound = this.getNBT();
compound.setBoolean(key, bool);
return this.setNBT(compound);
}
use of net.minecraft.server.v1_10_R1.NBTTagCompound in project Ublisk by Derkades.
the class CustomItem method fromItem.
public static CustomItem fromItem(Item item) {
if (item.getType() != CUSTOM_ITEM) {
throw new IllegalArgumentException("The provided item is not a custom item.");
}
NBTTagCompound nbt = item.getNBT();
if (!nbt.hasKey(UbliskNBT.IDENTIFIER.toString())) {
throw new IllegalArgumentException("The provided item does not have an item identifier in its NBT");
}
String identifier = nbt.getString(UbliskNBT.IDENTIFIER.toString());
return new CustomItem(identifier, true);
}
Aggregations