I created a custom block like this:
info:
namespace: generators
items:
test_generator:
display_name: Test Generator
permission: test_generator
nbt: '{valueItem: true, isGenerator: true, generatorLevel: 1, generatorType: "MONEY"}'
resource:
generate: true
material: PAPER
textures:
- block/test_generator.png
specific_properties:
block:
placed_model:
type: REAL_NOTE
break_particles: ITEM
everything works fine ingame (block shows up and can be placed with no problems). As you can see i provided a custom NBT value for the block but when i try to modify the nbt values it just wont work…
This is my plugin code that uses tr7zw/Item-NBT-API to modify NBT values (works on non ItemsAdder stuff fine):
public static ItemStack buildGeneratorItem(GeneratorRegistry generator, int amount) throws NullPointerException {
CustomStack customStack = CustomStack.getInstance("generators:" + generator.getItemAdderId());
if (customStack == null)
throw new NullPointerException("ItemsAdder stack for id " + generator.getItemAdderId() + " not found");
ItemStack itemStack = new ItemBuilder(customStack.getItemStack())
.setAmount(amount)
.setName("§eMoney Generator §8[§7Lvl. " + generator.getLevel() + "§8]")
.setLore(
"§7Place this generator on your plot to",
"§7start generating money.",
" ",
"§6§lINFORMATION",
"§6§l⋆ §7Generates§8: §e$" + Maths.formatNumberShort(generator.generateAmount*2) + "/min",
"§6§l⋆ §7Storage§8: §e$" + Maths.formatNumberShort(0),
"§b§l⋆ §7Shards§8: §b" + Maths.formatNumberShort(0),
" ",
"§8Right Click when placed"
)
.toItemStack();
NBT.modify(itemStack, nbt -> {
nbt.setBoolean("valueItem", true);
nbt.setBoolean("isGenerator", false);
nbt.setInteger("generatorLevel", generator.getLevel());
nbt.setEnum("generatorType", generator.getGeneratorType());
});
return itemStack;
}
As you can see im setting the isGenerator boolean to false but this just does not have a effect on the actual nbt value. The same happens when i try to add completely new nbt tags to a item that are not specified in the ItemsAdder block config.
Does anyone know what im doing wrong or is this just not possible?
Thanks for taking time in advance 🙂