Solved NBT craft issue (Not updating on craft)

Discussion in 'Spigot Plugin Development' started by Sean0402, Jan 27, 2020.

Thread Status:
Not open for further replies.
  1. Hey all, I basically have a plugin where it stores NBT on the ItemStack to prevent stacking.

    This is how I store the ItemStack;
    Code (Java):
    public ItemStack getItems(String name, List<String> lore) {
            for (String items : ColeniaPlanets.getInstance().getConfig().getConfigurationSection("tiers").getKeys(false)) {
                // Material
                ItemStack item = new ItemStack(Material.valueOf(ColeniaPlanets.getInstance().getConfig().getString("tiers." + items + ".Item.Material")));

                return new ItemStackBuilder(item)
            return null;
    My issue is that I have a recipe crafter which takes the shape + inredients from the config (works perfect) but the result has the same NBT. The "nbtItem.SetString("id", getUuid().tostring());" returns a random UUID;
    Code (Java):
    this.uuid = UUID.randomUUID();
    I'm unsure of why it decides not to update?
    Recipe code;
    Code (Java):
     private void load(String recipeName, ItemStack item) {
            NBTItem nbtItem = new NBTItem(item);
            nbtItem.setString("TieredItem", recipeName);
            nbtItem.setString("DoNotStack", UUID.randomUUID().toString());

            ItemStack copy = nbtItem.getItem();

            ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(ColeniaPlanets.getInstance(), recipeName), copy);
    As you see, I'm applying the NBT, and I add the recipe at the bottom after the whole config checking for ingredients.

    Note: I also use a command to give the itemStack, the NBT data changes perfect, but when crafting it, it doesn't seem to change?
  2. instead of using a random UUID, try pasting in the "System.currentMillis()" (not sure what the method is called excactly)
  3. Solved this issue. Cached the name / lore on startup and then applied it to the itemstack after.
    • Like Like x 1
Thread Status:
Not open for further replies.