namespace Minecraft.Server.FourKit.Enchantments; using Minecraft.Server.FourKit.Inventory; /// /// Represents the applicable target for a Enchantment /// public enum EnchantmentTarget { /// /// Allows the Enchantment to be placed on all items /// ALL, /// /// Allows the Enchantment to be placed on armor /// ARMOR, /// /// Allows the Enchantment to be placed on feet slot armor /// ARMOR_FEET, /// /// Allows the Enchantment to be placed on head slot armor /// ARMOR_HEAD, /// /// Allows the Enchantment to be placed on leg slot armor /// ARMOR_LEGS, /// /// Allows the Enchantment to be placed on torso slot armor /// ARMOR_TORSO, /// /// Allows the Enchantment to be placed on bows. /// BOW, /// /// Allows the Enchantment to be placed on tools (spades, pickaxe, hoes, axes) /// TOOL, /// /// Allows the Enchantment to be placed on weapons (swords) /// WEAPON, } //these numbers match the same ones that the enchants register as, Enchantment.cpp - 41 /// /// The various type of enchantments that may be added to armour or weapons /// public enum EnchantmentType { /// /// Provides extra damage when shooting arrows from bows /// ARROW_DAMAGE = 48, /// /// Sets entities on fire when hit by arrows shot from a bow /// ARROW_FIRE = 50, /// /// Provides infinite arrows when shooting a bow /// ARROW_INFINITE = 51, /// /// Provides a knockback when an entity is hit by an arrow from a bow /// ARROW_KNOCKBACK = 49, /// /// Increases damage against all targets /// DAMAGE_ALL = 16, /// /// Increases damage against arthropod targets /// DAMAGE_ARTHOPODS = 18, /// /// Increases damage against undead targets /// DAMAGE_UNDEAD = 17, /// /// Increases the rate at which you mine/dig /// DIG_SPEAD = 32, /// /// Decreases the rate at which a tool looses durability /// DURABILITY = 34, /// /// When attacking a target, has a chance to set them on fire /// FIRE_ASPECT = 20, /// /// All damage to other targets will knock them back when hit /// KNOCKBACK = 19, /// /// Provides a chance of gaining extra loot when destroying blocks /// LOOT_BONUS_BLOCKS = 35, /// /// Provides a chance of gaining extra loot when killing monsters /// LOOT_BONUS_MOBS = 21, /// /// Decreases the rate of air loss whilst underwater /// OXYGEN = 5, /// /// Provides protection against environmental damage /// PROTECTION_ENVIRONMENTAL = 0, /// /// Provides protection against explosive damage /// PROTECTION_EXPLOSIVE = 3, /// /// Provides protection against fall damage /// PROTECTION_FALL = 2, /// /// Provides protection against fire damage /// PROTECTION_FIRE = 1, /// /// Provides protection against projectile damage /// PROTECTION_PROJECTILE = 4, /// /// Allows blocks to drop themselves instead of fragments (for example, stone instead of cobblestone) /// SILK_TOUCH = 33, /// /// Damages the attacker /// THORNS = 7, /// /// Increases the speed at which a player may mine underwater /// WATER_WORKER = 6 } public abstract class Enchantment { public static Enchantment PowerEnchantment => _registry[EnchantmentType.ARROW_DAMAGE]; public static Enchantment FlameEnchantment => _registry[EnchantmentType.ARROW_FIRE]; public static Enchantment InfinityEnchantment => _registry[EnchantmentType.ARROW_INFINITE]; public static Enchantment PunchEnchantment => _registry[EnchantmentType.ARROW_KNOCKBACK]; public static Enchantment SharpnessEnchantment => _registry[EnchantmentType.DAMAGE_ALL]; public static Enchantment BaneOfArthropodsEnchantment => _registry[EnchantmentType.DAMAGE_ARTHOPODS]; public static Enchantment SmiteEnchantment => _registry[EnchantmentType.DAMAGE_UNDEAD]; public static Enchantment EfficiencyEnchantment => _registry[EnchantmentType.DIG_SPEAD]; public static Enchantment UnbreakingEnchantment => _registry[EnchantmentType.DURABILITY]; public static Enchantment FireAspectEnchantment => _registry[EnchantmentType.FIRE_ASPECT]; public static Enchantment KnockbackEnchantment => _registry[EnchantmentType.KNOCKBACK]; public static Enchantment FortuneEnchantment => _registry[EnchantmentType.LOOT_BONUS_BLOCKS]; public static Enchantment LootingEnchantment => _registry[EnchantmentType.LOOT_BONUS_MOBS]; public static Enchantment RespirationEnchantment => _registry[EnchantmentType.OXYGEN]; public static Enchantment ProtectionEnchantment => _registry[EnchantmentType.PROTECTION_ENVIRONMENTAL]; public static Enchantment BlastProtectionEnchantment => _registry[EnchantmentType.PROTECTION_EXPLOSIVE]; public static Enchantment FeatherFallingEnchantment => _registry[EnchantmentType.PROTECTION_FALL]; public static Enchantment FireProtectionEnchantment => _registry[EnchantmentType.PROTECTION_FIRE]; public static Enchantment ProjectileProtectionEnchantment => _registry[EnchantmentType.PROTECTION_PROJECTILE]; public static Enchantment SilkTouchEnchantment => _registry[EnchantmentType.SILK_TOUCH]; public static Enchantment ThornsEnchantment => _registry[EnchantmentType.THORNS]; public static Enchantment AquaAffinityEnchantment => _registry[EnchantmentType.WATER_WORKER]; private static Dictionary _registry = new Dictionary() { { EnchantmentType.ARROW_DAMAGE, new PowerEnchantment() }, { EnchantmentType.ARROW_FIRE, new FlameEnchantment() }, { EnchantmentType.ARROW_INFINITE, new InfinityEnchantment() }, { EnchantmentType.ARROW_KNOCKBACK, new PunchEnchantment() }, { EnchantmentType.DAMAGE_ALL, new SharpnessEnchantment() }, { EnchantmentType.DAMAGE_ARTHOPODS, new BaneOfArthropodsEnchantment() }, { EnchantmentType.DAMAGE_UNDEAD, new SmiteEnchantment() }, { EnchantmentType.DIG_SPEAD, new EfficiencyEnchantment() }, { EnchantmentType.DURABILITY, new UnbreakingEnchantment() }, { EnchantmentType.FIRE_ASPECT, new FireAspectEnchantment() }, { EnchantmentType.KNOCKBACK, new KnockbackEnchantment() }, { EnchantmentType.LOOT_BONUS_BLOCKS, new FortuneEnchantment() }, { EnchantmentType.LOOT_BONUS_MOBS, new LootingEnchantment() }, { EnchantmentType.OXYGEN, new RespirationEnchantment() }, { EnchantmentType.PROTECTION_ENVIRONMENTAL, new ProtectionEnchantment() }, { EnchantmentType.PROTECTION_EXPLOSIVE, new BlastProtectionEnchantment() }, { EnchantmentType.PROTECTION_FALL, new FeatherFallingEnchantment() }, { EnchantmentType.PROTECTION_FIRE, new FireProtectionEnchantment() }, { EnchantmentType.PROTECTION_PROJECTILE, new ProjectileProtectionEnchantment() }, { EnchantmentType.SILK_TOUCH, new SilkTouchEnchantment() }, { EnchantmentType.THORNS, new ThornsEnchantment() }, { EnchantmentType.WATER_WORKER, new AquaAffinityEnchantment() }, }; /// /// Checks if this Enchantment may be applied to the given . This does not check if it conflicts with any enchantments already applied to the item. /// /// Item to test /// True if the enchantment may be applied, otherwise False public abstract bool canEnchantItem(ItemStack item); /// /// Check if this enchantment conflicts with another enchantment. /// /// The enchantment to check against /// True if there is a conflict. public abstract bool conflictsWith(Enchantment other); //public abstract Enchantment getById(int id); //deprecated by bukkit /// /// Gets the Enchantment at the specified name /// /// Name to fetch. /// Resulting Enchantment, or null if not found public static Enchantment? getByName(string name) { foreach (KeyValuePair enchantmentPair in _registry) { if (enchantmentPair.Value.getName().Equals(name)) return enchantmentPair.Value; } return null; } /// /// Gets the Enchantment at the specified type /// /// Type to fetch. /// Resulting Enchantment, or null if not found public static Enchantment getByType(EnchantmentType type) { return _registry[type]; //we should always have the enchant based on the type } //public abstract int getId(); //deprecated by bukkit /// /// Gets the type of that may fit this Enchantment. /// /// Gets the type of that may fit this Enchantment. public abstract EnchantmentTarget getItemTarget(); /// /// Returns the . /// /// Gets the enchantment type. public abstract EnchantmentType getEnchantType(); /// /// Gets the maximum level that this Enchantment may become. /// /// Maximum level of the Enchantment public abstract int getMaxLevel(); /// /// Gets the unique name of this enchantment /// /// Unique name public abstract string getName(); /// /// Gets the level that this Enchantment should start at /// /// Starting level of the Enchantment public abstract int getStartLevel(); //public static bool isAcceptingRegistrations(); //we dont have enchant registrations //public static void registerEnchantment(Enchantment enchantment); //we dont have enchant registrations //public static void stopAcceptingRegistrations(); //we dont have enchant registrations }