DragonSurvivalTeam / DragonSurvival

Other
49 stars 41 forks source link

Enchantments, a handful of bug fixes #599

Closed Psither closed 2 months ago

Psither commented 2 months ago

The first pass at having items that have built-in enchantments that can't be removed, but don't block normal enchanting logic

Fixes silk touch giving dragon dust items Fixes a body type not being assigned properly when using the dragon command without specifying it Fixes base body type not specifying health bonus

SiverDX commented 2 months ago

is getDefaultEnchantments only called on the client?

How is the server going to determine the default enchantments? Why not pass a level / registry access to the method, don't the events have access to that (level or an entity)?

Also would recommend adding a new method to https://github.com/DragonSurvivalTeam/DragonSurvival/blob/1.21.x/src/main/java/by/dragonsurvivalteam/dragonsurvival/util/EnchantmentUtils.java which gets an enchantment, to cut down on boilerplate code

Psither commented 2 months ago

ItemStack doesn't have any way to access the level directly, or any entities to get the level from, and that's all that most of these methods get.

SiverDX commented 2 months ago

I mean at the moment it just wouldn't work, would it?

In applyDebuffs you have an entity but still access the client minecraft instance (and iirc effects can only really be modified on the server side)

same for the livingHurt event

you could maybe populate a static list on ServerStartedEvent (if the server has registry access, don't know tbh)

TeamSpen210 commented 2 months ago

Instead of directly adding enchantments to NBT, it might be better to instead override getEnchantmentLevel() and getAllEnchantments(). That way the item is considered to have the enchantment for gameplay purposes, but it can't be removed with the grindstone, regular enchantments can still work, etc.