WeaponMechanics / MechanicsMain

A New Age of Weapons in Minecraft.
https://www.spigotmc.org/resources/WeaponMechanics.99913/
MIT License
71 stars 26 forks source link

WeaponData class for common data #388

Open CJCrafter opened 5 months ago

CJCrafter commented 5 months ago

The Problem(s)

  1. 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
  2. In a lot of our handlers and events, we pass the same 3-5 arguments every time.
data class WeaponData(
    val shooter: LivingEntity,
    val weaponTitle: String,
    val weaponStack: ItemStack,
    val weaponMeta: ItemMeta,
    val slot: EquipmentSlot,
): CastData {

    val mainhand: Boolean
        get() = (slot == EquipmentSlot.HAND)

    // other methods for getting NBT tags

    // other methods for CastData for easy mechanics casting
}

Pros

Cons

Notes