I am making a game, and I decided to totally copy Minecraft’s enchantment system. Other enchantments you might see are ones I am adding to my game. I have two candidates for storing enchantments. Which is more efficient? Or are they both inefficient and I should use yet another system. Here is the code for the first option: struct ItemInstance { unsigned short ID; unsigned char Renamed:1; unsigned int Q:6; char *DisplayName; union { struct SwordData { struct SwordEnch { struct MeleeWeaponEnchantment { unsigned char Sharpness:4; unsigned char Smite:4; unsigned char BaneOfArthropods; unsigned char Impaling:4; unsigned char Extinguishing:4; unsigned char Knockback:4; unsigned char Looting:4; unsigned char SweepingEdge:4; } MeleeWeapon; struct DurabilityEnchantment { unsigned char Unbreaking:4; unsigned char Mending:1; unsigned char Neverbreaking:1; unsigned char Poof:1; } Durability; } Enchantment; short int DurabilityPointsLeft; } Sword; struct ToolData { struct ToolEnch { struct ToolEnchantment { unsigned char Efficiency:4; unsigned char Fortune:4; unsigned char SilkTouch:1; } Tool; struct MeleeWeaponEnchantment MeleeWeapon; struct DurabilityEnchantment Durability; } Enchantment; short int DurabilityPointsLeft; } Tool; struct ArmorData { struct ArmorEnch { struct ArmorEnchantment { unsigned char Protection:4; unsigned char BlastProtection:4; unsigned char FireProtection:4; unsigned char ProjectileProtection:4; unsigned char KineticProtection:4; unsigned char FeatherFalling:4; unsigned char DepthStrider:4; unsigned char Respiration:4; unsigned char Thorns:4; unsigned char Binding:1; unsigned char AquaAffinity:1; unsigned char NightVision:1; unsigned char FrostWalker:1; } Armor; struct DurabilityEnchantment Durability; } Enchantment; short int DurabilityPointsLeft; } Armor; struct ThrownWeaponsData { struct ThrownWeaponsEnch { struct ThrownWeaponEnchantment { unsigned char Loyalty:1; unsigned char Channeling:1; unsigned char Riptide:4; } ThrowableWeapon; struct MeleeWeaponEnchantment MeleeWeapon; struct… [Read full story]