Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Enchants dont save on item drop #862

Closed
Brougud opened this issue Apr 16, 2024 · 1 comment
Closed

Custom Enchants dont save on item drop #862

Brougud opened this issue Apr 16, 2024 · 1 comment

Comments

@Brougud
Copy link

Brougud commented Apr 16, 2024

When creating a custom enchant, I have ran into the problem of the enchant not working after the item is dropped, there is no errors or anything, the item just simply wont register that there is a custom enchant on there.

I am giving the enchanted item, to the player on the accept(p *player.Player) and have tried setting the item's enchants again on pickup, and drop, to no avail.

Here is how I am registering the enchant

enchants := map[int]CustomEnchant{
    100: Explosion{},
}

for id, e := range enchants {
    item.RegisterEnchantment(id, e)
    fmt.Println("Registered Enchant " + e.Name())
}

here is how I am giving the item to the player

stack := item.NewStack(item.Pickaxe{Tier: item.ToolTierNetherite}, 1)
stack = stack.WithEnchantments(ce.NewExplosion(3))
stack = stack.WithEnchantments(item.NewEnchantment(enchantment.Efficiency{}, 200))
stack = ce.LoreItem(stack)

pl.Inventory().AddItem(stack)

the NewExplosion() method

func NewExplosion(lvl int) item.Enchantment {
    return item.NewEnchantment(Explosion{lvl: lvl}, lvl)
}

and when I was debugging, I found that this is whats printed for the items ItemStack.Enchantments(): [{{} 200}].

Finally, I will reiterate that this enchant does work, when the item is first given to the player, however after you drop it and pick it back up, it will not.

@TwistedAsylumMC
Copy link
Member

Discussed on discord, was the result of OP's implementation of the enchant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants