use of net.minecraft.server.v1_16_R1.NBTTagCompound in project MyPet by xXKeyleXx.
the class ItemStackComparator method compareTagData.
public static boolean compareTagData(ItemStack i1, ItemStack i2) {
if (i1.hasItemMeta() && i2.hasItemMeta()) {
NBTTagCompound tag1 = CraftItemStack.asNMSCopy(i1).getTag();
NBTTagCompound tag2 = CraftItemStack.asNMSCopy(i2).getTag();
return tag1 != null && tag2 != null && tag1.equals(tag2);
}
return i1.hasItemMeta() == i2.hasItemMeta();
}
use of net.minecraft.server.v1_16_R1.NBTTagCompound in project Essentials by EssentialsX.
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_16_R1.NBTTagCompound in project Ublisk by Derkades.
the class Item method setNBTValue.
public Item setNBTValue(String key, NBTBase value) {
NBTTagCompound nbt = this.getNBT();
nbt.set(key, value);
return this.setNBT(nbt);
}
use of net.minecraft.server.v1_16_R1.NBTTagCompound in project Ublisk by Derkades.
the class Item method getNBT.
public NBTTagCompound getNBT() {
net.minecraft.server.v1_12_R1.ItemStack nms = CraftItemStack.asNMSCopy(item);
NBTTagCompound compound = nms.getTag();
if (compound == null) {
return new NBTTagCompound();
} else {
return compound;
}
}
use of net.minecraft.server.v1_16_R1.NBTTagCompound in project MyPet by xXKeyleXx.
the class PlatformHelper method entityToTag.
@Override
public TagCompound entityToTag(Entity bukkitEntity) {
net.minecraft.server.v1_16_R1.Entity entity = ((CraftEntity) bukkitEntity).getHandle();
NBTTagCompound vanillaNBT = new NBTTagCompound();
if (entity instanceof EntityLiving) {
((EntityLiving) entity).saveData(vanillaNBT);
} else {
Method b = ReflectionUtil.getMethod(entity.getClass(), "b", NBTTagCompound.class);
try {
b.invoke(entity, vanillaNBT);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
return (TagCompound) ItemStackNBTConverter.vanillaCompoundToCompound(vanillaNBT);
}
Aggregations