You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We do not save ItemMeta between method calls, so getting/setting an NBT tag is taking up too many resources. This is because ItemStack#getItemMeta
In a lot of our handlers and events, we pass the same 3-5 arguments every time.
data classWeaponData(
valshooter:LivingEntity,
valweaponTitle:String,
valweaponStack:ItemStack,
valweaponMeta:ItemMeta,
valslot:EquipmentSlot,
): CastData {
val mainhand:Boolean
get() = (slot ==EquipmentSlot.HAND)
// other methods for getting NBT tags// other methods for CastData for easy mechanics casting
}
Pros
Cleaner code
Removes null checks from code since we only do it once
Performance increase from saving the weaponMeta
Performance increase from caching all values
Performance increase from skipping new CastData instantiations
Cons
Refractoring in:
Events API constructors
All handlers
boiler plate at the start of handlers (weaponData#getWeaponStack)
Notes
This does not have to be in Kotlin, just wrote in kotlin for example
If anybody would like to fund to have this coded, let me know :)
The text was updated successfully, but these errors were encountered:
The Problem(s)
ItemMeta
between method calls, so getting/setting an NBT tag is taking up too many resources. This is becauseItemStack#getItemMeta
Pros
new CastData
instantiationsCons
weaponData#getWeaponStack
)Notes
The text was updated successfully, but these errors were encountered: