From 1be78dbcf4d52bf7c203f3b392b424400b04608b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 25 Apr 2026 21:04:20 +0000 Subject: [PATCH 1/3] Initial plan From 6d4a06b93832d5f4886a165779e692406f65bc88 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 25 Apr 2026 21:07:43 +0000 Subject: [PATCH 2/3] feat: enrich NBTAttribute with version-gated modern attributes Agent-Logs-Url: https://github.com/magemonkeystudio/codex/sessions/120c674f-c88e-4983-bc39-0802adacf0da Co-authored-by: MaksyKun <77341370+MaksyKun@users.noreply.github.com> --- .../codex/api/meta/NBTAttribute.java | 194 ++++++++++++++++-- 1 file changed, 173 insertions(+), 21 deletions(-) diff --git a/codex-api/src/main/java/studio/magemonkey/codex/api/meta/NBTAttribute.java b/codex-api/src/main/java/studio/magemonkey/codex/api/meta/NBTAttribute.java index 753a8eaa..b4ef5b56 100644 --- a/codex-api/src/main/java/studio/magemonkey/codex/api/meta/NBTAttribute.java +++ b/codex-api/src/main/java/studio/magemonkey/codex/api/meta/NBTAttribute.java @@ -4,53 +4,184 @@ import org.bukkit.inventory.EquipmentSlot; import org.jetbrains.annotations.NotNull; import studio.magemonkey.codex.compat.VersionManager; +import studio.magemonkey.codex.core.Version; import java.util.UUID; public enum NBTAttribute { ARMOR( - "generic.armor", - (Attribute) VersionManager.getNms().getAttribute("ARMOR"), - "1f1173-9999-3333-5555-99cb0245f9c1"), // '1' at start + "armor", + "1f1173-9999-3333-5555-99cb0245f9c1", + Version.V1_21_R2), ARMOR_TOUGHNESS( "generic.armorToughness", - (Attribute) VersionManager.getNms().getAttribute("ARMOR_TOUGHNESS"), - "1f1173-9999-3333-5555-99cb0245f9c2"), + "1f1173-9999-3333-5555-99cb0245f9c2", + Version.V1_16_R3), ATTACK_DAMAGE( "generic.attackDamage", - (Attribute) VersionManager.getNms().getAttribute("ATTACK_DAMAGE"), - "1f1173-9999-3333-5555-99cb0245f9c3"), + "1f1173-9999-3333-5555-99cb0245f9c3", + Version.V1_16_R3), + + ATTACK_KNOCKBACK( + "generic.attackKnockback", + "1f1173-9999-3333-5555-99cb0245f9c8", + Version.V1_16_R3), ATTACK_SPEED( "generic.attackSpeed", - (Attribute) VersionManager.getNms().getAttribute("ATTACK_SPEED"), - "1f1173-9999-3333-5555-99cb0245f9c4"), + "1f1173-9999-3333-5555-99cb0245f9c4", + Version.V1_16_R3), + + BLOCK_BREAK_SPEED( + "block_break_speed", + "1f1173-9999-3333-5555-99cb0245f9c9", + Version.V1_20_R4), + + BLOCK_INTERACTION_RANGE( + "block_interaction_range", + "1f1173-9999-3333-5555-99cb0245f9ca", + Version.V1_20_R4), + + BURNING_TIME( + "burning_time", + "1f1173-9999-3333-5555-99cb0245f9cb", + Version.V1_21_R1), + + ENTITY_INTERACTION_RANGE( + "entity_interaction_range", + "1f1173-9999-3333-5555-99cb0245f9cc", + Version.V1_20_R4), + + EXPLOSION_KNOCKBACK_RESISTANCE( + "explosion_knockback_resistance", + "1f1173-9999-3333-5555-99cb0245f9cd", + Version.V1_21_R1), + + FALL_DAMAGE_MULTIPLIER( + "fall_damage_multiplier", + "1f1173-9999-3333-5555-99cb0245f9ce", + Version.V1_20_R4), + + FLYING_SPEED( + "generic.flyingSpeed", + "1f1173-9999-3333-5555-99cb0245f9cf", + Version.V1_16_R3), + + FOLLOW_RANGE( + "generic.followRange", + "1f1173-9999-3333-5555-99cb0245f9d0", + Version.V1_16_R3), + + GRAVITY( + "gravity", + "1f1173-9999-3333-5555-99cb0245f9d1", + Version.V1_20_R4), + + JUMP_STRENGTH( + "generic.jumpStrength", + "1f1173-9999-3333-5555-99cb0245f9d2", + Version.V1_16_R3, + "HORSE_JUMP_STRENGTH"), MOVEMENT_SPEED( "generic.movementSpeed", - (Attribute) VersionManager.getNms().getAttribute("MOVEMENT_SPEED"), - "1f1173-9999-3333-5555-99cb0245f9c5"), + "1f1173-9999-3333-5555-99cb0245f9c5", + Version.V1_16_R3), + + KNOCKBACK_RESISTANCE( + "generic.knockbackResistance", + "1f1173-9999-3333-5555-99cb0245f9c7", + Version.V1_16_R3), + + LUCK( + "luck", + "1f1173-9999-3333-5555-99cb0245f9d3", + Version.V1_21_R2), + + MAX_ABSORPTION( + "max_absorption", + "1f1173-9999-3333-5555-99cb0245f9d4", + Version.V1_20_R2), MAX_HEALTH( "generic.maxHealth", - (Attribute) VersionManager.getNms().getAttribute("MAX_HEALTH"), - "1f1173-9999-3333-5555-99cb0245f9c6"), + "1f1173-9999-3333-5555-99cb0245f9c6", + Version.V1_16_R3), - KNOCKBACK_RESISTANCE( - "generic.knockbackResistance", - (Attribute) VersionManager.getNms().getAttribute("KNOCKBACK_RESISTANCE"), - "1f1173-9999-3333-5555-99cb0245f9c7"), + MINING_EFFICIENCY( + "mining_efficiency", + "1f1173-9999-3333-5555-99cb0245f9d5", + Version.V1_21_R1), + + MOVEMENT_EFFICIENCY( + "movement_efficiency", + "1f1173-9999-3333-5555-99cb0245f9d6", + Version.V1_21_R1), + + OXYGEN_BONUS( + "oxygen_bonus", + "1f1173-9999-3333-5555-99cb0245f9d7", + Version.V1_21_R1), + + SAFE_FALL_DISTANCE( + "safe_fall_distance", + "1f1173-9999-3333-5555-99cb0245f9d8", + Version.V1_20_R4), + + SCALE( + "scale", + "1f1173-9999-3333-5555-99cb0245f9d9", + Version.V1_20_R4), + + SNEAKING_SPEED( + "sneaking_speed", + "1f1173-9999-3333-5555-99cb0245f9da", + Version.V1_21_R1), + + STEP_HEIGHT( + "step_height", + "1f1173-9999-3333-5555-99cb0245f9db", + Version.V1_20_R4), + + SUBMERGED_MINING_SPEED( + "submerged_mining_speed", + "1f1173-9999-3333-5555-99cb0245f9dc", + Version.V1_21_R1), + + SWEEPING_DAMAGE_RATIO( + "sweeping_damage_ratio", + "1f1173-9999-3333-5555-99cb0245f9dd", + Version.V1_21_R1), + + WATER_MOVEMENT_EFFICIENCY( + "water_movement_efficiency", + "1f1173-9999-3333-5555-99cb0245f9de", + Version.V1_21_R1), + + SPAWN_REINFORCEMENTS( + "zombie.spawnReinforcements", + "1f1173-9999-3333-5555-99cb0245f9df", + Version.V1_16_R3, + "ZOMBIE_SPAWN_REINFORCEMENTS"), ; private final String nmsName; - private final Attribute att; + private final Version introducedVersion; + private final String[] nmsLookupNames; + private Attribute att; private final String uuid; - NBTAttribute(@NotNull String nmsName, @NotNull Attribute att, @NotNull String uuid) { + NBTAttribute(@NotNull String nmsName, + @NotNull String uuid, + @NotNull Version introducedVersion, + @NotNull String... fallbacks) { this.nmsName = nmsName; - this.att = att; + this.introducedVersion = introducedVersion; + this.nmsLookupNames = new String[fallbacks.length + 1]; + this.nmsLookupNames[0] = this.name(); + System.arraycopy(fallbacks, 0, this.nmsLookupNames, 1, fallbacks.length); this.uuid = uuid; } @@ -61,7 +192,28 @@ public String getNmsName() { @NotNull public Attribute getAttribute() { - return this.att; + if (!Version.CURRENT.isAtLeast(this.introducedVersion)) { + throw new IllegalArgumentException("Attribute '" + this.name() + + "' is only supported from " + this.introducedVersion.name() + " and above."); + } + + if (this.att != null) return this.att; + + IllegalArgumentException last = null; + for (String lookupName : this.nmsLookupNames) { + try { + this.att = VersionManager.getNms().getAttribute(lookupName); + return this.att; + } catch (IllegalArgumentException ex) { + last = ex; + } + } + + if (last != null) { + throw new IllegalArgumentException("Unknown attribute mappings for '" + this.name() + "'.", last); + } + + throw new IllegalStateException("Could not resolve attribute mapping for '" + this.name() + "'."); } @NotNull From 0bfbf8ee95ced61d10de89172ea213a8389e310d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 25 Apr 2026 21:11:22 +0000 Subject: [PATCH 3/3] refactor: simplify unreachable NBTAttribute error path Agent-Logs-Url: https://github.com/magemonkeystudio/codex/sessions/120c674f-c88e-4983-bc39-0802adacf0da Co-authored-by: MaksyKun <77341370+MaksyKun@users.noreply.github.com> --- .../java/studio/magemonkey/codex/api/meta/NBTAttribute.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/codex-api/src/main/java/studio/magemonkey/codex/api/meta/NBTAttribute.java b/codex-api/src/main/java/studio/magemonkey/codex/api/meta/NBTAttribute.java index b4ef5b56..5e123b69 100644 --- a/codex-api/src/main/java/studio/magemonkey/codex/api/meta/NBTAttribute.java +++ b/codex-api/src/main/java/studio/magemonkey/codex/api/meta/NBTAttribute.java @@ -209,11 +209,7 @@ public Attribute getAttribute() { } } - if (last != null) { - throw new IllegalArgumentException("Unknown attribute mappings for '" + this.name() + "'.", last); - } - - throw new IllegalStateException("Could not resolve attribute mapping for '" + this.name() + "'."); + throw new IllegalArgumentException("Unknown attribute mappings for '" + this.name() + "'.", last); } @NotNull