SPIGOT-5336: Field name parity with Minecraft keys

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
Bukkit/Spigot 2024-04-24 01:15:00 +10:00
parent 60b9f5bacc
commit d9a704e3f6
7 changed files with 96 additions and 199 deletions

View File

@ -9,14 +9,14 @@ import org.jetbrains.annotations.Nullable;
public abstract class MusicInstrument implements Keyed { public abstract class MusicInstrument implements Keyed {
public static final MusicInstrument PONDER = getInstrument("ponder_goat_horn"); public static final MusicInstrument PONDER_GOAT_HORN = getInstrument("ponder_goat_horn");
public static final MusicInstrument SING = getInstrument("sing_goat_horn"); public static final MusicInstrument SING_GOAT_HORN = getInstrument("sing_goat_horn");
public static final MusicInstrument SEEK = getInstrument("seek_goat_horn"); public static final MusicInstrument SEEK_GOAT_HORN = getInstrument("seek_goat_horn");
public static final MusicInstrument FEEL = getInstrument("feel_goat_horn"); public static final MusicInstrument FEEL_GOAT_HORN = getInstrument("feel_goat_horn");
public static final MusicInstrument ADMIRE = getInstrument("admire_goat_horn"); public static final MusicInstrument ADMIRE_GOAT_HORN = getInstrument("admire_goat_horn");
public static final MusicInstrument CALL = getInstrument("call_goat_horn"); public static final MusicInstrument CALL_GOAT_HORN = getInstrument("call_goat_horn");
public static final MusicInstrument YEARN = getInstrument("yearn_goat_horn"); public static final MusicInstrument YEARN_GOAT_HORN = getInstrument("yearn_goat_horn");
public static final MusicInstrument DREAM = getInstrument("dream_goat_horn"); public static final MusicInstrument DREAM_GOAT_HORN = getInstrument("dream_goat_horn");
/** /**
* Returns a {@link MusicInstrument} by a {@link NamespacedKey}. * Returns a {@link MusicInstrument} by a {@link NamespacedKey}.

View File

@ -6,59 +6,53 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public enum Particle implements Keyed { public enum Particle implements Keyed {
EXPLOSION_NORMAL("poof"), POOF("poof"),
EXPLOSION_LARGE("explosion"), EXPLOSION("explosion"),
EXPLOSION_HUGE("explosion_emitter"), EXPLOSION_EMITTER("explosion_emitter"),
FIREWORKS_SPARK("firework"), FIREWORK("firework"),
WATER_BUBBLE("bubble"), BUBBLE("bubble"),
WATER_SPLASH("splash"), SPLASH("splash"),
WATER_WAKE("fishing"), FISHING("fishing"),
SUSPENDED("underwater"), UNDERWATER("underwater"),
SUSPENDED_DEPTH("underwater", false),
CRIT("crit"), CRIT("crit"),
CRIT_MAGIC("enchanted_hit"), ENCHANTED_HIT("enchanted_hit"),
SMOKE_NORMAL("smoke"), SMOKE("smoke"),
SMOKE_LARGE("large_smoke"), LARGE_SMOKE("large_smoke"),
SPELL("effect"), EFFECT("effect"),
SPELL_INSTANT("instant_effect"), INSTANT_EFFECT("instant_effect"),
/** /**
* Uses {@link Color} as DataType * Uses {@link Color} as DataType
*/ */
SPELL_MOB("entity_effect", Color.class), ENTITY_EFFECT("entity_effect", Color.class),
SPELL_WITCH("witch"), WITCH("witch"),
DRIP_WATER("dripping_water"), DRIPPING_WATER("dripping_water"),
DRIP_LAVA("dripping_lava"), DRIPPING_LAVA("dripping_lava"),
VILLAGER_ANGRY("angry_villager"), ANGRY_VILLAGER("angry_villager"),
VILLAGER_HAPPY("happy_villager"), HAPPY_VILLAGER("happy_villager"),
TOWN_AURA("mycelium"), MYCELIUM("mycelium"),
NOTE("note"), NOTE("note"),
PORTAL("portal"), PORTAL("portal"),
ENCHANTMENT_TABLE("enchant"), ENCHANT("enchant"),
FLAME("flame"), FLAME("flame"),
LAVA("lava"), LAVA("lava"),
CLOUD("cloud"), CLOUD("cloud"),
/** /**
* Uses {@link Particle.DustOptions} as DataType * Uses {@link Particle.DustOptions} as DataType
*/ */
REDSTONE("dust", DustOptions.class), DUST("dust", DustOptions.class),
SNOWBALL("item_snowball"), ITEM_SNOWBALL("item_snowball"),
SNOW_SHOVEL("item_snowball", false), ITEM_SLIME("item_slime"),
SLIME("item_slime"),
HEART("heart"), HEART("heart"),
/** /**
* Uses {@link ItemStack} as DataType * Uses {@link ItemStack} as DataType
*/ */
ITEM_CRACK("item", ItemStack.class), ITEM("item", ItemStack.class),
/** /**
* Uses {@link BlockData} as DataType * Uses {@link BlockData} as DataType
*/ */
BLOCK_CRACK("block", BlockData.class), BLOCK("block", BlockData.class),
/** RAIN("rain"),
* Uses {@link BlockData} as DataType ELDER_GUARDIAN("elder_guardian"),
*/
BLOCK_DUST("block", BlockData.class, false),
WATER_DROP("rain"),
MOB_APPEARANCE("elder_guardian"),
DRAGON_BREATH("dragon_breath"), DRAGON_BREATH("dragon_breath"),
END_ROD("end_rod"), END_ROD("end_rod"),
DAMAGE_INDICATOR("damage_indicator"), DAMAGE_INDICATOR("damage_indicator"),
@ -67,7 +61,7 @@ public enum Particle implements Keyed {
* Uses {@link BlockData} as DataType * Uses {@link BlockData} as DataType
*/ */
FALLING_DUST("falling_dust", BlockData.class), FALLING_DUST("falling_dust", BlockData.class),
TOTEM("totem_of_undying"), TOTEM_OF_UNDYING("totem_of_undying"),
SPIT("spit"), SPIT("spit"),
SQUID_INK("squid_ink"), SQUID_INK("squid_ink"),
BUBBLE_POP("bubble_pop"), BUBBLE_POP("bubble_pop"),

View File

@ -24,7 +24,7 @@ public enum PatternType implements Keyed {
STRIPE_MIDDLE("ms", "stripe_middle"), STRIPE_MIDDLE("ms", "stripe_middle"),
STRIPE_DOWNRIGHT("drs", "stripe_downright"), STRIPE_DOWNRIGHT("drs", "stripe_downright"),
STRIPE_DOWNLEFT("dls", "stripe_downleft"), STRIPE_DOWNLEFT("dls", "stripe_downleft"),
STRIPE_SMALL("ss", "small_stripes"), SMALL_STRIPES("ss", "small_stripes"),
CROSS("cr", "cross"), CROSS("cr", "cross"),
STRAIGHT_CROSS("sc", "straight_cross"), STRAIGHT_CROSS("sc", "straight_cross"),
TRIANGLE_BOTTOM("bt", "triangle_bottom"), TRIANGLE_BOTTOM("bt", "triangle_bottom"),
@ -32,15 +32,15 @@ public enum PatternType implements Keyed {
TRIANGLES_BOTTOM("bts", "triangles_bottom"), TRIANGLES_BOTTOM("bts", "triangles_bottom"),
TRIANGLES_TOP("tts", "triangles_top"), TRIANGLES_TOP("tts", "triangles_top"),
DIAGONAL_LEFT("ld", "diagonal_left"), DIAGONAL_LEFT("ld", "diagonal_left"),
DIAGONAL_RIGHT("rd", "diagonal_up_right"), //PAIL - Why are these keys swapped? DIAGONAL_UP_RIGHT("rd", "diagonal_up_right"),
DIAGONAL_LEFT_MIRROR("lud", "diagonal_up_left"), DIAGONAL_UP_LEFT("lud", "diagonal_up_left"),
DIAGONAL_RIGHT_MIRROR("rud", "diagonal_right"), //PAIL - Why are these keys swapped? DIAGONAL_RIGHT("rud", "diagonal_right"),
CIRCLE_MIDDLE("mc", "circle"), CIRCLE("mc", "circle"),
RHOMBUS_MIDDLE("mr", "rhombus"), RHOMBUS("mr", "rhombus"),
HALF_VERTICAL("vh", "half_vertical"), HALF_VERTICAL("vh", "half_vertical"),
HALF_HORIZONTAL("hh", "half_horizontal"), HALF_HORIZONTAL("hh", "half_horizontal"),
HALF_VERTICAL_MIRROR("vhr", "half_vertical_right"), HALF_VERTICAL_RIGHT("vhr", "half_vertical_right"),
HALF_HORIZONTAL_MIRROR("hhb", "half_horizontal_bottom"), HALF_HORIZONTAL_BOTTOM("hhb", "half_horizontal_bottom"),
BORDER("bo", "border"), BORDER("bo", "border"),
CURLY_BORDER("cbo", "curly_border"), CURLY_BORDER("cbo", "curly_border"),
CREEPER("cre", "creeper"), CREEPER("cre", "creeper"),

View File

@ -19,37 +19,37 @@ public abstract class Enchantment implements Keyed, Translatable {
/** /**
* Provides protection against environmental damage * Provides protection against environmental damage
*/ */
public static final Enchantment PROTECTION_ENVIRONMENTAL = getEnchantment("protection"); public static final Enchantment PROTECTION = getEnchantment("protection");
/** /**
* Provides protection against fire damage * Provides protection against fire damage
*/ */
public static final Enchantment PROTECTION_FIRE = getEnchantment("fire_protection"); public static final Enchantment FIRE_PROTECTION = getEnchantment("fire_protection");
/** /**
* Provides protection against fall damage * Provides protection against fall damage
*/ */
public static final Enchantment PROTECTION_FALL = getEnchantment("feather_falling"); public static final Enchantment FEATHER_FALLING = getEnchantment("feather_falling");
/** /**
* Provides protection against explosive damage * Provides protection against explosive damage
*/ */
public static final Enchantment PROTECTION_EXPLOSIONS = getEnchantment("blast_protection"); public static final Enchantment BLAST_PROTECTION = getEnchantment("blast_protection");
/** /**
* Provides protection against projectile damage * Provides protection against projectile damage
*/ */
public static final Enchantment PROTECTION_PROJECTILE = getEnchantment("projectile_protection"); public static final Enchantment PROJECTILE_PROTECTION = getEnchantment("projectile_protection");
/** /**
* Decreases the rate of air loss whilst underwater * Decreases the rate of air loss whilst underwater
*/ */
public static final Enchantment OXYGEN = getEnchantment("respiration"); public static final Enchantment RESPIRATION = getEnchantment("respiration");
/** /**
* Increases the speed at which a player may mine underwater * Increases the speed at which a player may mine underwater
*/ */
public static final Enchantment WATER_WORKER = getEnchantment("aqua_affinity"); public static final Enchantment AQUA_AFFINITY = getEnchantment("aqua_affinity");
/** /**
* Damages the attacker * Damages the attacker
@ -74,17 +74,17 @@ public abstract class Enchantment implements Keyed, Translatable {
/** /**
* Increases damage against all targets * Increases damage against all targets
*/ */
public static final Enchantment DAMAGE_ALL = getEnchantment("sharpness"); public static final Enchantment SHARPNESS = getEnchantment("sharpness");
/** /**
* Increases damage against undead targets * Increases damage against undead targets
*/ */
public static final Enchantment DAMAGE_UNDEAD = getEnchantment("smite"); public static final Enchantment SMITE = getEnchantment("smite");
/** /**
* Increases damage against arthropod targets * Increases damage against arthropod targets
*/ */
public static final Enchantment DAMAGE_ARTHROPODS = getEnchantment("bane_of_arthropods"); public static final Enchantment BANE_OF_ARTHROPODS = getEnchantment("bane_of_arthropods");
/** /**
* All damage to other targets will knock them back when hit * All damage to other targets will knock them back when hit
@ -99,7 +99,7 @@ public abstract class Enchantment implements Keyed, Translatable {
/** /**
* Provides a chance of gaining extra loot when killing monsters * Provides a chance of gaining extra loot when killing monsters
*/ */
public static final Enchantment LOOT_BONUS_MOBS = getEnchantment("looting"); public static final Enchantment LOOTING = getEnchantment("looting");
/** /**
* Increases damage against targets when using a sweep attack * Increases damage against targets when using a sweep attack
@ -109,7 +109,7 @@ public abstract class Enchantment implements Keyed, Translatable {
/** /**
* Increases the rate at which you mine/dig * Increases the rate at which you mine/dig
*/ */
public static final Enchantment DIG_SPEED = getEnchantment("efficiency"); public static final Enchantment EFFICIENCY = getEnchantment("efficiency");
/** /**
* Allows blocks to drop themselves instead of fragments (for example, * Allows blocks to drop themselves instead of fragments (for example,
@ -120,37 +120,37 @@ public abstract class Enchantment implements Keyed, Translatable {
/** /**
* Decreases the rate at which a tool looses durability * Decreases the rate at which a tool looses durability
*/ */
public static final Enchantment DURABILITY = getEnchantment("unbreaking"); public static final Enchantment UNBREAKING = getEnchantment("unbreaking");
/** /**
* Provides a chance of gaining extra loot when destroying blocks * Provides a chance of gaining extra loot when destroying blocks
*/ */
public static final Enchantment LOOT_BONUS_BLOCKS = getEnchantment("fortune"); public static final Enchantment FORTUNE = getEnchantment("fortune");
/** /**
* Provides extra damage when shooting arrows from bows * Provides extra damage when shooting arrows from bows
*/ */
public static final Enchantment ARROW_DAMAGE = getEnchantment("power"); public static final Enchantment POWER = getEnchantment("power");
/** /**
* Provides a knockback when an entity is hit by an arrow from a bow * Provides a knockback when an entity is hit by an arrow from a bow
*/ */
public static final Enchantment ARROW_KNOCKBACK = getEnchantment("punch"); public static final Enchantment PUNCH = getEnchantment("punch");
/** /**
* Sets entities on fire when hit by arrows shot from a bow * Sets entities on fire when hit by arrows shot from a bow
*/ */
public static final Enchantment ARROW_FIRE = getEnchantment("flame"); public static final Enchantment FLAME = getEnchantment("flame");
/** /**
* Provides infinite arrows when shooting a bow * Provides infinite arrows when shooting a bow
*/ */
public static final Enchantment ARROW_INFINITE = getEnchantment("infinity"); public static final Enchantment INFINITY = getEnchantment("infinity");
/** /**
* Decreases odds of catching worthless junk * Decreases odds of catching worthless junk
*/ */
public static final Enchantment LUCK = getEnchantment("luck_of_the_sea"); public static final Enchantment LUCK_OF_THE_SEA = getEnchantment("luck_of_the_sea");
/** /**
* Increases rate of fish biting your hook * Increases rate of fish biting your hook
@ -350,7 +350,6 @@ public abstract class Enchantment implements Keyed, Translatable {
return null; return null;
} }
name = convertLegacy(name);
return getByKey(NamespacedKey.fromString(name.toLowerCase())); return getByKey(NamespacedKey.fromString(name.toLowerCase()));
} }
@ -365,55 +364,4 @@ public abstract class Enchantment implements Keyed, Translatable {
public static Enchantment[] values() { public static Enchantment[] values() {
return Lists.newArrayList(Registry.ENCHANTMENT).toArray(new Enchantment[0]); return Lists.newArrayList(Registry.ENCHANTMENT).toArray(new Enchantment[0]);
} }
private static String convertLegacy(String from) {
if (from == null) {
return null;
}
switch (from.toLowerCase()) {
case "protection_environmental":
return "protection";
case "protection_fire":
return "fire_protection";
case "protection_fall":
return "feather_falling";
case "protection_explosions":
return "blast_protection";
case "protection_projectile":
return "projectile_protection";
case "oxygen":
return "respiration";
case "water_worker":
return "aqua_affinity";
case "damage_all":
return "sharpness";
case "damage_undead":
return "smite";
case "damage_arthropods":
return "bane_of_arthropods";
case "loot_bonus_mobs":
return "looting";
case "sweeping":
return "sweeping_edge";
case "dig_speed":
return "efficiency";
case "durability":
return "unbreaking";
case "loot_bonus_blocks":
return "fortune";
case "arrow_damage":
return "power";
case "arrow_knockback":
return "punch";
case "arrow_fire":
return "flame";
case "arrow_infinite":
return "infinity";
case "luck":
return "luck_of_the_sea";
}
return from;
}
} }

View File

@ -33,7 +33,7 @@ public enum EntityType implements Keyed, Translatable {
* Spawn with {@link World#dropItem(Location, ItemStack)} or {@link * Spawn with {@link World#dropItem(Location, ItemStack)} or {@link
* World#dropItemNaturally(Location, ItemStack)} * World#dropItemNaturally(Location, ItemStack)}
*/ */
DROPPED_ITEM("item", Item.class, 1, false), ITEM("item", Item.class, 1, false),
/** /**
* An experience orb. * An experience orb.
*/ */
@ -61,7 +61,7 @@ public enum EntityType implements Keyed, Translatable {
/** /**
* A leash attached to a fencepost. * A leash attached to a fencepost.
*/ */
LEASH_HITCH("leash_knot", LeashHitch.class, 8), LEASH_KNOT("leash_knot", LeashHitch.class, 8),
/** /**
* A painting on a wall. * A painting on a wall.
*/ */
@ -89,15 +89,15 @@ public enum EntityType implements Keyed, Translatable {
/** /**
* An ender eye signal. * An ender eye signal.
*/ */
ENDER_SIGNAL("eye_of_ender", EnderSignal.class, 15), EYE_OF_ENDER("eye_of_ender", EnderSignal.class, 15),
/** /**
* A flying splash potion. * A flying splash potion.
*/ */
SPLASH_POTION("potion", ThrownPotion.class, 16, false), POTION("potion", ThrownPotion.class, 16, false),
/** /**
* A flying experience bottle. * A flying experience bottle.
*/ */
THROWN_EXP_BOTTLE("experience_bottle", ThrownExpBottle.class, 17), EXPERIENCE_BOTTLE("experience_bottle", ThrownExpBottle.class, 17),
/** /**
* An item frame on a wall. * An item frame on a wall.
*/ */
@ -109,7 +109,7 @@ public enum EntityType implements Keyed, Translatable {
/** /**
* Primed TNT that is about to explode. * Primed TNT that is about to explode.
*/ */
PRIMED_TNT("tnt", TNTPrimed.class, 20), TNT("tnt", TNTPrimed.class, 20),
/** /**
* A block that is going to or is about to fall. * A block that is going to or is about to fall.
*/ */
@ -117,7 +117,7 @@ public enum EntityType implements Keyed, Translatable {
/** /**
* Internal representation of a Firework once it has been launched. * Internal representation of a Firework once it has been launched.
*/ */
FIREWORK("firework_rocket", Firework.class, 22, false), FIREWORK_ROCKET("firework_rocket", Firework.class, 22, false),
/** /**
* @see Husk * @see Husk
*/ */
@ -181,7 +181,7 @@ public enum EntityType implements Keyed, Translatable {
/** /**
* @see CommandMinecart * @see CommandMinecart
*/ */
MINECART_COMMAND("command_block_minecart", CommandMinecart.class, 40), COMMAND_BLOCK_MINECART("command_block_minecart", CommandMinecart.class, 40),
/** /**
* A placed boat. * A placed boat.
*/ */
@ -193,23 +193,23 @@ public enum EntityType implements Keyed, Translatable {
/** /**
* @see StorageMinecart * @see StorageMinecart
*/ */
MINECART_CHEST("chest_minecart", StorageMinecart.class, 43), CHEST_MINECART("chest_minecart", StorageMinecart.class, 43),
/** /**
* @see PoweredMinecart * @see PoweredMinecart
*/ */
MINECART_FURNACE("furnace_minecart", PoweredMinecart.class, 44), FURNACE_MINECART("furnace_minecart", PoweredMinecart.class, 44),
/** /**
* @see ExplosiveMinecart * @see ExplosiveMinecart
*/ */
MINECART_TNT("tnt_minecart", ExplosiveMinecart.class, 45), TNT_MINECART("tnt_minecart", ExplosiveMinecart.class, 45),
/** /**
* @see HopperMinecart * @see HopperMinecart
*/ */
MINECART_HOPPER("hopper_minecart", HopperMinecart.class, 46), HOPPER_MINECART("hopper_minecart", HopperMinecart.class, 46),
/** /**
* @see SpawnerMinecart * @see SpawnerMinecart
*/ */
MINECART_MOB_SPAWNER("spawner_minecart", SpawnerMinecart.class, 47), SPAWNER_MINECART("spawner_minecart", SpawnerMinecart.class, 47),
CREEPER("creeper", Creeper.class, 50), CREEPER("creeper", Creeper.class, 50),
SKELETON("skeleton", Skeleton.class, 51), SKELETON("skeleton", Skeleton.class, 51),
SPIDER("spider", Spider.class, 52), SPIDER("spider", Spider.class, 52),
@ -236,8 +236,8 @@ public enum EntityType implements Keyed, Translatable {
CHICKEN("chicken", Chicken.class, 93), CHICKEN("chicken", Chicken.class, 93),
SQUID("squid", Squid.class, 94), SQUID("squid", Squid.class, 94),
WOLF("wolf", Wolf.class, 95), WOLF("wolf", Wolf.class, 95),
MUSHROOM_COW("mooshroom", MushroomCow.class, 96), MOOSHROOM("mooshroom", MushroomCow.class, 96),
SNOWMAN("snow_golem", Snowman.class, 97), SNOW_GOLEM("snow_golem", Snowman.class, 97),
OCELOT("ocelot", Ocelot.class, 98), OCELOT("ocelot", Ocelot.class, 98),
IRON_GOLEM("iron_golem", IronGolem.class, 99), IRON_GOLEM("iron_golem", IronGolem.class, 99),
HORSE("horse", Horse.class, 100), HORSE("horse", Horse.class, 100),
@ -247,7 +247,7 @@ public enum EntityType implements Keyed, Translatable {
LLAMA_SPIT("llama_spit", LlamaSpit.class, 104), LLAMA_SPIT("llama_spit", LlamaSpit.class, 104),
PARROT("parrot", Parrot.class, 105), PARROT("parrot", Parrot.class, 105),
VILLAGER("villager", Villager.class, 120), VILLAGER("villager", Villager.class, 120),
ENDER_CRYSTAL("end_crystal", EnderCrystal.class, 200), END_CRYSTAL("end_crystal", EnderCrystal.class, 200),
TURTLE("turtle", Turtle.class, -1), TURTLE("turtle", Turtle.class, -1),
PHANTOM("phantom", Phantom.class, -1), PHANTOM("phantom", Phantom.class, -1),
TRIDENT("trident", Trident.class, -1), TRIDENT("trident", Trident.class, -1),
@ -305,13 +305,13 @@ public enum EntityType implements Keyed, Translatable {
/** /**
* A fishing line and bobber. * A fishing line and bobber.
*/ */
FISHING_HOOK("fishing_bobber", FishHook.class, -1, false), FISHING_BOBBER("fishing_bobber", FishHook.class, -1, false),
/** /**
* A bolt of lightning. * A bolt of lightning.
* <p> * <p>
* Spawn with {@link World#strikeLightning(Location)}. * Spawn with {@link World#strikeLightning(Location)}.
*/ */
LIGHTNING("lightning_bolt", LightningStrike.class, -1, false), LIGHTNING_BOLT("lightning_bolt", LightningStrike.class, -1, false),
PLAYER("player", Player.class, -1, false), PLAYER("player", Player.class, -1, false),
/** /**
* An unknown entity without an Entity Class * An unknown entity without an Entity Class
@ -336,21 +336,6 @@ public enum EntityType implements Keyed, Translatable {
ID_MAP.put(type.typeId, type); ID_MAP.put(type.typeId, type);
} }
} }
// Add legacy names
NAME_MAP.put("xp_orb", EXPERIENCE_ORB);
NAME_MAP.put("eye_of_ender_signal", ENDER_SIGNAL);
NAME_MAP.put("xp_bottle", THROWN_EXP_BOTTLE);
NAME_MAP.put("fireworks_rocket", FIREWORK);
NAME_MAP.put("evocation_fangs", EVOKER_FANGS);
NAME_MAP.put("evocation_illager", EVOKER);
NAME_MAP.put("vindication_illager", VINDICATOR);
NAME_MAP.put("illusion_illager", ILLUSIONER);
NAME_MAP.put("commandblock_minecart", MINECART_COMMAND);
NAME_MAP.put("snowman", SNOWMAN);
NAME_MAP.put("villager_golem", IRON_GOLEM);
NAME_MAP.put("ender_crystal", ENDER_CRYSTAL);
NAME_MAP.put("zombie_pigman", ZOMBIFIED_PIGLIN);
} }
private EntityType(/*@Nullable*/ String name, /*@Nullable*/ Class<? extends Entity> clazz, int typeId) { private EntityType(/*@Nullable*/ String name, /*@Nullable*/ Class<? extends Entity> clazz, int typeId) {

View File

@ -27,42 +27,42 @@ public abstract class PotionEffectType implements Keyed, Translatable {
/** /**
* Decreases movement speed. * Decreases movement speed.
*/ */
public static final PotionEffectType SLOW = getPotionEffectType(2, "slowness"); public static final PotionEffectType SLOWNESS = getPotionEffectType(2, "slowness");
/** /**
* Increases dig speed. * Increases dig speed.
*/ */
public static final PotionEffectType FAST_DIGGING = getPotionEffectType(3, "haste"); public static final PotionEffectType HASTE = getPotionEffectType(3, "haste");
/** /**
* Decreases dig speed. * Decreases dig speed.
*/ */
public static final PotionEffectType SLOW_DIGGING = getPotionEffectType(4, "mining_fatigue"); public static final PotionEffectType MINING_FATIGUE = getPotionEffectType(4, "mining_fatigue");
/** /**
* Increases damage dealt. * Increases damage dealt.
*/ */
public static final PotionEffectType INCREASE_DAMAGE = getPotionEffectType(5, "strength"); public static final PotionEffectType STRENGTH = getPotionEffectType(5, "strength");
/** /**
* Heals an entity. * Heals an entity.
*/ */
public static final PotionEffectType HEAL = getPotionEffectType(6, "instant_health"); public static final PotionEffectType INSTANT_HEALTH = getPotionEffectType(6, "instant_health");
/** /**
* Hurts an entity. * Hurts an entity.
*/ */
public static final PotionEffectType HARM = getPotionEffectType(7, "instant_damage"); public static final PotionEffectType INSTANT_DAMAGE = getPotionEffectType(7, "instant_damage");
/** /**
* Increases jump height. * Increases jump height.
*/ */
public static final PotionEffectType JUMP = getPotionEffectType(8, "jump_boost"); public static final PotionEffectType JUMP_BOOST = getPotionEffectType(8, "jump_boost");
/** /**
* Warps vision on the client. * Warps vision on the client.
*/ */
public static final PotionEffectType CONFUSION = getPotionEffectType(9, "nausea"); public static final PotionEffectType NAUSEA = getPotionEffectType(9, "nausea");
/** /**
* Regenerates health. * Regenerates health.
@ -72,7 +72,7 @@ public abstract class PotionEffectType implements Keyed, Translatable {
/** /**
* Decreases damage dealt to an entity. * Decreases damage dealt to an entity.
*/ */
public static final PotionEffectType DAMAGE_RESISTANCE = getPotionEffectType(11, "resistance"); public static final PotionEffectType RESISTANCE = getPotionEffectType(11, "resistance");
/** /**
* Stops fire damage. * Stops fire damage.
@ -340,7 +340,6 @@ public abstract class PotionEffectType implements Keyed, Translatable {
@Deprecated @Deprecated
public static PotionEffectType getByName(@NotNull String name) { public static PotionEffectType getByName(@NotNull String name) {
Preconditions.checkArgument(name != null, "name cannot be null"); Preconditions.checkArgument(name != null, "name cannot be null");
name = convertLegacy(name);
return Registry.EFFECT.get(NamespacedKey.fromString(name.toLowerCase(java.util.Locale.ENGLISH))); return Registry.EFFECT.get(NamespacedKey.fromString(name.toLowerCase(java.util.Locale.ENGLISH)));
} }
@ -353,33 +352,4 @@ public abstract class PotionEffectType implements Keyed, Translatable {
public static PotionEffectType[] values() { public static PotionEffectType[] values() {
return Lists.newArrayList(Registry.EFFECT).toArray(new PotionEffectType[0]); return Lists.newArrayList(Registry.EFFECT).toArray(new PotionEffectType[0]);
} }
private static String convertLegacy(String from) {
if (from == null) {
return null;
}
switch (from.toLowerCase()) {
case "slow":
return "slowness";
case "fast_digging":
return "haste";
case "slow_digging":
return "mining_fatigue";
case "increase_damage":
return "strength";
case "heal":
return "instant_health";
case "harm":
return "instant_damage";
case "jump":
return "jump_boost";
case "confusion":
return "nausea";
case "damage_resistance":
return "resistance";
}
return from;
}
} }

View File

@ -24,12 +24,12 @@ public enum PotionType implements Keyed {
LONG_NIGHT_VISION("long_night_vision"), LONG_NIGHT_VISION("long_night_vision"),
INVISIBILITY("invisibility"), INVISIBILITY("invisibility"),
LONG_INVISIBILITY("long_invisibility"), LONG_INVISIBILITY("long_invisibility"),
JUMP("leaping"), LEAPING("leaping"),
LONG_LEAPING("long_leaping"), LONG_LEAPING("long_leaping"),
STRONG_LEAPING("strong_leaping"), STRONG_LEAPING("strong_leaping"),
FIRE_RESISTANCE("fire_resistance"), FIRE_RESISTANCE("fire_resistance"),
LONG_FIRE_RESISTANCE("long_fire_resistance"), LONG_FIRE_RESISTANCE("long_fire_resistance"),
SPEED("swiftness"), SWIFTNESS("swiftness"),
LONG_SWIFTNESS("long_swiftness"), LONG_SWIFTNESS("long_swiftness"),
STRONG_SWIFTNESS("strong_swiftness"), STRONG_SWIFTNESS("strong_swiftness"),
SLOWNESS("slowness"), SLOWNESS("slowness"),
@ -37,14 +37,14 @@ public enum PotionType implements Keyed {
STRONG_SLOWNESS("strong_slowness"), STRONG_SLOWNESS("strong_slowness"),
WATER_BREATHING("water_breathing"), WATER_BREATHING("water_breathing"),
LONG_WATER_BREATHING("long_water_breathing"), LONG_WATER_BREATHING("long_water_breathing"),
INSTANT_HEAL("healing"), HEALING("healing"),
STRONG_HEALING("strong_healing"), STRONG_HEALING("strong_healing"),
INSTANT_DAMAGE("harming"), HARMING("harming"),
STRONG_HARMING("strong_harming"), STRONG_HARMING("strong_harming"),
POISON("poison"), POISON("poison"),
LONG_POISON("long_poison"), LONG_POISON("long_poison"),
STRONG_POISON("strong_poison"), STRONG_POISON("strong_poison"),
REGEN("regeneration"), REGENERATION("regeneration"),
LONG_REGENERATION("long_regeneration"), LONG_REGENERATION("long_regeneration"),
STRONG_REGENERATION("strong_regeneration"), STRONG_REGENERATION("strong_regeneration"),
STRENGTH("strength"), STRENGTH("strength"),