use of net.minecraft.server.v1_16_R2.NBTTagList in project custom-items-gradle by knokko.
the class ItemAttributes method resetAttributes.
public static ItemStack resetAttributes(ItemStack original) {
net.minecraft.server.v1_12_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(original);
if (nmsStack.hasTag()) {
NBTTagCompound compound = nmsStack.getTag();
NBTTagList modifiers = compound.getList("AttributeModifiers", 10);
if (modifiers != null) {
compound.remove("AttributeModifiers");
nmsStack.setTag(compound);
return CraftItemStack.asBukkitCopy(nmsStack);
} else
return original;
} else
return original;
}
use of net.minecraft.server.v1_16_R2.NBTTagList in project SilkSpawners by timbru31.
the class NMSHandler method setNBTEntityID.
@Override
public ItemStack setNBTEntityID(final ItemStack item, final String entity) {
if (item == null || StringUtils.isBlank(entity)) {
Bukkit.getLogger().warning("[SilkSpawners] Skipping invalid spawner to set NBT data on.");
return null;
}
net.minecraft.server.v1_10_R1.ItemStack itemStack = null;
final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
itemStack = CraftItemStack.asNMSCopy(craftStack);
NBTTagCompound tag = itemStack.getTag();
if (tag == null) {
tag = new NBTTagCompound();
itemStack.setTag(tag);
}
if (!tag.hasKey("SilkSpawners")) {
tag.set("SilkSpawners", new NBTTagCompound());
}
tag.getCompound("SilkSpawners").setString("entity", entity);
if (!tag.hasKey("BlockEntityTag")) {
tag.set("BlockEntityTag", new NBTTagCompound());
}
tag.getCompound("BlockEntityTag").setString("EntityId", entity);
if (!tag.hasKey("SpawnData")) {
tag.set("SpawnData", new NBTTagCompound());
}
tag.getCompound("SpawnData").setString("id", entity);
if (!tag.getCompound("BlockEntityTag").hasKey("SpawnData")) {
tag.getCompound("BlockEntityTag").set("SpawnData", new NBTTagCompound());
}
tag.getCompound("BlockEntityTag").getCompound("SpawnData").setString("id", entity);
if (!tag.getCompound("BlockEntityTag").hasKey("SpawnPotentials")) {
tag.getCompound("BlockEntityTag").set("SpawnPotentials", new NBTTagCompound());
}
final NBTTagList tagList = new NBTTagList();
final NBTTagCompound spawnPotentials = new NBTTagCompound();
spawnPotentials.set("Entity", new NBTTagCompound());
spawnPotentials.getCompound("Entity").setString("id", entity);
spawnPotentials.setInt("Weight", 1);
tagList.add(spawnPotentials);
tag.getCompound("BlockEntityTag").set("SpawnPotentials", tagList);
// SpawnEgg data
if (!tag.hasKey("EntityTag")) {
tag.set("EntityTag", new NBTTagCompound());
}
tag.getCompound("EntityTag").setString("id", entity);
return CraftItemStack.asCraftMirror(itemStack);
}
use of net.minecraft.server.v1_16_R2.NBTTagList in project SilkSpawners by timbru31.
the class NMSHandler method setNBTEntityID.
@Override
public ItemStack setNBTEntityID(final ItemStack item, final String entity) {
if (item == null || StringUtils.isBlank(entity)) {
Bukkit.getLogger().warning("[SilkSpawners] Skipping invalid spawner to set NBT data on.");
return null;
}
net.minecraft.server.v1_9_R2.ItemStack itemStack = null;
final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
itemStack = CraftItemStack.asNMSCopy(craftStack);
NBTTagCompound tag = itemStack.getTag();
if (tag == null) {
tag = new NBTTagCompound();
itemStack.setTag(tag);
}
if (!tag.hasKey("SilkSpawners")) {
tag.set("SilkSpawners", new NBTTagCompound());
}
tag.getCompound("SilkSpawners").setString("entity", entity);
if (!tag.hasKey("BlockEntityTag")) {
tag.set("BlockEntityTag", new NBTTagCompound());
}
tag.getCompound("BlockEntityTag").setString("EntityId", entity);
if (!tag.hasKey("SpawnData")) {
tag.set("SpawnData", new NBTTagCompound());
}
tag.getCompound("SpawnData").setString("id", entity);
if (!tag.getCompound("BlockEntityTag").hasKey("SpawnData")) {
tag.getCompound("BlockEntityTag").set("SpawnData", new NBTTagCompound());
}
tag.getCompound("BlockEntityTag").getCompound("SpawnData").setString("id", entity);
if (!tag.getCompound("BlockEntityTag").hasKey("SpawnPotentials")) {
tag.getCompound("BlockEntityTag").set("SpawnPotentials", new NBTTagCompound());
}
final NBTTagList tagList = new NBTTagList();
final NBTTagCompound spawnPotentials = new NBTTagCompound();
spawnPotentials.set("Entity", new NBTTagCompound());
spawnPotentials.getCompound("Entity").setString("id", entity);
spawnPotentials.setInt("Weight", 1);
tagList.add(spawnPotentials);
tag.getCompound("BlockEntityTag").set("SpawnPotentials", tagList);
if (!tag.hasKey("EntityTag")) {
tag.set("EntityTag", new NBTTagCompound());
}
tag.getCompound("EntityTag").setString("id", entity);
return CraftItemStack.asCraftMirror(itemStack);
}
Aggregations