From d691096ce122a78a76590c29bef2ed73422f8b02 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 4 May 2024 18:40:44 +0200 Subject: [PATCH] Move around types, apply to other enums This doesn't include ALL abstract types, mostly if they are single-use or not at all relevant to our handling and most likely never will --- .../minecraft/entities/EntityTypes1_14.java | 379 ++++++++-------- .../minecraft/entities/EntityTypes1_15.java | 382 ++++++++-------- .../minecraft/entities/EntityTypes1_16.java | 391 +++++++++-------- .../minecraft/entities/EntityTypes1_16_2.java | 400 ++++++++--------- .../minecraft/entities/EntityTypes1_17.java | 409 +++++++++--------- .../minecraft/entities/EntityTypes1_19.java | 273 ++++++------ .../minecraft/entities/EntityTypes1_19_3.java | 275 ++++++------ .../minecraft/entities/EntityTypes1_19_4.java | 285 ++++++------ .../minecraft/entities/EntityTypes1_20_3.java | 287 ++++++------ .../minecraft/entities/EntityTypes1_20_5.java | 289 ++++++------- .../viaversion/util/EntityTypeUtil.java | 8 +- .../Protocol1_14To1_13_2.java | 2 + .../MetadataRewriter1_14To1_13_2.java | 17 +- .../Protocol1_15To1_14_4.java | 2 + .../Protocol1_16_2To1_16_1.java | 2 + .../MetadataRewriter1_16_2To1_16_1.java | 7 +- .../Protocol1_16To1_15_2.java | 1 + .../MetadataRewriter1_16To1_15_2.java | 8 +- .../Protocol1_17To1_16_4.java | 1 + .../packets/EntityPackets.java | 7 +- .../viaversion/rewriter/EntityRewriter.java | 24 - .../viaversion/data/identifiers-1.13.2.nbt | Bin 192 -> 520 bytes .../viaversion/data/identifiers-1.13.nbt | Bin 94 -> 94 bytes .../viaversion/data/identifiers-1.14.nbt | Bin 570 -> 882 bytes .../viaversion/data/identifiers-1.15.nbt | Bin 594 -> 898 bytes .../viaversion/data/identifiers-1.16.2.nbt | Bin 1394 -> 1482 bytes .../viaversion/data/identifiers-1.16.nbt | Bin 1210 -> 1306 bytes .../viaversion/data/identifiers-1.17.nbt | Bin 2594 -> 2640 bytes .../viaversion/data/identifiers-1.18.nbt | Bin 2707 -> 2707 bytes .../viaversion/data/identifiers-1.19.3.nbt | Bin 3583 -> 3583 bytes .../viaversion/data/identifiers-1.19.4.nbt | Bin 4215 -> 4215 bytes .../viaversion/data/identifiers-1.19.nbt | Bin 3444 -> 3444 bytes .../viaversion/data/identifiers-1.20.2.nbt | Bin 4287 -> 4287 bytes .../viaversion/data/identifiers-1.20.3.nbt | Bin 4568 -> 4568 bytes .../viaversion/data/identifiers-1.20.5.nbt | Bin 4840 -> 4840 bytes .../viaversion/data/identifiers-1.20.nbt | Bin 4287 -> 4287 bytes .../viaversion/data/mappings-1.13.2to1.14.nbt | Bin 2103 -> 2231 bytes .../viaversion/data/mappings-1.14to1.15.nbt | Bin 456 -> 528 bytes .../viaversion/data/mappings-1.15to1.16.nbt | Bin 8553 -> 8833 bytes .../viaversion/data/mappings-1.16.2to1.17.nbt | Bin 4688 -> 4776 bytes .../viaversion/data/mappings-1.16to1.16.2.nbt | Bin 560 -> 632 bytes .../common/entities/EntityTypesTest.java | 52 --- 42 files changed, 1740 insertions(+), 1761 deletions(-) delete mode 100644 common/src/test/java/com/viaversion/viaversion/common/entities/EntityTypesTest.java diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_14.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_14.java index 7ff046ccb..9d16033f1 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_14.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_14.java @@ -22,223 +22,232 @@ */ package com.viaversion.viaversion.api.minecraft.entities; +import com.google.common.base.Preconditions; +import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.util.EntityTypeUtil; +import java.util.Locale; +import org.checkerframework.checker.nullness.qual.Nullable; public enum EntityTypes1_14 implements EntityType { - ENTITY(-1), + ENTITY(null, null), - AREA_EFFECT_CLOUD(0, ENTITY), - END_CRYSTAL(17, ENTITY), - EVOKER_FANGS(21, ENTITY), - EXPERIENCE_ORB(23, ENTITY), - EYE_OF_ENDER(24, ENTITY), - FALLING_BLOCK(25, ENTITY), - FIREWORK_ROCKET(26, ENTITY), - ITEM(34, ENTITY), - LLAMA_SPIT(39, ENTITY), - TNT(58, ENTITY), - SHULKER_BULLET(63, ENTITY), - FISHING_BOBBER(101, ENTITY), + AREA_EFFECT_CLOUD(ENTITY), + END_CRYSTAL(ENTITY), + EVOKER_FANGS(ENTITY), + EXPERIENCE_ORB(ENTITY), + EYE_OF_ENDER(ENTITY), + FALLING_BLOCK(ENTITY), + ITEM(ENTITY), + TNT(ENTITY), + LIGHTNING_BOLT(ENTITY), - LIVINGENTITY(-1, ENTITY), - ARMOR_STAND(1, LIVINGENTITY), - PLAYER(100, LIVINGENTITY), - - ABSTRACT_INSENTIENT(-1, LIVINGENTITY), - ENDER_DRAGON(18, ABSTRACT_INSENTIENT), - - ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT), - - ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE), - VILLAGER(84, ABSTRACT_AGEABLE), - WANDERING_TRADER(88, ABSTRACT_AGEABLE), - - // Animals - ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE), - DOLPHIN(13, ABSTRACT_INSENTIENT), - CHICKEN(8, ABSTRACT_ANIMAL), - COW(10, ABSTRACT_ANIMAL), - MOOSHROOM(49, COW), - PANDA(52, ABSTRACT_INSENTIENT), - PIG(54, ABSTRACT_ANIMAL), - POLAR_BEAR(57, ABSTRACT_ANIMAL), - RABBIT(59, ABSTRACT_ANIMAL), - SHEEP(61, ABSTRACT_ANIMAL), - TURTLE(77, ABSTRACT_ANIMAL), - FOX(27, ABSTRACT_ANIMAL), - - ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL), - CAT(6, ABSTRACT_TAMEABLE_ANIMAL), - OCELOT(50, ABSTRACT_TAMEABLE_ANIMAL), - WOLF(93, ABSTRACT_TAMEABLE_ANIMAL), - - ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL), - PARROT(53, ABSTRACT_PARROT), - - // Horses - ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL), - CHESTED_HORSE(-1, ABSTRACT_HORSE), - DONKEY(12, CHESTED_HORSE), - MULE(48, CHESTED_HORSE), - LLAMA(38, CHESTED_HORSE), - TRADER_LLAMA(75, CHESTED_HORSE), - HORSE(31, ABSTRACT_HORSE), - SKELETON_HORSE(66, ABSTRACT_HORSE), - ZOMBIE_HORSE(95, ABSTRACT_HORSE), - - // Golem - ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE), - SNOW_GOLEM(69, ABSTRACT_GOLEM), - IRON_GOLEM(85, ABSTRACT_GOLEM), - SHULKER(62, ABSTRACT_GOLEM), - - // Fish - ABSTRACT_FISHES(-1, ABSTRACT_CREATURE), - COD(9, ABSTRACT_FISHES), - PUFFERFISH(55, ABSTRACT_FISHES), - SALMON(60, ABSTRACT_FISHES), - TROPICAL_FISH(76, ABSTRACT_FISHES), - - // Monsters - ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE), - BLAZE(4, ABSTRACT_MONSTER), - CREEPER(11, ABSTRACT_MONSTER), - ENDERMITE(20, ABSTRACT_MONSTER), - ENDERMAN(19, ABSTRACT_MONSTER), - GIANT(29, ABSTRACT_MONSTER), - SILVERFISH(64, ABSTRACT_MONSTER), - VEX(83, ABSTRACT_MONSTER), - WITCH(89, ABSTRACT_MONSTER), - WITHER(90, ABSTRACT_MONSTER), - RAVAGER(98, ABSTRACT_MONSTER), - - // Illagers - ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER), - ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE), - EVOKER(22, ABSTRACT_EVO_ILLU_ILLAGER), - ILLUSIONER(33, ABSTRACT_EVO_ILLU_ILLAGER), - VINDICATOR(86, ABSTRACT_ILLAGER_BASE), - PILLAGER(87, ABSTRACT_ILLAGER_BASE), - - // Skeletons - ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER), - SKELETON(65, ABSTRACT_SKELETON), - STRAY(74, ABSTRACT_SKELETON), - WITHER_SKELETON(91, ABSTRACT_SKELETON), - - // Guardians - GUARDIAN(30, ABSTRACT_MONSTER), - ELDER_GUARDIAN(16, GUARDIAN), - - // Spiders - SPIDER(72, ABSTRACT_MONSTER), - CAVE_SPIDER(7, SPIDER), - - // Zombies - META CHECKED - ZOMBIE(94, ABSTRACT_MONSTER), - DROWNED(15, ZOMBIE), - HUSK(32, ZOMBIE), - ZOMBIE_PIGMAN(56, ZOMBIE), - ZOMBIE_VILLAGER(96, ZOMBIE), - - // Flying entities - ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT), - GHAST(28, ABSTRACT_FLYING), - PHANTOM(97, ABSTRACT_FLYING), - - ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT), - BAT(3, ABSTRACT_AMBIENT), - - ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT), - SQUID(73, ABSTRACT_WATERMOB), - - // Slimes - SLIME(67, ABSTRACT_INSENTIENT), - MAGMA_CUBE(40, SLIME), - - // Hangable objects - ABSTRACT_HANGING(-1, ENTITY), - LEASH_KNOT(37, ABSTRACT_HANGING), - ITEM_FRAME(35, ABSTRACT_HANGING), - PAINTING(51, ABSTRACT_HANGING), - - ABSTRACT_LIGHTNING(-1, ENTITY), - LIGHTNING_BOLT(99, ABSTRACT_LIGHTNING), - - // Arrows - ABSTRACT_ARROW(-1, ENTITY), - ARROW(2, ABSTRACT_ARROW), - SPECTRAL_ARROW(71, ABSTRACT_ARROW), - TRIDENT(82, ABSTRACT_ARROW), - - // Fireballs - ABSTRACT_FIREBALL(-1, ENTITY), - DRAGON_FIREBALL(14, ABSTRACT_FIREBALL), - FIREBALL(36, ABSTRACT_FIREBALL), - SMALL_FIREBALL(68, ABSTRACT_FIREBALL), - WITHER_SKULL(92, ABSTRACT_FIREBALL), + // Hanging entities + ABSTRACT_HANGING(ENTITY, null), + LEASH_KNOT(ABSTRACT_HANGING), + PAINTING(ABSTRACT_HANGING), + ITEM_FRAME(ABSTRACT_HANGING), // Projectiles - PROJECTILE_ABSTRACT(-1, ENTITY), - SNOWBALL(70, PROJECTILE_ABSTRACT), - ENDER_PEARL(79, PROJECTILE_ABSTRACT), - EGG(78, PROJECTILE_ABSTRACT), - POTION(81, PROJECTILE_ABSTRACT), - EXPERIENCE_BOTTLE(80, PROJECTILE_ABSTRACT), + PROJECTILE_ABSTRACT(ENTITY, null), // Not actually its own abstract type, but useful for categorizing + SNOWBALL(PROJECTILE_ABSTRACT), + ENDER_PEARL(PROJECTILE_ABSTRACT), + EGG(PROJECTILE_ABSTRACT), + POTION(PROJECTILE_ABSTRACT), + EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), + FIREWORK_ROCKET(PROJECTILE_ABSTRACT), + LLAMA_SPIT(PROJECTILE_ABSTRACT), + SHULKER_BULLET(PROJECTILE_ABSTRACT), + FISHING_BOBBER(PROJECTILE_ABSTRACT), + WITHER_SKULL(PROJECTILE_ABSTRACT), + DRAGON_FIREBALL(PROJECTILE_ABSTRACT), // Doesn't actually inherit fireball + + ABSTRACT_ARROW(PROJECTILE_ABSTRACT, null), + ARROW(ABSTRACT_ARROW), + SPECTRAL_ARROW(ABSTRACT_ARROW), + TRIDENT(ABSTRACT_ARROW), + + ABSTRACT_FIREBALL(ENTITY, null), + FIREBALL(ABSTRACT_FIREBALL), + SMALL_FIREBALL(ABSTRACT_FIREBALL), // Vehicles - MINECART_ABSTRACT(-1, ENTITY), - CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT), - CHEST_MINECART(42, CHESTED_MINECART_ABSTRACT), - HOPPER_MINECART(45, CHESTED_MINECART_ABSTRACT), - MINECART(41, MINECART_ABSTRACT), - FURNACE_MINECART(44, MINECART_ABSTRACT), - COMMAND_BLOCK_MINECART(43, MINECART_ABSTRACT), - TNT_MINECART(47, MINECART_ABSTRACT), - SPAWNER_MINECART(46, MINECART_ABSTRACT), - BOAT(5, ENTITY); + VEHICLE(ENTITY, null), + BOAT(VEHICLE), - private static final EntityType[] TYPES; + MINECART_ABSTRACT(VEHICLE, null), + MINECART(MINECART_ABSTRACT), + FURNACE_MINECART(MINECART_ABSTRACT), + COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), + TNT_MINECART(MINECART_ABSTRACT), + SPAWNER_MINECART(MINECART_ABSTRACT), - private final int id; + CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), + CHEST_MINECART(CHESTED_MINECART_ABSTRACT), + HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), + + // Living entities as a larger subclass + LIVINGENTITY(ENTITY, null), + ARMOR_STAND(LIVINGENTITY), + PLAYER(LIVINGENTITY), + + // Mobs as a larger subclass + ABSTRACT_INSENTIENT(LIVINGENTITY, null), + ENDER_DRAGON(ABSTRACT_INSENTIENT), + + SLIME(ABSTRACT_INSENTIENT), + MAGMA_CUBE(SLIME), + + // Ambient mobs + ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), + BAT(ABSTRACT_AMBIENT), + + // Flying mobs + ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), + GHAST(ABSTRACT_FLYING), + PHANTOM(ABSTRACT_FLYING), + + // Pathfinder mobs and its subclasses + ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null), + + ABSTRACT_GOLEM(ABSTRACT_CREATURE, null), + SNOW_GOLEM(ABSTRACT_GOLEM), + IRON_GOLEM(ABSTRACT_GOLEM), + SHULKER(ABSTRACT_GOLEM), + + // Water mobs + ABSTRACT_WATERMOB(ABSTRACT_CREATURE, null), + DOLPHIN(ABSTRACT_WATERMOB), + SQUID(ABSTRACT_WATERMOB), + + ABSTRACT_FISHES(ABSTRACT_WATERMOB, null), + PUFFERFISH(ABSTRACT_FISHES), + + ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISHES, null), + COD(ABSTRACT_SCHOOLING_FISH), + SALMON(ABSTRACT_SCHOOLING_FISH), + TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH), + + // Ageable mobs and (tamable) animals + ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), + ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null), + VILLAGER(ABSTRACT_VILLAGER), + WANDERING_TRADER(ABSTRACT_VILLAGER), + + ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), + CHICKEN(ABSTRACT_ANIMAL), + PANDA(ABSTRACT_ANIMAL), + PIG(ABSTRACT_ANIMAL), + POLAR_BEAR(ABSTRACT_ANIMAL), + RABBIT(ABSTRACT_ANIMAL), + SHEEP(ABSTRACT_ANIMAL), + TURTLE(ABSTRACT_ANIMAL), + FOX(ABSTRACT_ANIMAL), + + COW(ABSTRACT_ANIMAL), + MOOSHROOM(COW), + + ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), + CAT(ABSTRACT_TAMEABLE_ANIMAL), + OCELOT(ABSTRACT_TAMEABLE_ANIMAL), + WOLF(ABSTRACT_TAMEABLE_ANIMAL), + PARROT(ABSTRACT_TAMEABLE_ANIMAL), + + ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), + HORSE(ABSTRACT_HORSE), + SKELETON_HORSE(ABSTRACT_HORSE), + ZOMBIE_HORSE(ABSTRACT_HORSE), + + CHESTED_HORSE(ABSTRACT_HORSE, null), + DONKEY(CHESTED_HORSE), + MULE(CHESTED_HORSE), + LLAMA(CHESTED_HORSE), + TRADER_LLAMA(LLAMA), + + // Monsters + ABSTRACT_MONSTER(ABSTRACT_CREATURE, null), + BLAZE(ABSTRACT_MONSTER), + CREEPER(ABSTRACT_MONSTER), + ENDERMITE(ABSTRACT_MONSTER), + ENDERMAN(ABSTRACT_MONSTER), + GIANT(ABSTRACT_MONSTER), + SILVERFISH(ABSTRACT_MONSTER), + VEX(ABSTRACT_MONSTER), + WITHER(ABSTRACT_MONSTER), + + ABSTRACT_SKELETON(ABSTRACT_MONSTER, null), + SKELETON(ABSTRACT_SKELETON), + STRAY(ABSTRACT_SKELETON), + WITHER_SKELETON(ABSTRACT_SKELETON), + + ZOMBIE(ABSTRACT_MONSTER), + DROWNED(ZOMBIE), + HUSK(ZOMBIE), + ZOMBIE_PIGMAN(ZOMBIE), + ZOMBIE_VILLAGER(ZOMBIE), + + GUARDIAN(ABSTRACT_MONSTER), + ELDER_GUARDIAN(GUARDIAN), + + SPIDER(ABSTRACT_MONSTER), + CAVE_SPIDER(SPIDER), + + // Raiders + ABSTRACT_RAIDER(ABSTRACT_MONSTER, null), + WITCH(ABSTRACT_RAIDER), + RAVAGER(ABSTRACT_RAIDER), + + ABSTRACT_ILLAGER_BASE(ABSTRACT_RAIDER, null), + ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), + VINDICATOR(ABSTRACT_ILLAGER_BASE), + PILLAGER(ABSTRACT_ILLAGER_BASE), + EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), + ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER); + + private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values()); private final EntityType parent; + private final String identifier; + private int id = -1; - EntityTypes1_14(int id) { - this.id = id; - this.parent = null; + EntityTypes1_14(final EntityType parent) { + this.parent = parent; + this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); } - EntityTypes1_14(int id, EntityType parent) { - this.id = id; + EntityTypes1_14(final EntityType parent, @Nullable final String identifier) { this.parent = parent; + this.identifier = identifier; } @Override public int getId() { + if (id == -1) { + throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")"); + } return id; } @Override - public EntityType getParent() { + public String identifier() { + Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type"); + return identifier; + } + + @Override + public @Nullable EntityType getParent() { return parent; } - @Override - public String identifier() { - throw new UnsupportedOperationException(); - } - @Override public boolean isAbstractType() { - return id != -1; + return identifier == null; } - static { - TYPES = EntityTypeUtil.toOrderedArray(values()); - } - - public static EntityType getTypeFromId(int typeId) { + public static EntityType getTypeFromId(final int typeId) { return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY); } + + public static void initialize(final Protocol protocol) { + EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id); + } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_15.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_15.java index 47be06ca0..ecdf1fcde 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_15.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_15.java @@ -22,225 +22,233 @@ */ package com.viaversion.viaversion.api.minecraft.entities; +import com.google.common.base.Preconditions; +import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.util.EntityTypeUtil; +import java.util.Locale; +import org.checkerframework.checker.nullness.qual.Nullable; public enum EntityTypes1_15 implements EntityType { - ENTITY(-1), + ENTITY(null, null), - AREA_EFFECT_CLOUD(0, ENTITY), - END_CRYSTAL(18, ENTITY), - EVOKER_FANGS(22, ENTITY), - EXPERIENCE_ORB(24, ENTITY), - EYE_OF_ENDER(25, ENTITY), - FALLING_BLOCK(26, ENTITY), - FIREWORK_ROCKET(27, ENTITY), - ITEM(35, ENTITY), - LLAMA_SPIT(40, ENTITY), - TNT(59, ENTITY), - SHULKER_BULLET(64, ENTITY), - FISHING_BOBBER(102, ENTITY), + AREA_EFFECT_CLOUD(ENTITY), + END_CRYSTAL(ENTITY), + EVOKER_FANGS(ENTITY), + EXPERIENCE_ORB(ENTITY), + EYE_OF_ENDER(ENTITY), + FALLING_BLOCK(ENTITY), + ITEM(ENTITY), + TNT(ENTITY), + LIGHTNING_BOLT(ENTITY), - LIVINGENTITY(-1, ENTITY), - ARMOR_STAND(1, LIVINGENTITY), - PLAYER(101, LIVINGENTITY), - - ABSTRACT_INSENTIENT(-1, LIVINGENTITY), - ENDER_DRAGON(19, ABSTRACT_INSENTIENT), - - BEE(4, ABSTRACT_INSENTIENT), - - ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT), - - ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE), - VILLAGER(85, ABSTRACT_AGEABLE), - WANDERING_TRADER(89, ABSTRACT_AGEABLE), - - // Animals - ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE), - DOLPHIN(14, ABSTRACT_INSENTIENT), - CHICKEN(9, ABSTRACT_ANIMAL), - COW(11, ABSTRACT_ANIMAL), - MOOSHROOM(50, COW), - PANDA(53, ABSTRACT_INSENTIENT), - PIG(55, ABSTRACT_ANIMAL), - POLAR_BEAR(58, ABSTRACT_ANIMAL), - RABBIT(60, ABSTRACT_ANIMAL), - SHEEP(62, ABSTRACT_ANIMAL), - TURTLE(78, ABSTRACT_ANIMAL), - FOX(28, ABSTRACT_ANIMAL), - - ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL), - CAT(7, ABSTRACT_TAMEABLE_ANIMAL), - OCELOT(51, ABSTRACT_TAMEABLE_ANIMAL), - WOLF(94, ABSTRACT_TAMEABLE_ANIMAL), - - ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL), - PARROT(54, ABSTRACT_PARROT), - - // Horses - ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL), - CHESTED_HORSE(-1, ABSTRACT_HORSE), - DONKEY(13, CHESTED_HORSE), - MULE(49, CHESTED_HORSE), - LLAMA(39, CHESTED_HORSE), - TRADER_LLAMA(76, CHESTED_HORSE), - HORSE(32, ABSTRACT_HORSE), - SKELETON_HORSE(67, ABSTRACT_HORSE), - ZOMBIE_HORSE(96, ABSTRACT_HORSE), - - // Golem - ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE), - SNOW_GOLEM(70, ABSTRACT_GOLEM), - IRON_GOLEM(86, ABSTRACT_GOLEM), - SHULKER(63, ABSTRACT_GOLEM), - - // Fish - ABSTRACT_FISHES(-1, ABSTRACT_CREATURE), - COD(10, ABSTRACT_FISHES), - PUFFERFISH(56, ABSTRACT_FISHES), - SALMON(61, ABSTRACT_FISHES), - TROPICAL_FISH(77, ABSTRACT_FISHES), - - // Monsters - ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE), - BLAZE(5, ABSTRACT_MONSTER), - CREEPER(12, ABSTRACT_MONSTER), - ENDERMITE(21, ABSTRACT_MONSTER), - ENDERMAN(20, ABSTRACT_MONSTER), - GIANT(30, ABSTRACT_MONSTER), - SILVERFISH(65, ABSTRACT_MONSTER), - VEX(84, ABSTRACT_MONSTER), - WITCH(90, ABSTRACT_MONSTER), - WITHER(91, ABSTRACT_MONSTER), - RAVAGER(99, ABSTRACT_MONSTER), - - // Illagers - ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER), - ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE), - EVOKER(23, ABSTRACT_EVO_ILLU_ILLAGER), - ILLUSIONER(34, ABSTRACT_EVO_ILLU_ILLAGER), - VINDICATOR(87, ABSTRACT_ILLAGER_BASE), - PILLAGER(88, ABSTRACT_ILLAGER_BASE), - - // Skeletons - ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER), - SKELETON(66, ABSTRACT_SKELETON), - STRAY(75, ABSTRACT_SKELETON), - WITHER_SKELETON(92, ABSTRACT_SKELETON), - - // Guardians - GUARDIAN(31, ABSTRACT_MONSTER), - ELDER_GUARDIAN(17, GUARDIAN), - - // Spiders - SPIDER(73, ABSTRACT_MONSTER), - CAVE_SPIDER(8, SPIDER), - - // Zombies - ZOMBIE(95, ABSTRACT_MONSTER), - DROWNED(16, ZOMBIE), - HUSK(33, ZOMBIE), - ZOMBIE_PIGMAN(57, ZOMBIE), - ZOMBIE_VILLAGER(97, ZOMBIE), - - // Flying entities - ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT), - GHAST(29, ABSTRACT_FLYING), - PHANTOM(98, ABSTRACT_FLYING), - - ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT), - BAT(3, ABSTRACT_AMBIENT), - - ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT), - SQUID(74, ABSTRACT_WATERMOB), - - // Slimes - SLIME(68, ABSTRACT_INSENTIENT), - MAGMA_CUBE(41, SLIME), - - // Hangable objects - ABSTRACT_HANGING(-1, ENTITY), - LEASH_KNOT(38, ABSTRACT_HANGING), - ITEM_FRAME(36, ABSTRACT_HANGING), - PAINTING(52, ABSTRACT_HANGING), - - ABSTRACT_LIGHTNING(-1, ENTITY), - LIGHTNING_BOLT(100, ABSTRACT_LIGHTNING), - - // Arrows - ABSTRACT_ARROW(-1, ENTITY), - ARROW(2, ABSTRACT_ARROW), - SPECTRAL_ARROW(72, ABSTRACT_ARROW), - TRIDENT(83, ABSTRACT_ARROW), - - // Fireballs - ABSTRACT_FIREBALL(-1, ENTITY), - DRAGON_FIREBALL(15, ABSTRACT_FIREBALL), - FIREBALL(37, ABSTRACT_FIREBALL), - SMALL_FIREBALL(69, ABSTRACT_FIREBALL), - WITHER_SKULL(93, ABSTRACT_FIREBALL), + // Hanging entities + ABSTRACT_HANGING(ENTITY, null), + LEASH_KNOT(ABSTRACT_HANGING), + PAINTING(ABSTRACT_HANGING), + ITEM_FRAME(ABSTRACT_HANGING), // Projectiles - PROJECTILE_ABSTRACT(-1, ENTITY), - SNOWBALL(71, PROJECTILE_ABSTRACT), - ENDER_PEARL(80, PROJECTILE_ABSTRACT), - EGG(79, PROJECTILE_ABSTRACT), - POTION(82, PROJECTILE_ABSTRACT), - EXPERIENCE_BOTTLE(81, PROJECTILE_ABSTRACT), + PROJECTILE_ABSTRACT(ENTITY, null), // Not actually its own abstract type, but useful for categorizing + SNOWBALL(PROJECTILE_ABSTRACT), + ENDER_PEARL(PROJECTILE_ABSTRACT), + EGG(PROJECTILE_ABSTRACT), + POTION(PROJECTILE_ABSTRACT), + EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), + FIREWORK_ROCKET(PROJECTILE_ABSTRACT), + LLAMA_SPIT(PROJECTILE_ABSTRACT), + SHULKER_BULLET(PROJECTILE_ABSTRACT), + FISHING_BOBBER(PROJECTILE_ABSTRACT), + WITHER_SKULL(PROJECTILE_ABSTRACT), + DRAGON_FIREBALL(PROJECTILE_ABSTRACT), // Doesn't actually inherit fireball + + ABSTRACT_ARROW(PROJECTILE_ABSTRACT, null), + ARROW(ABSTRACT_ARROW), + SPECTRAL_ARROW(ABSTRACT_ARROW), + TRIDENT(ABSTRACT_ARROW), + + ABSTRACT_FIREBALL(ENTITY, null), + FIREBALL(ABSTRACT_FIREBALL), + SMALL_FIREBALL(ABSTRACT_FIREBALL), // Vehicles - MINECART_ABSTRACT(-1, ENTITY), - CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT), - CHEST_MINECART(43, CHESTED_MINECART_ABSTRACT), - HOPPER_MINECART(46, CHESTED_MINECART_ABSTRACT), - MINECART(42, MINECART_ABSTRACT), - FURNACE_MINECART(45, MINECART_ABSTRACT), - COMMAND_BLOCK_MINECART(44, MINECART_ABSTRACT), - TNT_MINECART(48, MINECART_ABSTRACT), - SPAWNER_MINECART(47, MINECART_ABSTRACT), - BOAT(6, ENTITY); + VEHICLE(ENTITY, null), + BOAT(VEHICLE), - private static final EntityType[] TYPES; + MINECART_ABSTRACT(VEHICLE, null), + MINECART(MINECART_ABSTRACT), + FURNACE_MINECART(MINECART_ABSTRACT), + COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), + TNT_MINECART(MINECART_ABSTRACT), + SPAWNER_MINECART(MINECART_ABSTRACT), - private final int id; + CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), + CHEST_MINECART(CHESTED_MINECART_ABSTRACT), + HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), + + // Living entities as a larger subclass + LIVINGENTITY(ENTITY, null), + ARMOR_STAND(LIVINGENTITY), + PLAYER(LIVINGENTITY), + + // Mobs as a larger subclass + ABSTRACT_INSENTIENT(LIVINGENTITY, null), + ENDER_DRAGON(ABSTRACT_INSENTIENT), + + SLIME(ABSTRACT_INSENTIENT), + MAGMA_CUBE(SLIME), + + // Ambient mobs + ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), + BAT(ABSTRACT_AMBIENT), + + // Flying mobs + ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), + GHAST(ABSTRACT_FLYING), + PHANTOM(ABSTRACT_FLYING), + + // Pathfinder mobs and its subclasses + ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null), + + ABSTRACT_GOLEM(ABSTRACT_CREATURE, null), + SNOW_GOLEM(ABSTRACT_GOLEM), + IRON_GOLEM(ABSTRACT_GOLEM), + SHULKER(ABSTRACT_GOLEM), + + // Water mobs + ABSTRACT_WATERMOB(ABSTRACT_CREATURE, null), + DOLPHIN(ABSTRACT_WATERMOB), + SQUID(ABSTRACT_WATERMOB), + + ABSTRACT_FISHES(ABSTRACT_WATERMOB, null), + PUFFERFISH(ABSTRACT_FISHES), + + ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISHES, null), + COD(ABSTRACT_SCHOOLING_FISH), + SALMON(ABSTRACT_SCHOOLING_FISH), + TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH), + + // Ageable mobs and (tamable) animals + ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), + ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null), + VILLAGER(ABSTRACT_VILLAGER), + WANDERING_TRADER(ABSTRACT_VILLAGER), + + ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), + CHICKEN(ABSTRACT_ANIMAL), + PANDA(ABSTRACT_ANIMAL), + PIG(ABSTRACT_ANIMAL), + POLAR_BEAR(ABSTRACT_ANIMAL), + RABBIT(ABSTRACT_ANIMAL), + SHEEP(ABSTRACT_ANIMAL), + BEE(ABSTRACT_ANIMAL), + TURTLE(ABSTRACT_ANIMAL), + FOX(ABSTRACT_ANIMAL), + + COW(ABSTRACT_ANIMAL), + MOOSHROOM(COW), + + ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), + CAT(ABSTRACT_TAMEABLE_ANIMAL), + OCELOT(ABSTRACT_TAMEABLE_ANIMAL), + WOLF(ABSTRACT_TAMEABLE_ANIMAL), + PARROT(ABSTRACT_TAMEABLE_ANIMAL), + + ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), + HORSE(ABSTRACT_HORSE), + SKELETON_HORSE(ABSTRACT_HORSE), + ZOMBIE_HORSE(ABSTRACT_HORSE), + + CHESTED_HORSE(ABSTRACT_HORSE, null), + DONKEY(CHESTED_HORSE), + MULE(CHESTED_HORSE), + LLAMA(CHESTED_HORSE), + TRADER_LLAMA(LLAMA), + + // Monsters + ABSTRACT_MONSTER(ABSTRACT_CREATURE, null), + BLAZE(ABSTRACT_MONSTER), + CREEPER(ABSTRACT_MONSTER), + ENDERMITE(ABSTRACT_MONSTER), + ENDERMAN(ABSTRACT_MONSTER), + GIANT(ABSTRACT_MONSTER), + SILVERFISH(ABSTRACT_MONSTER), + VEX(ABSTRACT_MONSTER), + WITHER(ABSTRACT_MONSTER), + + ABSTRACT_SKELETON(ABSTRACT_MONSTER, null), + SKELETON(ABSTRACT_SKELETON), + STRAY(ABSTRACT_SKELETON), + WITHER_SKELETON(ABSTRACT_SKELETON), + + ZOMBIE(ABSTRACT_MONSTER), + DROWNED(ZOMBIE), + HUSK(ZOMBIE), + ZOMBIE_PIGMAN(ZOMBIE), + ZOMBIE_VILLAGER(ZOMBIE), + + GUARDIAN(ABSTRACT_MONSTER), + ELDER_GUARDIAN(GUARDIAN), + + SPIDER(ABSTRACT_MONSTER), + CAVE_SPIDER(SPIDER), + + // Raiders + ABSTRACT_RAIDER(ABSTRACT_MONSTER, null), + WITCH(ABSTRACT_RAIDER), + RAVAGER(ABSTRACT_RAIDER), + + ABSTRACT_ILLAGER_BASE(ABSTRACT_RAIDER, null), + ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), + VINDICATOR(ABSTRACT_ILLAGER_BASE), + PILLAGER(ABSTRACT_ILLAGER_BASE), + EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), + ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER); + + private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values()); private final EntityType parent; + private final String identifier; + private int id = -1; - EntityTypes1_15(int id) { - this.id = id; - this.parent = null; + EntityTypes1_15(final EntityType parent) { + this.parent = parent; + this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); } - EntityTypes1_15(int id, EntityType parent) { - this.id = id; + EntityTypes1_15(final EntityType parent, @Nullable final String identifier) { this.parent = parent; + this.identifier = identifier; } @Override public int getId() { + if (id == -1) { + throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")"); + } return id; } @Override - public EntityType getParent() { + public String identifier() { + Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type"); + return identifier; + } + + @Override + public @Nullable EntityType getParent() { return parent; } - @Override - public String identifier() { - throw new UnsupportedOperationException(); - } - @Override public boolean isAbstractType() { - return id != -1; + return identifier == null; } - static { - TYPES = EntityTypeUtil.toOrderedArray(values()); - } - - public static EntityType getTypeFromId(int typeId) { + public static EntityType getTypeFromId(final int typeId) { return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY); } + + public static void initialize(final Protocol protocol) { + EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id); + } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16.java index 23de1ef65..7039c4de2 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16.java @@ -22,230 +22,237 @@ */ package com.viaversion.viaversion.api.minecraft.entities; +import com.google.common.base.Preconditions; +import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.util.EntityTypeUtil; +import java.util.Locale; +import org.checkerframework.checker.nullness.qual.Nullable; public enum EntityTypes1_16 implements EntityType { - ENTITY(-1), + ENTITY(null, null), - AREA_EFFECT_CLOUD(0, ENTITY), - END_CRYSTAL(18, ENTITY), - EVOKER_FANGS(23, ENTITY), - EXPERIENCE_ORB(24, ENTITY), - EYE_OF_ENDER(25, ENTITY), - FALLING_BLOCK(26, ENTITY), - FIREWORK_ROCKET(27, ENTITY), - ITEM(37, ENTITY), - LLAMA_SPIT(43, ENTITY), - TNT(63, ENTITY), - SHULKER_BULLET(70, ENTITY), - FISHING_BOBBER(106, ENTITY), + AREA_EFFECT_CLOUD(ENTITY), + END_CRYSTAL(ENTITY), + EVOKER_FANGS(ENTITY), + EXPERIENCE_ORB(ENTITY), + EYE_OF_ENDER(ENTITY), + FALLING_BLOCK(ENTITY), + ITEM(ENTITY), + TNT(ENTITY), + LIGHTNING_BOLT(ENTITY), - LIVINGENTITY(-1, ENTITY), - ARMOR_STAND(1, LIVINGENTITY), - PLAYER(105, LIVINGENTITY), - - ABSTRACT_INSENTIENT(-1, LIVINGENTITY), - ENDER_DRAGON(19, ABSTRACT_INSENTIENT), - - BEE(4, ABSTRACT_INSENTIENT), - - ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT), - - ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE), - VILLAGER(92, ABSTRACT_AGEABLE), - WANDERING_TRADER(94, ABSTRACT_AGEABLE), - - // Animals - ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE), - DOLPHIN(13, ABSTRACT_INSENTIENT), - CHICKEN(9, ABSTRACT_ANIMAL), - COW(11, ABSTRACT_ANIMAL), - MOOSHROOM(53, COW), - PANDA(56, ABSTRACT_INSENTIENT), - PIG(59, ABSTRACT_ANIMAL), - POLAR_BEAR(62, ABSTRACT_ANIMAL), - RABBIT(65, ABSTRACT_ANIMAL), - SHEEP(68, ABSTRACT_ANIMAL), - TURTLE(90, ABSTRACT_ANIMAL), - FOX(28, ABSTRACT_ANIMAL), - - ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL), - CAT(7, ABSTRACT_TAMEABLE_ANIMAL), - OCELOT(54, ABSTRACT_TAMEABLE_ANIMAL), - WOLF(99, ABSTRACT_TAMEABLE_ANIMAL), - - ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL), - PARROT(57, ABSTRACT_PARROT), - - // Horses - ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL), - CHESTED_HORSE(-1, ABSTRACT_HORSE), - DONKEY(14, CHESTED_HORSE), - MULE(52, CHESTED_HORSE), - LLAMA(42, CHESTED_HORSE), - TRADER_LLAMA(88, CHESTED_HORSE), - HORSE(33, ABSTRACT_HORSE), - SKELETON_HORSE(73, ABSTRACT_HORSE), - ZOMBIE_HORSE(102, ABSTRACT_HORSE), - - // Golem - ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE), - SNOW_GOLEM(76, ABSTRACT_GOLEM), - IRON_GOLEM(36, ABSTRACT_GOLEM), - SHULKER(69, ABSTRACT_GOLEM), - - // Fish - ABSTRACT_FISHES(-1, ABSTRACT_CREATURE), - COD(10, ABSTRACT_FISHES), - PUFFERFISH(64, ABSTRACT_FISHES), - SALMON(67, ABSTRACT_FISHES), - TROPICAL_FISH(89, ABSTRACT_FISHES), - - // Monsters - ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE), - BLAZE(5, ABSTRACT_MONSTER), - CREEPER(12, ABSTRACT_MONSTER), - ENDERMITE(21, ABSTRACT_MONSTER), - ENDERMAN(20, ABSTRACT_MONSTER), - GIANT(30, ABSTRACT_MONSTER), - SILVERFISH(71, ABSTRACT_MONSTER), - VEX(91, ABSTRACT_MONSTER), - WITCH(95, ABSTRACT_MONSTER), - WITHER(96, ABSTRACT_MONSTER), - RAVAGER(66, ABSTRACT_MONSTER), - PIGLIN(60, ABSTRACT_MONSTER), - - HOGLIN(32, ABSTRACT_ANIMAL), - STRIDER(82, ABSTRACT_ANIMAL), - ZOGLIN(100, ABSTRACT_MONSTER), - - // Illagers - ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER), - ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE), - EVOKER(22, ABSTRACT_EVO_ILLU_ILLAGER), - ILLUSIONER(35, ABSTRACT_EVO_ILLU_ILLAGER), - VINDICATOR(93, ABSTRACT_ILLAGER_BASE), - PILLAGER(61, ABSTRACT_ILLAGER_BASE), - - // Skeletons - ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER), - SKELETON(72, ABSTRACT_SKELETON), - STRAY(81, ABSTRACT_SKELETON), - WITHER_SKELETON(97, ABSTRACT_SKELETON), - - // Guardians - GUARDIAN(31, ABSTRACT_MONSTER), - ELDER_GUARDIAN(17, GUARDIAN), - - // Spiders - SPIDER(79, ABSTRACT_MONSTER), - CAVE_SPIDER(8, SPIDER), - - // Zombies - ZOMBIE(101, ABSTRACT_MONSTER), - DROWNED(16, ZOMBIE), - HUSK(34, ZOMBIE), - ZOMBIFIED_PIGLIN(104, ZOMBIE), - ZOMBIE_VILLAGER(103, ZOMBIE), - - // Flying entities - ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT), - GHAST(29, ABSTRACT_FLYING), - PHANTOM(58, ABSTRACT_FLYING), - - ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT), - BAT(3, ABSTRACT_AMBIENT), - - ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT), - SQUID(80, ABSTRACT_WATERMOB), - - // Slimes - SLIME(74, ABSTRACT_INSENTIENT), - MAGMA_CUBE(44, SLIME), - - // Hangable objects - ABSTRACT_HANGING(-1, ENTITY), - LEASH_KNOT(40, ABSTRACT_HANGING), - ITEM_FRAME(38, ABSTRACT_HANGING), - PAINTING(55, ABSTRACT_HANGING), - - ABSTRACT_LIGHTNING(-1, ENTITY), - LIGHTNING_BOLT(41, ABSTRACT_LIGHTNING), - - // Arrows - ABSTRACT_ARROW(-1, ENTITY), - ARROW(2, ABSTRACT_ARROW), - SPECTRAL_ARROW(78, ABSTRACT_ARROW), - TRIDENT(87, ABSTRACT_ARROW), - - // Fireballs - ABSTRACT_FIREBALL(-1, ENTITY), - DRAGON_FIREBALL(15, ABSTRACT_FIREBALL), - FIREBALL(39, ABSTRACT_FIREBALL), - SMALL_FIREBALL(75, ABSTRACT_FIREBALL), - WITHER_SKULL(98, ABSTRACT_FIREBALL), + // Hanging entities + ABSTRACT_HANGING(ENTITY, null), + LEASH_KNOT(ABSTRACT_HANGING), + PAINTING(ABSTRACT_HANGING), + ITEM_FRAME(ABSTRACT_HANGING), // Projectiles - PROJECTILE_ABSTRACT(-1, ENTITY), - SNOWBALL(77, PROJECTILE_ABSTRACT), - ENDER_PEARL(84, PROJECTILE_ABSTRACT), - EGG(83, PROJECTILE_ABSTRACT), - POTION(86, PROJECTILE_ABSTRACT), - EXPERIENCE_BOTTLE(85, PROJECTILE_ABSTRACT), + PROJECTILE_ABSTRACT(ENTITY, null), // Not actually its own abstract type, but useful for categorizing + SNOWBALL(PROJECTILE_ABSTRACT), + ENDER_PEARL(PROJECTILE_ABSTRACT), + EGG(PROJECTILE_ABSTRACT), + POTION(PROJECTILE_ABSTRACT), + EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), + FIREWORK_ROCKET(PROJECTILE_ABSTRACT), + LLAMA_SPIT(PROJECTILE_ABSTRACT), + SHULKER_BULLET(PROJECTILE_ABSTRACT), + FISHING_BOBBER(PROJECTILE_ABSTRACT), + WITHER_SKULL(PROJECTILE_ABSTRACT), + DRAGON_FIREBALL(PROJECTILE_ABSTRACT), // Doesn't actually inherit fireball + + ABSTRACT_ARROW(PROJECTILE_ABSTRACT, null), + ARROW(ABSTRACT_ARROW), + SPECTRAL_ARROW(ABSTRACT_ARROW), + TRIDENT(ABSTRACT_ARROW), + + ABSTRACT_FIREBALL(ENTITY, null), + FIREBALL(ABSTRACT_FIREBALL), + SMALL_FIREBALL(ABSTRACT_FIREBALL), // Vehicles - MINECART_ABSTRACT(-1, ENTITY), - CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT), - CHEST_MINECART(46, CHESTED_MINECART_ABSTRACT), - HOPPER_MINECART(49, CHESTED_MINECART_ABSTRACT), - MINECART(45, MINECART_ABSTRACT), - FURNACE_MINECART(48, MINECART_ABSTRACT), - COMMAND_BLOCK_MINECART(47, MINECART_ABSTRACT), - TNT_MINECART(51, MINECART_ABSTRACT), - SPAWNER_MINECART(50, MINECART_ABSTRACT), - BOAT(6, ENTITY); + VEHICLE(ENTITY, null), + BOAT(VEHICLE), - private static final EntityType[] TYPES; + MINECART_ABSTRACT(VEHICLE, null), + MINECART(MINECART_ABSTRACT), + FURNACE_MINECART(MINECART_ABSTRACT), + COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), + TNT_MINECART(MINECART_ABSTRACT), + SPAWNER_MINECART(MINECART_ABSTRACT), - private final int id; + CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), + CHEST_MINECART(CHESTED_MINECART_ABSTRACT), + HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), + + // Living entities as a larger subclass + LIVINGENTITY(ENTITY, null), + ARMOR_STAND(LIVINGENTITY), + PLAYER(LIVINGENTITY), + + // Mobs as a larger subclass + ABSTRACT_INSENTIENT(LIVINGENTITY, null), + ENDER_DRAGON(ABSTRACT_INSENTIENT), + + SLIME(ABSTRACT_INSENTIENT), + MAGMA_CUBE(SLIME), + + // Ambient mobs + ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), + BAT(ABSTRACT_AMBIENT), + + // Flying mobs + ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), + GHAST(ABSTRACT_FLYING), + PHANTOM(ABSTRACT_FLYING), + + // Pathfinder mobs and its subclasses + ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null), + + ABSTRACT_GOLEM(ABSTRACT_CREATURE, null), + SNOW_GOLEM(ABSTRACT_GOLEM), + IRON_GOLEM(ABSTRACT_GOLEM), + SHULKER(ABSTRACT_GOLEM), + + // Water mobs + ABSTRACT_WATERMOB(ABSTRACT_CREATURE, null), + DOLPHIN(ABSTRACT_WATERMOB), + SQUID(ABSTRACT_WATERMOB), + + ABSTRACT_FISHES(ABSTRACT_WATERMOB, null), + PUFFERFISH(ABSTRACT_FISHES), + + ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISHES, null), + COD(ABSTRACT_SCHOOLING_FISH), + SALMON(ABSTRACT_SCHOOLING_FISH), + TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH), + + // Ageable mobs and (tamable) animals + ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), + ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null), + VILLAGER(ABSTRACT_VILLAGER), + WANDERING_TRADER(ABSTRACT_VILLAGER), + + ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), + CHICKEN(ABSTRACT_ANIMAL), + PANDA(ABSTRACT_ANIMAL), + PIG(ABSTRACT_ANIMAL), + POLAR_BEAR(ABSTRACT_ANIMAL), + RABBIT(ABSTRACT_ANIMAL), + SHEEP(ABSTRACT_ANIMAL), + BEE(ABSTRACT_ANIMAL), + TURTLE(ABSTRACT_ANIMAL), + FOX(ABSTRACT_ANIMAL), + HOGLIN(ABSTRACT_ANIMAL), + STRIDER(ABSTRACT_ANIMAL), + + COW(ABSTRACT_ANIMAL), + MOOSHROOM(COW), + + ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), + CAT(ABSTRACT_TAMEABLE_ANIMAL), + OCELOT(ABSTRACT_TAMEABLE_ANIMAL), + WOLF(ABSTRACT_TAMEABLE_ANIMAL), + PARROT(ABSTRACT_TAMEABLE_ANIMAL), + + ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), + HORSE(ABSTRACT_HORSE), + SKELETON_HORSE(ABSTRACT_HORSE), + ZOMBIE_HORSE(ABSTRACT_HORSE), + + CHESTED_HORSE(ABSTRACT_HORSE, null), + DONKEY(CHESTED_HORSE), + MULE(CHESTED_HORSE), + LLAMA(CHESTED_HORSE), + TRADER_LLAMA(LLAMA), + + // Monsters + ABSTRACT_MONSTER(ABSTRACT_CREATURE, null), + BLAZE(ABSTRACT_MONSTER), + CREEPER(ABSTRACT_MONSTER), + ENDERMITE(ABSTRACT_MONSTER), + ENDERMAN(ABSTRACT_MONSTER), + GIANT(ABSTRACT_MONSTER), + SILVERFISH(ABSTRACT_MONSTER), + VEX(ABSTRACT_MONSTER), + WITHER(ABSTRACT_MONSTER), + ZOGLIN(ABSTRACT_MONSTER), + PIGLIN(ABSTRACT_MONSTER), + + ABSTRACT_SKELETON(ABSTRACT_MONSTER, null), + SKELETON(ABSTRACT_SKELETON), + STRAY(ABSTRACT_SKELETON), + WITHER_SKELETON(ABSTRACT_SKELETON), + + ZOMBIE(ABSTRACT_MONSTER), + DROWNED(ZOMBIE), + HUSK(ZOMBIE), + ZOMBIFIED_PIGLIN(ZOMBIE), + ZOMBIE_VILLAGER(ZOMBIE), + + GUARDIAN(ABSTRACT_MONSTER), + ELDER_GUARDIAN(GUARDIAN), + + SPIDER(ABSTRACT_MONSTER), + CAVE_SPIDER(SPIDER), + + // Raiders + ABSTRACT_RAIDER(ABSTRACT_MONSTER, null), + WITCH(ABSTRACT_RAIDER), + RAVAGER(ABSTRACT_RAIDER), + + ABSTRACT_ILLAGER_BASE(ABSTRACT_RAIDER, null), + ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), + VINDICATOR(ABSTRACT_ILLAGER_BASE), + PILLAGER(ABSTRACT_ILLAGER_BASE), + EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), + ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER); + + private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values()); private final EntityType parent; + private final String identifier; + private int id = -1; - EntityTypes1_16(int id) { - this.id = id; - this.parent = null; + EntityTypes1_16(final EntityType parent) { + this.parent = parent; + this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); } - EntityTypes1_16(int id, EntityType parent) { - this.id = id; + EntityTypes1_16(final EntityType parent, @Nullable final String identifier) { this.parent = parent; + this.identifier = identifier; } @Override public int getId() { + if (id == -1) { + throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")"); + } return id; } @Override - public EntityType getParent() { + public String identifier() { + Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type"); + return identifier; + } + + @Override + public @Nullable EntityType getParent() { return parent; } - @Override - public String identifier() { - throw new UnsupportedOperationException(); - } - @Override public boolean isAbstractType() { - return id != -1; + return identifier == null; } - static { - TYPES = EntityTypeUtil.toOrderedArray(values()); - } - - public static EntityType getTypeFromId(int typeId) { + public static EntityType getTypeFromId(final int typeId) { return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY); } + + public static void initialize(final Protocol protocol) { + EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id); + } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16_2.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16_2.java index 3a77e08e8..aa8e2fb3a 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16_2.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_16_2.java @@ -22,234 +22,240 @@ */ package com.viaversion.viaversion.api.minecraft.entities; +import com.google.common.base.Preconditions; +import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.util.EntityTypeUtil; +import java.util.Locale; +import org.checkerframework.checker.nullness.qual.Nullable; public enum EntityTypes1_16_2 implements EntityType { - ENTITY(-1), + ENTITY(null, null), - AREA_EFFECT_CLOUD(0, ENTITY), - END_CRYSTAL(18, ENTITY), - EVOKER_FANGS(23, ENTITY), - EXPERIENCE_ORB(24, ENTITY), - EYE_OF_ENDER(25, ENTITY), - FALLING_BLOCK(26, ENTITY), - FIREWORK_ROCKET(27, ENTITY), - ITEM(37, ENTITY), - LLAMA_SPIT(43, ENTITY), - TNT(64, ENTITY), - SHULKER_BULLET(71, ENTITY), - FISHING_BOBBER(107, ENTITY), + AREA_EFFECT_CLOUD(ENTITY), + END_CRYSTAL(ENTITY), + EVOKER_FANGS(ENTITY), + EXPERIENCE_ORB(ENTITY), + EYE_OF_ENDER(ENTITY), + FALLING_BLOCK(ENTITY), + ITEM(ENTITY), + TNT(ENTITY), + LIGHTNING_BOLT(ENTITY), - LIVINGENTITY(-1, ENTITY), - ARMOR_STAND(1, LIVINGENTITY), - PLAYER(106, LIVINGENTITY), - - ABSTRACT_INSENTIENT(-1, LIVINGENTITY), - ENDER_DRAGON(19, ABSTRACT_INSENTIENT), - - BEE(4, ABSTRACT_INSENTIENT), - - ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT), - - ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE), - VILLAGER(93, ABSTRACT_AGEABLE), - WANDERING_TRADER(95, ABSTRACT_AGEABLE), - - // Animals - ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE), - DOLPHIN(13, ABSTRACT_INSENTIENT), - CHICKEN(9, ABSTRACT_ANIMAL), - COW(11, ABSTRACT_ANIMAL), - MOOSHROOM(53, COW), - PANDA(56, ABSTRACT_INSENTIENT), - PIG(59, ABSTRACT_ANIMAL), - POLAR_BEAR(63, ABSTRACT_ANIMAL), - RABBIT(66, ABSTRACT_ANIMAL), - SHEEP(69, ABSTRACT_ANIMAL), - TURTLE(91, ABSTRACT_ANIMAL), - FOX(28, ABSTRACT_ANIMAL), - - ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL), - CAT(7, ABSTRACT_TAMEABLE_ANIMAL), - OCELOT(54, ABSTRACT_TAMEABLE_ANIMAL), - WOLF(100, ABSTRACT_TAMEABLE_ANIMAL), - - ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL), - PARROT(57, ABSTRACT_PARROT), - - // Horses - ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL), - CHESTED_HORSE(-1, ABSTRACT_HORSE), - DONKEY(14, CHESTED_HORSE), - MULE(52, CHESTED_HORSE), - LLAMA(42, CHESTED_HORSE), - TRADER_LLAMA(89, CHESTED_HORSE), - HORSE(33, ABSTRACT_HORSE), - SKELETON_HORSE(74, ABSTRACT_HORSE), - ZOMBIE_HORSE(103, ABSTRACT_HORSE), - - // Golem - ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE), - SNOW_GOLEM(77, ABSTRACT_GOLEM), - IRON_GOLEM(36, ABSTRACT_GOLEM), - SHULKER(70, ABSTRACT_GOLEM), - - // Fish - ABSTRACT_FISHES(-1, ABSTRACT_CREATURE), - COD(10, ABSTRACT_FISHES), - PUFFERFISH(65, ABSTRACT_FISHES), - SALMON(68, ABSTRACT_FISHES), - TROPICAL_FISH(90, ABSTRACT_FISHES), - - // Monsters - ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE), - BLAZE(5, ABSTRACT_MONSTER), - CREEPER(12, ABSTRACT_MONSTER), - ENDERMITE(21, ABSTRACT_MONSTER), - ENDERMAN(20, ABSTRACT_MONSTER), - GIANT(30, ABSTRACT_MONSTER), - SILVERFISH(72, ABSTRACT_MONSTER), - VEX(92, ABSTRACT_MONSTER), - WITCH(96, ABSTRACT_MONSTER), - WITHER(97, ABSTRACT_MONSTER), - RAVAGER(67, ABSTRACT_MONSTER), - - ABSTRACT_PIGLIN(-1, ABSTRACT_MONSTER), - - PIGLIN(60, ABSTRACT_PIGLIN), - PIGLIN_BRUTE(61, ABSTRACT_PIGLIN), - - HOGLIN(32, ABSTRACT_ANIMAL), - STRIDER(83, ABSTRACT_ANIMAL), - ZOGLIN(101, ABSTRACT_MONSTER), - - // Illagers - ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER), - ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE), - EVOKER(22, ABSTRACT_EVO_ILLU_ILLAGER), - ILLUSIONER(35, ABSTRACT_EVO_ILLU_ILLAGER), - VINDICATOR(94, ABSTRACT_ILLAGER_BASE), - PILLAGER(62, ABSTRACT_ILLAGER_BASE), - - // Skeletons - ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER), - SKELETON(73, ABSTRACT_SKELETON), - STRAY(82, ABSTRACT_SKELETON), - WITHER_SKELETON(98, ABSTRACT_SKELETON), - - // Guardians - GUARDIAN(31, ABSTRACT_MONSTER), - ELDER_GUARDIAN(17, GUARDIAN), - - // Spiders - SPIDER(80, ABSTRACT_MONSTER), - CAVE_SPIDER(8, SPIDER), - - // Zombies - ZOMBIE(102, ABSTRACT_MONSTER), - DROWNED(16, ZOMBIE), - HUSK(34, ZOMBIE), - ZOMBIFIED_PIGLIN(105, ZOMBIE), - ZOMBIE_VILLAGER(104, ZOMBIE), - - // Flying entities - ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT), - GHAST(29, ABSTRACT_FLYING), - PHANTOM(58, ABSTRACT_FLYING), - - ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT), - BAT(3, ABSTRACT_AMBIENT), - - ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT), - SQUID(81, ABSTRACT_WATERMOB), - - // Slimes - SLIME(75, ABSTRACT_INSENTIENT), - MAGMA_CUBE(44, SLIME), - - // Hangable objects - ABSTRACT_HANGING(-1, ENTITY), - LEASH_KNOT(40, ABSTRACT_HANGING), - ITEM_FRAME(38, ABSTRACT_HANGING), - PAINTING(55, ABSTRACT_HANGING), - - ABSTRACT_LIGHTNING(-1, ENTITY), - LIGHTNING_BOLT(41, ABSTRACT_LIGHTNING), - - // Arrows - ABSTRACT_ARROW(-1, ENTITY), - ARROW(2, ABSTRACT_ARROW), - SPECTRAL_ARROW(79, ABSTRACT_ARROW), - TRIDENT(88, ABSTRACT_ARROW), - - // Fireballs - ABSTRACT_FIREBALL(-1, ENTITY), - DRAGON_FIREBALL(15, ABSTRACT_FIREBALL), - FIREBALL(39, ABSTRACT_FIREBALL), - SMALL_FIREBALL(76, ABSTRACT_FIREBALL), - WITHER_SKULL(99, ABSTRACT_FIREBALL), + // Hanging entities + ABSTRACT_HANGING(ENTITY, null), + LEASH_KNOT(ABSTRACT_HANGING), + PAINTING(ABSTRACT_HANGING), + ITEM_FRAME(ABSTRACT_HANGING), // Projectiles - PROJECTILE_ABSTRACT(-1, ENTITY), - SNOWBALL(78, PROJECTILE_ABSTRACT), - ENDER_PEARL(85, PROJECTILE_ABSTRACT), - EGG(84, PROJECTILE_ABSTRACT), - POTION(87, PROJECTILE_ABSTRACT), - EXPERIENCE_BOTTLE(86, PROJECTILE_ABSTRACT), + PROJECTILE_ABSTRACT(ENTITY, null), // Not actually its own abstract type, but useful for categorizing + SNOWBALL(PROJECTILE_ABSTRACT), + ENDER_PEARL(PROJECTILE_ABSTRACT), + EGG(PROJECTILE_ABSTRACT), + POTION(PROJECTILE_ABSTRACT), + EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), + FIREWORK_ROCKET(PROJECTILE_ABSTRACT), + LLAMA_SPIT(PROJECTILE_ABSTRACT), + SHULKER_BULLET(PROJECTILE_ABSTRACT), + FISHING_BOBBER(PROJECTILE_ABSTRACT), + WITHER_SKULL(PROJECTILE_ABSTRACT), + DRAGON_FIREBALL(PROJECTILE_ABSTRACT), // Doesn't actually inherit fireball + + ABSTRACT_ARROW(PROJECTILE_ABSTRACT, null), + ARROW(ABSTRACT_ARROW), + SPECTRAL_ARROW(ABSTRACT_ARROW), + TRIDENT(ABSTRACT_ARROW), + + ABSTRACT_FIREBALL(ENTITY, null), + FIREBALL(ABSTRACT_FIREBALL), + SMALL_FIREBALL(ABSTRACT_FIREBALL), // Vehicles - MINECART_ABSTRACT(-1, ENTITY), - CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT), - CHEST_MINECART(46, CHESTED_MINECART_ABSTRACT), - HOPPER_MINECART(49, CHESTED_MINECART_ABSTRACT), - MINECART(45, MINECART_ABSTRACT), - FURNACE_MINECART(48, MINECART_ABSTRACT), - COMMAND_BLOCK_MINECART(47, MINECART_ABSTRACT), - TNT_MINECART(51, MINECART_ABSTRACT), - SPAWNER_MINECART(50, MINECART_ABSTRACT), - BOAT(6, ENTITY); + VEHICLE(ENTITY, null), + BOAT(VEHICLE), - private static final EntityType[] TYPES; + MINECART_ABSTRACT(VEHICLE, null), + MINECART(MINECART_ABSTRACT), + FURNACE_MINECART(MINECART_ABSTRACT), + COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), + TNT_MINECART(MINECART_ABSTRACT), + SPAWNER_MINECART(MINECART_ABSTRACT), - private final int id; + CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), + CHEST_MINECART(CHESTED_MINECART_ABSTRACT), + HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), + + // Living entities as a larger subclass + LIVINGENTITY(ENTITY, null), + ARMOR_STAND(LIVINGENTITY), + PLAYER(LIVINGENTITY), + + // Mobs as a larger subclass + ABSTRACT_INSENTIENT(LIVINGENTITY, null), + ENDER_DRAGON(ABSTRACT_INSENTIENT), + + SLIME(ABSTRACT_INSENTIENT), + MAGMA_CUBE(SLIME), + + // Ambient mobs + ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), + BAT(ABSTRACT_AMBIENT), + + // Flying mobs + ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), + GHAST(ABSTRACT_FLYING), + PHANTOM(ABSTRACT_FLYING), + + // Pathfinder mobs and its subclasses + ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null), + + ABSTRACT_GOLEM(ABSTRACT_CREATURE, null), + SNOW_GOLEM(ABSTRACT_GOLEM), + IRON_GOLEM(ABSTRACT_GOLEM), + SHULKER(ABSTRACT_GOLEM), + + // Water mobs + ABSTRACT_WATERMOB(ABSTRACT_CREATURE, null), + DOLPHIN(ABSTRACT_WATERMOB), + SQUID(ABSTRACT_WATERMOB), + + ABSTRACT_FISHES(ABSTRACT_WATERMOB, null), + PUFFERFISH(ABSTRACT_FISHES), + + ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISHES, null), + COD(ABSTRACT_SCHOOLING_FISH), + SALMON(ABSTRACT_SCHOOLING_FISH), + TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH), + + // Ageable mobs and (tamable) animals + ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), + ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null), + VILLAGER(ABSTRACT_VILLAGER), + WANDERING_TRADER(ABSTRACT_VILLAGER), + + ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), + CHICKEN(ABSTRACT_ANIMAL), + PANDA(ABSTRACT_ANIMAL), + PIG(ABSTRACT_ANIMAL), + POLAR_BEAR(ABSTRACT_ANIMAL), + RABBIT(ABSTRACT_ANIMAL), + SHEEP(ABSTRACT_ANIMAL), + BEE(ABSTRACT_ANIMAL), + TURTLE(ABSTRACT_ANIMAL), + FOX(ABSTRACT_ANIMAL), + HOGLIN(ABSTRACT_ANIMAL), + STRIDER(ABSTRACT_ANIMAL), + + COW(ABSTRACT_ANIMAL), + MOOSHROOM(COW), + + ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), + CAT(ABSTRACT_TAMEABLE_ANIMAL), + OCELOT(ABSTRACT_TAMEABLE_ANIMAL), + WOLF(ABSTRACT_TAMEABLE_ANIMAL), + PARROT(ABSTRACT_TAMEABLE_ANIMAL), + + ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), + HORSE(ABSTRACT_HORSE), + SKELETON_HORSE(ABSTRACT_HORSE), + ZOMBIE_HORSE(ABSTRACT_HORSE), + + CHESTED_HORSE(ABSTRACT_HORSE, null), + DONKEY(CHESTED_HORSE), + MULE(CHESTED_HORSE), + LLAMA(CHESTED_HORSE), + TRADER_LLAMA(LLAMA), + + // Monsters + ABSTRACT_MONSTER(ABSTRACT_CREATURE, null), + BLAZE(ABSTRACT_MONSTER), + CREEPER(ABSTRACT_MONSTER), + ENDERMITE(ABSTRACT_MONSTER), + ENDERMAN(ABSTRACT_MONSTER), + GIANT(ABSTRACT_MONSTER), + SILVERFISH(ABSTRACT_MONSTER), + VEX(ABSTRACT_MONSTER), + WITHER(ABSTRACT_MONSTER), + ZOGLIN(ABSTRACT_MONSTER), + + ABSTRACT_SKELETON(ABSTRACT_MONSTER, null), + SKELETON(ABSTRACT_SKELETON), + STRAY(ABSTRACT_SKELETON), + WITHER_SKELETON(ABSTRACT_SKELETON), + + ZOMBIE(ABSTRACT_MONSTER), + DROWNED(ZOMBIE), + HUSK(ZOMBIE), + ZOMBIFIED_PIGLIN(ZOMBIE), + ZOMBIE_VILLAGER(ZOMBIE), + + GUARDIAN(ABSTRACT_MONSTER), + ELDER_GUARDIAN(GUARDIAN), + + SPIDER(ABSTRACT_MONSTER), + CAVE_SPIDER(SPIDER), + + ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null), + PIGLIN(ABSTRACT_PIGLIN), + PIGLIN_BRUTE(ABSTRACT_PIGLIN), + + // Raiders + ABSTRACT_RAIDER(ABSTRACT_MONSTER, null), + WITCH(ABSTRACT_RAIDER), + RAVAGER(ABSTRACT_RAIDER), + + ABSTRACT_ILLAGER_BASE(ABSTRACT_RAIDER, null), + ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), + VINDICATOR(ABSTRACT_ILLAGER_BASE), + PILLAGER(ABSTRACT_ILLAGER_BASE), + EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), + ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER); + + private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values()); private final EntityType parent; + private final String identifier; + private int id = -1; - EntityTypes1_16_2(int id) { - this.id = id; - this.parent = null; + EntityTypes1_16_2(final EntityType parent) { + this.parent = parent; + this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); } - EntityTypes1_16_2(int id, EntityType parent) { - this.id = id; + EntityTypes1_16_2(final EntityType parent, @Nullable final String identifier) { this.parent = parent; + this.identifier = identifier; } @Override public int getId() { + if (id == -1) { + throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")"); + } return id; } @Override - public EntityType getParent() { + public String identifier() { + Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type"); + return identifier; + } + + @Override + public @Nullable EntityType getParent() { return parent; } - @Override - public String identifier() { - throw new UnsupportedOperationException(); - } - @Override public boolean isAbstractType() { - return id != -1; + return identifier == null; } - static { - TYPES = EntityTypeUtil.toOrderedArray(values()); - } - - public static EntityType getTypeFromId(int typeId) { + public static EntityType getTypeFromId(final int typeId) { return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY); } -} \ No newline at end of file + + public static void initialize(final Protocol protocol) { + EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id); + } +} diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_17.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_17.java index 1751d32ca..f942bbe07 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_17.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_17.java @@ -22,239 +22,246 @@ */ package com.viaversion.viaversion.api.minecraft.entities; +import com.google.common.base.Preconditions; +import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.util.EntityTypeUtil; +import java.util.Locale; +import org.checkerframework.checker.nullness.qual.Nullable; public enum EntityTypes1_17 implements EntityType { - ENTITY(-1), + ENTITY(null, null), - AREA_EFFECT_CLOUD(0, ENTITY), - END_CRYSTAL(19, ENTITY), - EVOKER_FANGS(24, ENTITY), - EXPERIENCE_ORB(25, ENTITY), - EYE_OF_ENDER(26, ENTITY), - FALLING_BLOCK(27, ENTITY), - FIREWORK_ROCKET(28, ENTITY), - ITEM(41, ENTITY), - LLAMA_SPIT(47, ENTITY), - TNT(69, ENTITY), - SHULKER_BULLET(76, ENTITY), - FISHING_BOBBER(112, ENTITY), + AREA_EFFECT_CLOUD(ENTITY), + END_CRYSTAL(ENTITY), + EVOKER_FANGS(ENTITY), + EXPERIENCE_ORB(ENTITY), + EYE_OF_ENDER(ENTITY), + FALLING_BLOCK(ENTITY), + ITEM(ENTITY), + TNT(ENTITY), + MARKER(ENTITY), + LIGHTNING_BOLT(ENTITY), - LIVINGENTITY(-1, ENTITY), - ARMOR_STAND(1, LIVINGENTITY), - MARKER(49, ENTITY), - PLAYER(111, LIVINGENTITY), - - ABSTRACT_INSENTIENT(-1, LIVINGENTITY), - ENDER_DRAGON(20, ABSTRACT_INSENTIENT), - - BEE(5, ABSTRACT_INSENTIENT), - - ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT), - - ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE), - VILLAGER(98, ABSTRACT_AGEABLE), - WANDERING_TRADER(100, ABSTRACT_AGEABLE), - - // Animals - ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE), - AXOLOTL(3, ABSTRACT_ANIMAL), - DOLPHIN(14, ABSTRACT_INSENTIENT), - CHICKEN(10, ABSTRACT_ANIMAL), - COW(12, ABSTRACT_ANIMAL), - MOOSHROOM(58, COW), - PANDA(61, ABSTRACT_INSENTIENT), - PIG(64, ABSTRACT_ANIMAL), - POLAR_BEAR(68, ABSTRACT_ANIMAL), - RABBIT(71, ABSTRACT_ANIMAL), - SHEEP(74, ABSTRACT_ANIMAL), - TURTLE(96, ABSTRACT_ANIMAL), - FOX(29, ABSTRACT_ANIMAL), - GOAT(34, ABSTRACT_ANIMAL), - - ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL), - CAT(8, ABSTRACT_TAMEABLE_ANIMAL), - OCELOT(59, ABSTRACT_TAMEABLE_ANIMAL), - WOLF(105, ABSTRACT_TAMEABLE_ANIMAL), - - ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL), - PARROT(62, ABSTRACT_PARROT), - - // Horses - ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL), - CHESTED_HORSE(-1, ABSTRACT_HORSE), - DONKEY(15, CHESTED_HORSE), - MULE(57, CHESTED_HORSE), - LLAMA(46, CHESTED_HORSE), - TRADER_LLAMA(94, CHESTED_HORSE), - HORSE(37, ABSTRACT_HORSE), - SKELETON_HORSE(79, ABSTRACT_HORSE), - ZOMBIE_HORSE(108, ABSTRACT_HORSE), - - // Golem - ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE), - SNOW_GOLEM(82, ABSTRACT_GOLEM), - IRON_GOLEM(40, ABSTRACT_GOLEM), - SHULKER(75, ABSTRACT_GOLEM), - - // Fish - ABSTRACT_FISHES(-1, ABSTRACT_CREATURE), - COD(11, ABSTRACT_FISHES), - PUFFERFISH(70, ABSTRACT_FISHES), - SALMON(73, ABSTRACT_FISHES), - TROPICAL_FISH(95, ABSTRACT_FISHES), - - // Monsters - ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE), - BLAZE(6, ABSTRACT_MONSTER), - CREEPER(13, ABSTRACT_MONSTER), - ENDERMITE(22, ABSTRACT_MONSTER), - ENDERMAN(21, ABSTRACT_MONSTER), - GIANT(31, ABSTRACT_MONSTER), - SILVERFISH(77, ABSTRACT_MONSTER), - VEX(97, ABSTRACT_MONSTER), - WITCH(101, ABSTRACT_MONSTER), - WITHER(102, ABSTRACT_MONSTER), - RAVAGER(72, ABSTRACT_MONSTER), - - ABSTRACT_PIGLIN(-1, ABSTRACT_MONSTER), - - PIGLIN(65, ABSTRACT_PIGLIN), - PIGLIN_BRUTE(66, ABSTRACT_PIGLIN), - - HOGLIN(36, ABSTRACT_ANIMAL), - STRIDER(88, ABSTRACT_ANIMAL), - ZOGLIN(106, ABSTRACT_MONSTER), - - // Illagers - ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER), - ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE), - EVOKER(23, ABSTRACT_EVO_ILLU_ILLAGER), - ILLUSIONER(39, ABSTRACT_EVO_ILLU_ILLAGER), - VINDICATOR(99, ABSTRACT_ILLAGER_BASE), - PILLAGER(67, ABSTRACT_ILLAGER_BASE), - - // Skeletons - ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER), - SKELETON(78, ABSTRACT_SKELETON), - STRAY(87, ABSTRACT_SKELETON), - WITHER_SKELETON(103, ABSTRACT_SKELETON), - - // Guardians - GUARDIAN(35, ABSTRACT_MONSTER), - ELDER_GUARDIAN(18, GUARDIAN), - - // Spiders - SPIDER(85, ABSTRACT_MONSTER), - CAVE_SPIDER(9, SPIDER), - - // Zombies - ZOMBIE(107, ABSTRACT_MONSTER), - DROWNED(17, ZOMBIE), - HUSK(38, ZOMBIE), - ZOMBIFIED_PIGLIN(110, ZOMBIE), - ZOMBIE_VILLAGER(109, ZOMBIE), - - // Flying entities - ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT), - GHAST(30, ABSTRACT_FLYING), - PHANTOM(63, ABSTRACT_FLYING), - - ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT), - BAT(4, ABSTRACT_AMBIENT), - - ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT), - SQUID(86, ABSTRACT_WATERMOB), - GLOW_SQUID(33, SQUID), - - // Slimes - SLIME(80, ABSTRACT_INSENTIENT), - MAGMA_CUBE(48, SLIME), - - // Hangable objects - ABSTRACT_HANGING(-1, ENTITY), - LEASH_KNOT(44, ABSTRACT_HANGING), - ITEM_FRAME(42, ABSTRACT_HANGING), - GLOW_ITEM_FRAME(32, ITEM_FRAME), - PAINTING(60, ABSTRACT_HANGING), - - ABSTRACT_LIGHTNING(-1, ENTITY), - LIGHTNING_BOLT(45, ABSTRACT_LIGHTNING), - - // Arrows - ABSTRACT_ARROW(-1, ENTITY), - ARROW(2, ABSTRACT_ARROW), - SPECTRAL_ARROW(84, ABSTRACT_ARROW), - TRIDENT(93, ABSTRACT_ARROW), - - // Fireballs - ABSTRACT_FIREBALL(-1, ENTITY), - DRAGON_FIREBALL(16, ABSTRACT_FIREBALL), - FIREBALL(43, ABSTRACT_FIREBALL), - SMALL_FIREBALL(81, ABSTRACT_FIREBALL), - WITHER_SKULL(104, ABSTRACT_FIREBALL), + // Hanging entities + ABSTRACT_HANGING(ENTITY, null), + LEASH_KNOT(ABSTRACT_HANGING), + PAINTING(ABSTRACT_HANGING), + ITEM_FRAME(ABSTRACT_HANGING), + GLOW_ITEM_FRAME(ITEM_FRAME), // Projectiles - PROJECTILE_ABSTRACT(-1, ENTITY), - SNOWBALL(83, PROJECTILE_ABSTRACT), - ENDER_PEARL(90, PROJECTILE_ABSTRACT), - EGG(89, PROJECTILE_ABSTRACT), - POTION(92, PROJECTILE_ABSTRACT), - EXPERIENCE_BOTTLE(91, PROJECTILE_ABSTRACT), + PROJECTILE_ABSTRACT(ENTITY, null), // Not actually its own abstract type, but useful for categorizing + SNOWBALL(PROJECTILE_ABSTRACT), + ENDER_PEARL(PROJECTILE_ABSTRACT), + EGG(PROJECTILE_ABSTRACT), + POTION(PROJECTILE_ABSTRACT), + EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), + FIREWORK_ROCKET(PROJECTILE_ABSTRACT), + LLAMA_SPIT(PROJECTILE_ABSTRACT), + SHULKER_BULLET(PROJECTILE_ABSTRACT), + FISHING_BOBBER(PROJECTILE_ABSTRACT), + WITHER_SKULL(PROJECTILE_ABSTRACT), + DRAGON_FIREBALL(PROJECTILE_ABSTRACT), // Doesn't actually inherit fireball + + ABSTRACT_ARROW(PROJECTILE_ABSTRACT, null), + ARROW(ABSTRACT_ARROW), + SPECTRAL_ARROW(ABSTRACT_ARROW), + TRIDENT(ABSTRACT_ARROW), + + ABSTRACT_FIREBALL(ENTITY, null), + FIREBALL(ABSTRACT_FIREBALL), + SMALL_FIREBALL(ABSTRACT_FIREBALL), // Vehicles - MINECART_ABSTRACT(-1, ENTITY), - CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT), - CHEST_MINECART(51, CHESTED_MINECART_ABSTRACT), - HOPPER_MINECART(54, CHESTED_MINECART_ABSTRACT), - MINECART(50, MINECART_ABSTRACT), - FURNACE_MINECART(53, MINECART_ABSTRACT), - COMMAND_BLOCK_MINECART(52, MINECART_ABSTRACT), - TNT_MINECART(56, MINECART_ABSTRACT), - SPAWNER_MINECART(55, MINECART_ABSTRACT), - BOAT(7, ENTITY); + VEHICLE(ENTITY, null), + BOAT(VEHICLE), - private static final EntityType[] TYPES; + MINECART_ABSTRACT(VEHICLE, null), + MINECART(MINECART_ABSTRACT), + FURNACE_MINECART(MINECART_ABSTRACT), + COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), + TNT_MINECART(MINECART_ABSTRACT), + SPAWNER_MINECART(MINECART_ABSTRACT), - private final int id; + CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), + CHEST_MINECART(CHESTED_MINECART_ABSTRACT), + HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), + + // Living entities as a larger subclass + LIVINGENTITY(ENTITY, null), + ARMOR_STAND(LIVINGENTITY), + PLAYER(LIVINGENTITY), + + // Mobs as a larger subclass + ABSTRACT_INSENTIENT(LIVINGENTITY, null), + ENDER_DRAGON(ABSTRACT_INSENTIENT), + + SLIME(ABSTRACT_INSENTIENT), + MAGMA_CUBE(SLIME), + + // Ambient mobs + ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), + BAT(ABSTRACT_AMBIENT), + + // Flying mobs + ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), + GHAST(ABSTRACT_FLYING), + PHANTOM(ABSTRACT_FLYING), + + // Pathfinder mobs and its subclasses + ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null), + + ABSTRACT_GOLEM(ABSTRACT_CREATURE, null), + SNOW_GOLEM(ABSTRACT_GOLEM), + IRON_GOLEM(ABSTRACT_GOLEM), + SHULKER(ABSTRACT_GOLEM), + + // Water mobs + ABSTRACT_WATERMOB(ABSTRACT_CREATURE, null), + DOLPHIN(ABSTRACT_WATERMOB), + + SQUID(ABSTRACT_WATERMOB), + GLOW_SQUID(SQUID), + + ABSTRACT_FISHES(ABSTRACT_WATERMOB, null), + PUFFERFISH(ABSTRACT_FISHES), + + ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISHES, null), + COD(ABSTRACT_SCHOOLING_FISH), + SALMON(ABSTRACT_SCHOOLING_FISH), + TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH), + + // Ageable mobs and (tamable) animals + ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), + ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null), + VILLAGER(ABSTRACT_VILLAGER), + WANDERING_TRADER(ABSTRACT_VILLAGER), + + ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), + AXOLOTL(ABSTRACT_ANIMAL), + CHICKEN(ABSTRACT_ANIMAL), + PANDA(ABSTRACT_ANIMAL), + PIG(ABSTRACT_ANIMAL), + POLAR_BEAR(ABSTRACT_ANIMAL), + RABBIT(ABSTRACT_ANIMAL), + SHEEP(ABSTRACT_ANIMAL), + BEE(ABSTRACT_ANIMAL), + TURTLE(ABSTRACT_ANIMAL), + FOX(ABSTRACT_ANIMAL), + GOAT(ABSTRACT_ANIMAL), + HOGLIN(ABSTRACT_ANIMAL), + STRIDER(ABSTRACT_ANIMAL), + + COW(ABSTRACT_ANIMAL), + MOOSHROOM(COW), + + ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), + CAT(ABSTRACT_TAMEABLE_ANIMAL), + OCELOT(ABSTRACT_TAMEABLE_ANIMAL), + WOLF(ABSTRACT_TAMEABLE_ANIMAL), + PARROT(ABSTRACT_TAMEABLE_ANIMAL), + + ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), + HORSE(ABSTRACT_HORSE), + SKELETON_HORSE(ABSTRACT_HORSE), + ZOMBIE_HORSE(ABSTRACT_HORSE), + + CHESTED_HORSE(ABSTRACT_HORSE, null), + DONKEY(CHESTED_HORSE), + MULE(CHESTED_HORSE), + LLAMA(CHESTED_HORSE), + TRADER_LLAMA(LLAMA), + + // Monsters + ABSTRACT_MONSTER(ABSTRACT_CREATURE, null), + BLAZE(ABSTRACT_MONSTER), + CREEPER(ABSTRACT_MONSTER), + ENDERMITE(ABSTRACT_MONSTER), + ENDERMAN(ABSTRACT_MONSTER), + GIANT(ABSTRACT_MONSTER), + SILVERFISH(ABSTRACT_MONSTER), + VEX(ABSTRACT_MONSTER), + WITHER(ABSTRACT_MONSTER), + ZOGLIN(ABSTRACT_MONSTER), + + ABSTRACT_SKELETON(ABSTRACT_MONSTER, null), + SKELETON(ABSTRACT_SKELETON), + STRAY(ABSTRACT_SKELETON), + WITHER_SKELETON(ABSTRACT_SKELETON), + + ZOMBIE(ABSTRACT_MONSTER), + DROWNED(ZOMBIE), + HUSK(ZOMBIE), + ZOMBIFIED_PIGLIN(ZOMBIE), + ZOMBIE_VILLAGER(ZOMBIE), + + GUARDIAN(ABSTRACT_MONSTER), + ELDER_GUARDIAN(GUARDIAN), + + SPIDER(ABSTRACT_MONSTER), + CAVE_SPIDER(SPIDER), + + ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null), + PIGLIN(ABSTRACT_PIGLIN), + PIGLIN_BRUTE(ABSTRACT_PIGLIN), + + // Raiders + ABSTRACT_RAIDER(ABSTRACT_MONSTER, null), + WITCH(ABSTRACT_RAIDER), + RAVAGER(ABSTRACT_RAIDER), + + ABSTRACT_ILLAGER_BASE(ABSTRACT_RAIDER, null), + ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), + VINDICATOR(ABSTRACT_ILLAGER_BASE), + PILLAGER(ABSTRACT_ILLAGER_BASE), + EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), + ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER); + + private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values()); private final EntityType parent; + private final String identifier; + private int id = -1; - EntityTypes1_17(int id) { - this.id = id; - this.parent = null; + EntityTypes1_17(final EntityType parent) { + this.parent = parent; + this.identifier = "minecraft:" + name().toLowerCase(Locale.ROOT); } - EntityTypes1_17(int id, EntityType parent) { - this.id = id; + EntityTypes1_17(final EntityType parent, @Nullable final String identifier) { this.parent = parent; + this.identifier = identifier; } @Override public int getId() { + if (id == -1) { + throw new IllegalStateException("Ids have not been initialized yet (type " + name() + ")"); + } return id; } @Override - public EntityType getParent() { + public String identifier() { + Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type"); + return identifier; + } + + @Override + public @Nullable EntityType getParent() { return parent; } - @Override - public String identifier() { - throw new UnsupportedOperationException(); - } - @Override public boolean isAbstractType() { - return id != -1; + return identifier == null; } - static { - TYPES = EntityTypeUtil.toOrderedArray(values()); - } - - public static EntityType getTypeFromId(int typeId) { + public static EntityType getTypeFromId(final int typeId) { return EntityTypeUtil.getTypeFromId(TYPES, typeId, ENTITY); } + + public static void initialize(final Protocol protocol) { + EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id); + } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19.java index 93b9bbb78..885a31900 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19.java @@ -38,77 +38,144 @@ public enum EntityTypes1_19 implements EntityType { EXPERIENCE_ORB(ENTITY), EYE_OF_ENDER(ENTITY), FALLING_BLOCK(ENTITY), - FIREWORK_ROCKET(ENTITY), ITEM(ENTITY), - LLAMA_SPIT(ENTITY), TNT(ENTITY), - SHULKER_BULLET(ENTITY), - FISHING_BOBBER(ENTITY), + MARKER(ENTITY), + LIGHTNING_BOLT(ENTITY), + // Hanging entities + ABSTRACT_HANGING(ENTITY, null), + LEASH_KNOT(ABSTRACT_HANGING), + PAINTING(ABSTRACT_HANGING), + ITEM_FRAME(ABSTRACT_HANGING), + GLOW_ITEM_FRAME(ITEM_FRAME), + + // Projectiles + PROJECTILE_ABSTRACT(ENTITY, null), // Not actually its own abstract type, but useful for categorizing + SNOWBALL(PROJECTILE_ABSTRACT), + ENDER_PEARL(PROJECTILE_ABSTRACT), + EGG(PROJECTILE_ABSTRACT), + POTION(PROJECTILE_ABSTRACT), + EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), + FIREWORK_ROCKET(PROJECTILE_ABSTRACT), + LLAMA_SPIT(PROJECTILE_ABSTRACT), + SHULKER_BULLET(PROJECTILE_ABSTRACT), + FISHING_BOBBER(PROJECTILE_ABSTRACT), + WITHER_SKULL(PROJECTILE_ABSTRACT), + DRAGON_FIREBALL(PROJECTILE_ABSTRACT), // Doesn't actually inherit fireball + + ABSTRACT_ARROW(PROJECTILE_ABSTRACT, null), + ARROW(ABSTRACT_ARROW), + SPECTRAL_ARROW(ABSTRACT_ARROW), + TRIDENT(ABSTRACT_ARROW), + + ABSTRACT_FIREBALL(ENTITY, null), + FIREBALL(ABSTRACT_FIREBALL), + SMALL_FIREBALL(ABSTRACT_FIREBALL), + + // Vehicles + VEHICLE(ENTITY, null), + BOAT(VEHICLE), + + MINECART_ABSTRACT(VEHICLE, null), + MINECART(MINECART_ABSTRACT), + FURNACE_MINECART(MINECART_ABSTRACT), + COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), + TNT_MINECART(MINECART_ABSTRACT), + SPAWNER_MINECART(MINECART_ABSTRACT), + CHEST_BOAT(BOAT), + + CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), + CHEST_MINECART(CHESTED_MINECART_ABSTRACT), + HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), + + // Living entities as a larger subclass LIVINGENTITY(ENTITY, null), ARMOR_STAND(LIVINGENTITY), - MARKER(ENTITY), PLAYER(LIVINGENTITY), + // Mobs as a larger subclass ABSTRACT_INSENTIENT(LIVINGENTITY, null), ENDER_DRAGON(ABSTRACT_INSENTIENT), - BEE(ABSTRACT_INSENTIENT), + SLIME(ABSTRACT_INSENTIENT), + MAGMA_CUBE(SLIME), + // Ambient mobs + ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), + BAT(ABSTRACT_AMBIENT), + + // Flying mobs + ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), + GHAST(ABSTRACT_FLYING), + PHANTOM(ABSTRACT_FLYING), + + // Pathfinder mobs and its subclasses ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null), + ALLAY(ABSTRACT_CREATURE), - ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), - VILLAGER(ABSTRACT_AGEABLE), - WANDERING_TRADER(ABSTRACT_AGEABLE), - - // Animals - ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), - AXOLOTL(ABSTRACT_ANIMAL), - DOLPHIN(ABSTRACT_INSENTIENT), - CHICKEN(ABSTRACT_ANIMAL), - COW(ABSTRACT_ANIMAL), - MOOSHROOM(COW), - PANDA(ABSTRACT_INSENTIENT), - PIG(ABSTRACT_ANIMAL), - POLAR_BEAR(ABSTRACT_ANIMAL), - RABBIT(ABSTRACT_ANIMAL), - SHEEP(ABSTRACT_ANIMAL), - TURTLE(ABSTRACT_ANIMAL), - FOX(ABSTRACT_ANIMAL), - FROG(ABSTRACT_ANIMAL), - GOAT(ABSTRACT_ANIMAL), - - ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), - CAT(ABSTRACT_TAMEABLE_ANIMAL), - OCELOT(ABSTRACT_TAMEABLE_ANIMAL), - WOLF(ABSTRACT_TAMEABLE_ANIMAL), - - ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null), - PARROT(ABSTRACT_PARROT), - - // Horses - ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), - CHESTED_HORSE(ABSTRACT_HORSE, null), - DONKEY(CHESTED_HORSE), - MULE(CHESTED_HORSE), - LLAMA(CHESTED_HORSE), - TRADER_LLAMA(CHESTED_HORSE), - HORSE(ABSTRACT_HORSE), - SKELETON_HORSE(ABSTRACT_HORSE), - ZOMBIE_HORSE(ABSTRACT_HORSE), - - // Golem ABSTRACT_GOLEM(ABSTRACT_CREATURE, null), SNOW_GOLEM(ABSTRACT_GOLEM), IRON_GOLEM(ABSTRACT_GOLEM), SHULKER(ABSTRACT_GOLEM), - // Fish - ABSTRACT_FISHES(ABSTRACT_CREATURE, null), - COD(ABSTRACT_FISHES), + // Water mobs + ABSTRACT_WATERMOB(ABSTRACT_CREATURE, null), + DOLPHIN(ABSTRACT_WATERMOB), + + SQUID(ABSTRACT_WATERMOB), + GLOW_SQUID(SQUID), + + ABSTRACT_FISHES(ABSTRACT_WATERMOB, null), PUFFERFISH(ABSTRACT_FISHES), - SALMON(ABSTRACT_FISHES), - TROPICAL_FISH(ABSTRACT_FISHES), + TADPOLE(ABSTRACT_FISHES), + + ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISHES, null), + COD(ABSTRACT_SCHOOLING_FISH), + SALMON(ABSTRACT_SCHOOLING_FISH), + TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH), + + // Ageable mobs and (tamable) animals + ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), + ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null), + VILLAGER(ABSTRACT_VILLAGER), + WANDERING_TRADER(ABSTRACT_VILLAGER), + + ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), + AXOLOTL(ABSTRACT_ANIMAL), + CHICKEN(ABSTRACT_ANIMAL), + PANDA(ABSTRACT_ANIMAL), + PIG(ABSTRACT_ANIMAL), + POLAR_BEAR(ABSTRACT_ANIMAL), + RABBIT(ABSTRACT_ANIMAL), + SHEEP(ABSTRACT_ANIMAL), + BEE(ABSTRACT_ANIMAL), + TURTLE(ABSTRACT_ANIMAL), + FOX(ABSTRACT_ANIMAL), + FROG(ABSTRACT_ANIMAL), + GOAT(ABSTRACT_ANIMAL), + HOGLIN(ABSTRACT_ANIMAL), + STRIDER(ABSTRACT_ANIMAL), + + COW(ABSTRACT_ANIMAL), + MOOSHROOM(COW), + + ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), + CAT(ABSTRACT_TAMEABLE_ANIMAL), + OCELOT(ABSTRACT_TAMEABLE_ANIMAL), + WOLF(ABSTRACT_TAMEABLE_ANIMAL), + PARROT(ABSTRACT_TAMEABLE_ANIMAL), + + ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), + HORSE(ABSTRACT_HORSE), + SKELETON_HORSE(ABSTRACT_HORSE), + ZOMBIE_HORSE(ABSTRACT_HORSE), + + CHESTED_HORSE(ABSTRACT_HORSE, null), + DONKEY(CHESTED_HORSE), + MULE(CHESTED_HORSE), + LLAMA(CHESTED_HORSE), + TRADER_LLAMA(LLAMA), // Monsters ABSTRACT_MONSTER(ABSTRACT_CREATURE, null), @@ -119,110 +186,42 @@ public enum EntityTypes1_19 implements EntityType { GIANT(ABSTRACT_MONSTER), SILVERFISH(ABSTRACT_MONSTER), VEX(ABSTRACT_MONSTER), - WITCH(ABSTRACT_MONSTER), WITHER(ABSTRACT_MONSTER), - RAVAGER(ABSTRACT_MONSTER), - - ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null), - - PIGLIN(ABSTRACT_PIGLIN), - PIGLIN_BRUTE(ABSTRACT_PIGLIN), - - HOGLIN(ABSTRACT_ANIMAL), - STRIDER(ABSTRACT_ANIMAL), - TADPOLE(ABSTRACT_FISHES), ZOGLIN(ABSTRACT_MONSTER), WARDEN(ABSTRACT_MONSTER), - // Illagers - ABSTRACT_ILLAGER_BASE(ABSTRACT_MONSTER, null), - ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), - EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), - ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER), - VINDICATOR(ABSTRACT_ILLAGER_BASE), - PILLAGER(ABSTRACT_ILLAGER_BASE), - - // Skeletons ABSTRACT_SKELETON(ABSTRACT_MONSTER, null), SKELETON(ABSTRACT_SKELETON), STRAY(ABSTRACT_SKELETON), WITHER_SKELETON(ABSTRACT_SKELETON), - // Guardians - GUARDIAN(ABSTRACT_MONSTER), - ELDER_GUARDIAN(GUARDIAN), - - // Spiders - SPIDER(ABSTRACT_MONSTER), - CAVE_SPIDER(SPIDER), - - // Zombies ZOMBIE(ABSTRACT_MONSTER), DROWNED(ZOMBIE), HUSK(ZOMBIE), ZOMBIFIED_PIGLIN(ZOMBIE), ZOMBIE_VILLAGER(ZOMBIE), - // Flying entities - ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), - GHAST(ABSTRACT_FLYING), - PHANTOM(ABSTRACT_FLYING), + GUARDIAN(ABSTRACT_MONSTER), + ELDER_GUARDIAN(GUARDIAN), - ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), - BAT(ABSTRACT_AMBIENT), - ALLAY(ABSTRACT_CREATURE), + SPIDER(ABSTRACT_MONSTER), + CAVE_SPIDER(SPIDER), - ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null), - SQUID(ABSTRACT_WATERMOB), - GLOW_SQUID(SQUID), + ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null), + PIGLIN(ABSTRACT_PIGLIN), + PIGLIN_BRUTE(ABSTRACT_PIGLIN), - // Slimes - SLIME(ABSTRACT_INSENTIENT), - MAGMA_CUBE(SLIME), + // Raiders + ABSTRACT_RAIDER(ABSTRACT_MONSTER, null), + WITCH(ABSTRACT_RAIDER), + RAVAGER(ABSTRACT_RAIDER), - // Hangable objects - ABSTRACT_HANGING(ENTITY, null), - LEASH_KNOT(ABSTRACT_HANGING), - ITEM_FRAME(ABSTRACT_HANGING), - GLOW_ITEM_FRAME(ITEM_FRAME), - PAINTING(ABSTRACT_HANGING), - - ABSTRACT_LIGHTNING(ENTITY, null), - LIGHTNING_BOLT(ABSTRACT_LIGHTNING), - - // Arrows - ABSTRACT_ARROW(ENTITY, null), - ARROW(ABSTRACT_ARROW), - SPECTRAL_ARROW(ABSTRACT_ARROW), - TRIDENT(ABSTRACT_ARROW), - - // Fireballs - ABSTRACT_FIREBALL(ENTITY, null), - DRAGON_FIREBALL(ABSTRACT_FIREBALL), - FIREBALL(ABSTRACT_FIREBALL), - SMALL_FIREBALL(ABSTRACT_FIREBALL), - WITHER_SKULL(ABSTRACT_FIREBALL), - - // Projectiles - PROJECTILE_ABSTRACT(ENTITY, null), - SNOWBALL(PROJECTILE_ABSTRACT), - ENDER_PEARL(PROJECTILE_ABSTRACT), - EGG(PROJECTILE_ABSTRACT), - POTION(PROJECTILE_ABSTRACT), - EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), - - // Vehicles - MINECART_ABSTRACT(ENTITY, null), - CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), - CHEST_MINECART(CHESTED_MINECART_ABSTRACT), - HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), - MINECART(MINECART_ABSTRACT), - FURNACE_MINECART(MINECART_ABSTRACT), - COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), - TNT_MINECART(MINECART_ABSTRACT), - SPAWNER_MINECART(MINECART_ABSTRACT), - BOAT(ENTITY), - CHEST_BOAT(BOAT); + ABSTRACT_ILLAGER_BASE(ABSTRACT_RAIDER, null), + ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), + VINDICATOR(ABSTRACT_ILLAGER_BASE), + PILLAGER(ABSTRACT_ILLAGER_BASE), + EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), + ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER); private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values()); private final EntityType parent; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_3.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_3.java index e06ebce54..646de4ba7 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_3.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_3.java @@ -38,78 +38,145 @@ public enum EntityTypes1_19_3 implements EntityType { EXPERIENCE_ORB(ENTITY), EYE_OF_ENDER(ENTITY), FALLING_BLOCK(ENTITY), - FIREWORK_ROCKET(ENTITY), ITEM(ENTITY), - LLAMA_SPIT(ENTITY), TNT(ENTITY), - SHULKER_BULLET(ENTITY), - FISHING_BOBBER(ENTITY), + MARKER(ENTITY), + LIGHTNING_BOLT(ENTITY), + // Hanging entities + ABSTRACT_HANGING(ENTITY, null), + LEASH_KNOT(ABSTRACT_HANGING), + PAINTING(ABSTRACT_HANGING), + ITEM_FRAME(ABSTRACT_HANGING), + GLOW_ITEM_FRAME(ITEM_FRAME), + + // Projectiles + PROJECTILE_ABSTRACT(ENTITY, null), // Not actually its own abstract type, but useful for categorizing + SNOWBALL(PROJECTILE_ABSTRACT), + ENDER_PEARL(PROJECTILE_ABSTRACT), + EGG(PROJECTILE_ABSTRACT), + POTION(PROJECTILE_ABSTRACT), + EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), + FIREWORK_ROCKET(PROJECTILE_ABSTRACT), + LLAMA_SPIT(PROJECTILE_ABSTRACT), + SHULKER_BULLET(PROJECTILE_ABSTRACT), + FISHING_BOBBER(PROJECTILE_ABSTRACT), + WITHER_SKULL(PROJECTILE_ABSTRACT), + DRAGON_FIREBALL(PROJECTILE_ABSTRACT), // Doesn't actually inherit fireball + + ABSTRACT_ARROW(PROJECTILE_ABSTRACT, null), + ARROW(ABSTRACT_ARROW), + SPECTRAL_ARROW(ABSTRACT_ARROW), + TRIDENT(ABSTRACT_ARROW), + + ABSTRACT_FIREBALL(ENTITY, null), + FIREBALL(ABSTRACT_FIREBALL), + SMALL_FIREBALL(ABSTRACT_FIREBALL), + + // Vehicles + VEHICLE(ENTITY, null), + BOAT(VEHICLE), + + MINECART_ABSTRACT(VEHICLE, null), + MINECART(MINECART_ABSTRACT), + FURNACE_MINECART(MINECART_ABSTRACT), + COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), + TNT_MINECART(MINECART_ABSTRACT), + SPAWNER_MINECART(MINECART_ABSTRACT), + CHEST_BOAT(BOAT), + + CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), + CHEST_MINECART(CHESTED_MINECART_ABSTRACT), + HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), + + // Living entities as a larger subclass LIVINGENTITY(ENTITY, null), ARMOR_STAND(LIVINGENTITY), - MARKER(ENTITY), PLAYER(LIVINGENTITY), + // Mobs as a larger subclass ABSTRACT_INSENTIENT(LIVINGENTITY, null), ENDER_DRAGON(ABSTRACT_INSENTIENT), - BEE(ABSTRACT_INSENTIENT), + SLIME(ABSTRACT_INSENTIENT), + MAGMA_CUBE(SLIME), + // Ambient mobs + ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), + BAT(ABSTRACT_AMBIENT), + + // Flying mobs + ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), + GHAST(ABSTRACT_FLYING), + PHANTOM(ABSTRACT_FLYING), + + // Pathfinder mobs and its subclasses ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null), + ALLAY(ABSTRACT_CREATURE), - ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), - VILLAGER(ABSTRACT_AGEABLE), - WANDERING_TRADER(ABSTRACT_AGEABLE), - - // Animals - ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), - AXOLOTL(ABSTRACT_ANIMAL), - DOLPHIN(ABSTRACT_INSENTIENT), - CHICKEN(ABSTRACT_ANIMAL), - COW(ABSTRACT_ANIMAL), - MOOSHROOM(COW), - PANDA(ABSTRACT_INSENTIENT), - PIG(ABSTRACT_ANIMAL), - POLAR_BEAR(ABSTRACT_ANIMAL), - RABBIT(ABSTRACT_ANIMAL), - SHEEP(ABSTRACT_ANIMAL), - TURTLE(ABSTRACT_ANIMAL), - FOX(ABSTRACT_ANIMAL), - FROG(ABSTRACT_ANIMAL), - GOAT(ABSTRACT_ANIMAL), - - ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), - CAT(ABSTRACT_TAMEABLE_ANIMAL), - OCELOT(ABSTRACT_TAMEABLE_ANIMAL), - WOLF(ABSTRACT_TAMEABLE_ANIMAL), - - ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null), - PARROT(ABSTRACT_PARROT), - - // Horses - ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), - CHESTED_HORSE(ABSTRACT_HORSE, null), - DONKEY(CHESTED_HORSE), - MULE(CHESTED_HORSE), - LLAMA(CHESTED_HORSE), - TRADER_LLAMA(CHESTED_HORSE), - HORSE(ABSTRACT_HORSE), - SKELETON_HORSE(ABSTRACT_HORSE), - ZOMBIE_HORSE(ABSTRACT_HORSE), - CAMEL(ABSTRACT_HORSE), - - // Golem ABSTRACT_GOLEM(ABSTRACT_CREATURE, null), SNOW_GOLEM(ABSTRACT_GOLEM), IRON_GOLEM(ABSTRACT_GOLEM), SHULKER(ABSTRACT_GOLEM), - // Fish - ABSTRACT_FISHES(ABSTRACT_CREATURE, null), - COD(ABSTRACT_FISHES), + // Water mobs + ABSTRACT_WATERMOB(ABSTRACT_CREATURE, null), + DOLPHIN(ABSTRACT_WATERMOB), + + SQUID(ABSTRACT_WATERMOB), + GLOW_SQUID(SQUID), + + ABSTRACT_FISHES(ABSTRACT_WATERMOB, null), PUFFERFISH(ABSTRACT_FISHES), - SALMON(ABSTRACT_FISHES), - TROPICAL_FISH(ABSTRACT_FISHES), + TADPOLE(ABSTRACT_FISHES), + + ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISHES, null), + COD(ABSTRACT_SCHOOLING_FISH), + SALMON(ABSTRACT_SCHOOLING_FISH), + TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH), + + // Ageable mobs and (tamable) animals + ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), + ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null), + VILLAGER(ABSTRACT_VILLAGER), + WANDERING_TRADER(ABSTRACT_VILLAGER), + + ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), + AXOLOTL(ABSTRACT_ANIMAL), + CHICKEN(ABSTRACT_ANIMAL), + PANDA(ABSTRACT_ANIMAL), + PIG(ABSTRACT_ANIMAL), + POLAR_BEAR(ABSTRACT_ANIMAL), + RABBIT(ABSTRACT_ANIMAL), + SHEEP(ABSTRACT_ANIMAL), + BEE(ABSTRACT_ANIMAL), + TURTLE(ABSTRACT_ANIMAL), + FOX(ABSTRACT_ANIMAL), + FROG(ABSTRACT_ANIMAL), + GOAT(ABSTRACT_ANIMAL), + HOGLIN(ABSTRACT_ANIMAL), + STRIDER(ABSTRACT_ANIMAL), + + COW(ABSTRACT_ANIMAL), + MOOSHROOM(COW), + + ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), + CAT(ABSTRACT_TAMEABLE_ANIMAL), + OCELOT(ABSTRACT_TAMEABLE_ANIMAL), + WOLF(ABSTRACT_TAMEABLE_ANIMAL), + PARROT(ABSTRACT_TAMEABLE_ANIMAL), + + ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), + HORSE(ABSTRACT_HORSE), + SKELETON_HORSE(ABSTRACT_HORSE), + ZOMBIE_HORSE(ABSTRACT_HORSE), + CAMEL(ABSTRACT_HORSE), + + CHESTED_HORSE(ABSTRACT_HORSE, null), + DONKEY(CHESTED_HORSE), + MULE(CHESTED_HORSE), + LLAMA(CHESTED_HORSE), + TRADER_LLAMA(LLAMA), // Monsters ABSTRACT_MONSTER(ABSTRACT_CREATURE, null), @@ -120,110 +187,42 @@ public enum EntityTypes1_19_3 implements EntityType { GIANT(ABSTRACT_MONSTER), SILVERFISH(ABSTRACT_MONSTER), VEX(ABSTRACT_MONSTER), - WITCH(ABSTRACT_MONSTER), WITHER(ABSTRACT_MONSTER), - RAVAGER(ABSTRACT_MONSTER), - - ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null), - - PIGLIN(ABSTRACT_PIGLIN), - PIGLIN_BRUTE(ABSTRACT_PIGLIN), - - HOGLIN(ABSTRACT_ANIMAL), - STRIDER(ABSTRACT_ANIMAL), - TADPOLE(ABSTRACT_FISHES), ZOGLIN(ABSTRACT_MONSTER), WARDEN(ABSTRACT_MONSTER), - // Illagers - ABSTRACT_ILLAGER_BASE(ABSTRACT_MONSTER, null), - ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), - EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), - ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER), - VINDICATOR(ABSTRACT_ILLAGER_BASE), - PILLAGER(ABSTRACT_ILLAGER_BASE), - - // Skeletons ABSTRACT_SKELETON(ABSTRACT_MONSTER, null), SKELETON(ABSTRACT_SKELETON), STRAY(ABSTRACT_SKELETON), WITHER_SKELETON(ABSTRACT_SKELETON), - // Guardians - GUARDIAN(ABSTRACT_MONSTER), - ELDER_GUARDIAN(GUARDIAN), - - // Spiders - SPIDER(ABSTRACT_MONSTER), - CAVE_SPIDER(SPIDER), - - // Zombies ZOMBIE(ABSTRACT_MONSTER), DROWNED(ZOMBIE), HUSK(ZOMBIE), ZOMBIFIED_PIGLIN(ZOMBIE), ZOMBIE_VILLAGER(ZOMBIE), - // Flying entities - ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), - GHAST(ABSTRACT_FLYING), - PHANTOM(ABSTRACT_FLYING), + GUARDIAN(ABSTRACT_MONSTER), + ELDER_GUARDIAN(GUARDIAN), - ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), - BAT(ABSTRACT_AMBIENT), - ALLAY(ABSTRACT_CREATURE), + SPIDER(ABSTRACT_MONSTER), + CAVE_SPIDER(SPIDER), - ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null), - SQUID(ABSTRACT_WATERMOB), - GLOW_SQUID(SQUID), + ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null), + PIGLIN(ABSTRACT_PIGLIN), + PIGLIN_BRUTE(ABSTRACT_PIGLIN), - // Slimes - SLIME(ABSTRACT_INSENTIENT), - MAGMA_CUBE(SLIME), + // Raiders + ABSTRACT_RAIDER(ABSTRACT_MONSTER, null), + WITCH(ABSTRACT_RAIDER), + RAVAGER(ABSTRACT_RAIDER), - // Hangable objects - ABSTRACT_HANGING(ENTITY, null), - LEASH_KNOT(ABSTRACT_HANGING), - ITEM_FRAME(ABSTRACT_HANGING), - GLOW_ITEM_FRAME(ITEM_FRAME), - PAINTING(ABSTRACT_HANGING), - - ABSTRACT_LIGHTNING(ENTITY, null), - LIGHTNING_BOLT(ABSTRACT_LIGHTNING), - - // Arrows - ABSTRACT_ARROW(ENTITY, null), - ARROW(ABSTRACT_ARROW), - SPECTRAL_ARROW(ABSTRACT_ARROW), - TRIDENT(ABSTRACT_ARROW), - - // Fireballs - ABSTRACT_FIREBALL(ENTITY, null), - DRAGON_FIREBALL(ABSTRACT_FIREBALL), - FIREBALL(ABSTRACT_FIREBALL), - SMALL_FIREBALL(ABSTRACT_FIREBALL), - WITHER_SKULL(ABSTRACT_FIREBALL), - - // Projectiles - PROJECTILE_ABSTRACT(ENTITY, null), - SNOWBALL(PROJECTILE_ABSTRACT), - ENDER_PEARL(PROJECTILE_ABSTRACT), - EGG(PROJECTILE_ABSTRACT), - POTION(PROJECTILE_ABSTRACT), - EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), - - // Vehicles - MINECART_ABSTRACT(ENTITY, null), - CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), - CHEST_MINECART(CHESTED_MINECART_ABSTRACT), - HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), - MINECART(MINECART_ABSTRACT), - FURNACE_MINECART(MINECART_ABSTRACT), - COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), - TNT_MINECART(MINECART_ABSTRACT), - SPAWNER_MINECART(MINECART_ABSTRACT), - BOAT(ENTITY), - CHEST_BOAT(BOAT); + ABSTRACT_ILLAGER_BASE(ABSTRACT_RAIDER, null), + ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), + VINDICATOR(ABSTRACT_ILLAGER_BASE), + PILLAGER(ABSTRACT_ILLAGER_BASE), + EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), + ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER); private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values()); private final EntityType parent; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_4.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_4.java index 6f48994e3..da6a0420b 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_4.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_19_4.java @@ -38,85 +38,152 @@ public enum EntityTypes1_19_4 implements EntityType { EXPERIENCE_ORB(ENTITY), EYE_OF_ENDER(ENTITY), FALLING_BLOCK(ENTITY), - FIREWORK_ROCKET(ENTITY), ITEM(ENTITY), - LLAMA_SPIT(ENTITY), TNT(ENTITY), - SHULKER_BULLET(ENTITY), - FISHING_BOBBER(ENTITY), - - LIVINGENTITY(ENTITY, null), - ARMOR_STAND(LIVINGENTITY), MARKER(ENTITY), - PLAYER(LIVINGENTITY), + LIGHTNING_BOLT(ENTITY), + INTERACTION(ENTITY), DISPLAY(ENTITY, null), BLOCK_DISPLAY(DISPLAY), ITEM_DISPLAY(DISPLAY), TEXT_DISPLAY(DISPLAY), - INTERACTION(ENTITY), + // Hanging entities + ABSTRACT_HANGING(ENTITY, null), + LEASH_KNOT(ABSTRACT_HANGING), + PAINTING(ABSTRACT_HANGING), + ITEM_FRAME(ABSTRACT_HANGING), + GLOW_ITEM_FRAME(ITEM_FRAME), + + // Projectiles + PROJECTILE_ABSTRACT(ENTITY, null), // Not actually its own abstract type, but useful for categorizing + SNOWBALL(PROJECTILE_ABSTRACT), + ENDER_PEARL(PROJECTILE_ABSTRACT), + EGG(PROJECTILE_ABSTRACT), + POTION(PROJECTILE_ABSTRACT), + EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), + FIREWORK_ROCKET(PROJECTILE_ABSTRACT), + LLAMA_SPIT(PROJECTILE_ABSTRACT), + SHULKER_BULLET(PROJECTILE_ABSTRACT), + FISHING_BOBBER(PROJECTILE_ABSTRACT), + WITHER_SKULL(PROJECTILE_ABSTRACT), + DRAGON_FIREBALL(PROJECTILE_ABSTRACT), // Doesn't actually inherit fireball + + ABSTRACT_ARROW(PROJECTILE_ABSTRACT, null), + ARROW(ABSTRACT_ARROW), + SPECTRAL_ARROW(ABSTRACT_ARROW), + TRIDENT(ABSTRACT_ARROW), + + ABSTRACT_FIREBALL(ENTITY, null), + FIREBALL(ABSTRACT_FIREBALL), + SMALL_FIREBALL(ABSTRACT_FIREBALL), + + // Vehicles + VEHICLE(ENTITY, null), + BOAT(VEHICLE), + + MINECART_ABSTRACT(VEHICLE, null), + MINECART(MINECART_ABSTRACT), + FURNACE_MINECART(MINECART_ABSTRACT), + COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), + TNT_MINECART(MINECART_ABSTRACT), + SPAWNER_MINECART(MINECART_ABSTRACT), + CHEST_BOAT(BOAT), + + CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), + CHEST_MINECART(CHESTED_MINECART_ABSTRACT), + HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), + + // Living entities as a larger subclass + LIVINGENTITY(ENTITY, null), + ARMOR_STAND(LIVINGENTITY), + PLAYER(LIVINGENTITY), + + // Mobs as a larger subclass ABSTRACT_INSENTIENT(LIVINGENTITY, null), ENDER_DRAGON(ABSTRACT_INSENTIENT), - BEE(ABSTRACT_INSENTIENT), + SLIME(ABSTRACT_INSENTIENT), + MAGMA_CUBE(SLIME), + // Ambient mobs + ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), + BAT(ABSTRACT_AMBIENT), + + // Flying mobs + ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), + GHAST(ABSTRACT_FLYING), + PHANTOM(ABSTRACT_FLYING), + + // Pathfinder mobs and its subclasses ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null), + ALLAY(ABSTRACT_CREATURE), - ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), - VILLAGER(ABSTRACT_AGEABLE), - WANDERING_TRADER(ABSTRACT_AGEABLE), - - // Animals - ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), - AXOLOTL(ABSTRACT_ANIMAL), - DOLPHIN(ABSTRACT_INSENTIENT), - CHICKEN(ABSTRACT_ANIMAL), - COW(ABSTRACT_ANIMAL), - MOOSHROOM(COW), - PANDA(ABSTRACT_INSENTIENT), - PIG(ABSTRACT_ANIMAL), - POLAR_BEAR(ABSTRACT_ANIMAL), - RABBIT(ABSTRACT_ANIMAL), - SHEEP(ABSTRACT_ANIMAL), - TURTLE(ABSTRACT_ANIMAL), - FOX(ABSTRACT_ANIMAL), - FROG(ABSTRACT_ANIMAL), - GOAT(ABSTRACT_ANIMAL), - SNIFFER(ABSTRACT_ANIMAL), - - ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), - CAT(ABSTRACT_TAMEABLE_ANIMAL), - OCELOT(ABSTRACT_TAMEABLE_ANIMAL), - WOLF(ABSTRACT_TAMEABLE_ANIMAL), - - ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null), - PARROT(ABSTRACT_PARROT), - - // Horses - ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), - CHESTED_HORSE(ABSTRACT_HORSE, null), - DONKEY(CHESTED_HORSE), - MULE(CHESTED_HORSE), - LLAMA(CHESTED_HORSE), - TRADER_LLAMA(CHESTED_HORSE), - HORSE(ABSTRACT_HORSE), - SKELETON_HORSE(ABSTRACT_HORSE), - ZOMBIE_HORSE(ABSTRACT_HORSE), - CAMEL(ABSTRACT_HORSE), - - // Golem ABSTRACT_GOLEM(ABSTRACT_CREATURE, null), SNOW_GOLEM(ABSTRACT_GOLEM), IRON_GOLEM(ABSTRACT_GOLEM), SHULKER(ABSTRACT_GOLEM), - // Fish - ABSTRACT_FISHES(ABSTRACT_CREATURE, null), - COD(ABSTRACT_FISHES), + // Water mobs + ABSTRACT_WATERMOB(ABSTRACT_CREATURE, null), + DOLPHIN(ABSTRACT_WATERMOB), + + SQUID(ABSTRACT_WATERMOB), + GLOW_SQUID(SQUID), + + ABSTRACT_FISHES(ABSTRACT_WATERMOB, null), PUFFERFISH(ABSTRACT_FISHES), - SALMON(ABSTRACT_FISHES), - TROPICAL_FISH(ABSTRACT_FISHES), + TADPOLE(ABSTRACT_FISHES), + + ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISHES, null), + COD(ABSTRACT_SCHOOLING_FISH), + SALMON(ABSTRACT_SCHOOLING_FISH), + TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH), + + // Ageable mobs and (tamable) animals + ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), + ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null), + VILLAGER(ABSTRACT_VILLAGER), + WANDERING_TRADER(ABSTRACT_VILLAGER), + + ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), + AXOLOTL(ABSTRACT_ANIMAL), + CHICKEN(ABSTRACT_ANIMAL), + PANDA(ABSTRACT_ANIMAL), + PIG(ABSTRACT_ANIMAL), + POLAR_BEAR(ABSTRACT_ANIMAL), + RABBIT(ABSTRACT_ANIMAL), + SHEEP(ABSTRACT_ANIMAL), + BEE(ABSTRACT_ANIMAL), + TURTLE(ABSTRACT_ANIMAL), + FOX(ABSTRACT_ANIMAL), + FROG(ABSTRACT_ANIMAL), + GOAT(ABSTRACT_ANIMAL), + HOGLIN(ABSTRACT_ANIMAL), + STRIDER(ABSTRACT_ANIMAL), + SNIFFER(ABSTRACT_ANIMAL), + + COW(ABSTRACT_ANIMAL), + MOOSHROOM(COW), + + ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), + CAT(ABSTRACT_TAMEABLE_ANIMAL), + OCELOT(ABSTRACT_TAMEABLE_ANIMAL), + WOLF(ABSTRACT_TAMEABLE_ANIMAL), + PARROT(ABSTRACT_TAMEABLE_ANIMAL), + + ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), + HORSE(ABSTRACT_HORSE), + SKELETON_HORSE(ABSTRACT_HORSE), + ZOMBIE_HORSE(ABSTRACT_HORSE), + CAMEL(ABSTRACT_HORSE), + + CHESTED_HORSE(ABSTRACT_HORSE, null), + DONKEY(CHESTED_HORSE), + MULE(CHESTED_HORSE), + LLAMA(CHESTED_HORSE), + TRADER_LLAMA(LLAMA), // Monsters ABSTRACT_MONSTER(ABSTRACT_CREATURE, null), @@ -127,110 +194,42 @@ public enum EntityTypes1_19_4 implements EntityType { GIANT(ABSTRACT_MONSTER), SILVERFISH(ABSTRACT_MONSTER), VEX(ABSTRACT_MONSTER), - WITCH(ABSTRACT_MONSTER), WITHER(ABSTRACT_MONSTER), - RAVAGER(ABSTRACT_MONSTER), - - ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null), - - PIGLIN(ABSTRACT_PIGLIN), - PIGLIN_BRUTE(ABSTRACT_PIGLIN), - - HOGLIN(ABSTRACT_ANIMAL), - STRIDER(ABSTRACT_ANIMAL), - TADPOLE(ABSTRACT_FISHES), ZOGLIN(ABSTRACT_MONSTER), WARDEN(ABSTRACT_MONSTER), - // Illagers - ABSTRACT_ILLAGER_BASE(ABSTRACT_MONSTER, null), - ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), - EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), - ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER), - VINDICATOR(ABSTRACT_ILLAGER_BASE), - PILLAGER(ABSTRACT_ILLAGER_BASE), - - // Skeletons ABSTRACT_SKELETON(ABSTRACT_MONSTER, null), SKELETON(ABSTRACT_SKELETON), STRAY(ABSTRACT_SKELETON), WITHER_SKELETON(ABSTRACT_SKELETON), - // Guardians - GUARDIAN(ABSTRACT_MONSTER), - ELDER_GUARDIAN(GUARDIAN), - - // Spiders - SPIDER(ABSTRACT_MONSTER), - CAVE_SPIDER(SPIDER), - - // Zombies ZOMBIE(ABSTRACT_MONSTER), DROWNED(ZOMBIE), HUSK(ZOMBIE), ZOMBIFIED_PIGLIN(ZOMBIE), ZOMBIE_VILLAGER(ZOMBIE), - // Flying entities - ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), - GHAST(ABSTRACT_FLYING), - PHANTOM(ABSTRACT_FLYING), + GUARDIAN(ABSTRACT_MONSTER), + ELDER_GUARDIAN(GUARDIAN), - ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), - BAT(ABSTRACT_AMBIENT), - ALLAY(ABSTRACT_CREATURE), + SPIDER(ABSTRACT_MONSTER), + CAVE_SPIDER(SPIDER), - ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null), - SQUID(ABSTRACT_WATERMOB), - GLOW_SQUID(SQUID), + ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null), + PIGLIN(ABSTRACT_PIGLIN), + PIGLIN_BRUTE(ABSTRACT_PIGLIN), - // Slimes - SLIME(ABSTRACT_INSENTIENT), - MAGMA_CUBE(SLIME), + // Raiders + ABSTRACT_RAIDER(ABSTRACT_MONSTER, null), + WITCH(ABSTRACT_RAIDER), + RAVAGER(ABSTRACT_RAIDER), - // Hangable objects - ABSTRACT_HANGING(ENTITY, null), - LEASH_KNOT(ABSTRACT_HANGING), - ITEM_FRAME(ABSTRACT_HANGING), - GLOW_ITEM_FRAME(ITEM_FRAME), - PAINTING(ABSTRACT_HANGING), - - ABSTRACT_LIGHTNING(ENTITY, null), - LIGHTNING_BOLT(ABSTRACT_LIGHTNING), - - // Arrows - ABSTRACT_ARROW(ENTITY, null), - ARROW(ABSTRACT_ARROW), - SPECTRAL_ARROW(ABSTRACT_ARROW), - TRIDENT(ABSTRACT_ARROW), - - // Fireballs - ABSTRACT_FIREBALL(ENTITY, null), - DRAGON_FIREBALL(ABSTRACT_FIREBALL), - FIREBALL(ABSTRACT_FIREBALL), - SMALL_FIREBALL(ABSTRACT_FIREBALL), - WITHER_SKULL(ABSTRACT_FIREBALL), - - // Projectiles - PROJECTILE_ABSTRACT(ENTITY, null), - SNOWBALL(PROJECTILE_ABSTRACT), - ENDER_PEARL(PROJECTILE_ABSTRACT), - EGG(PROJECTILE_ABSTRACT), - POTION(PROJECTILE_ABSTRACT), - EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), - - // Vehicles - MINECART_ABSTRACT(ENTITY, null), - CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), - CHEST_MINECART(CHESTED_MINECART_ABSTRACT), - HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), - MINECART(MINECART_ABSTRACT), - FURNACE_MINECART(MINECART_ABSTRACT), - COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), - TNT_MINECART(MINECART_ABSTRACT), - SPAWNER_MINECART(MINECART_ABSTRACT), - BOAT(ENTITY), - CHEST_BOAT(BOAT); + ABSTRACT_ILLAGER_BASE(ABSTRACT_RAIDER, null), + ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), + VINDICATOR(ABSTRACT_ILLAGER_BASE), + PILLAGER(ABSTRACT_ILLAGER_BASE), + EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), + ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER); private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values()); private final EntityType parent; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_3.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_3.java index 63b651f4c..14fb9ea6b 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_3.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_3.java @@ -38,85 +38,153 @@ public enum EntityTypes1_20_3 implements EntityType { EXPERIENCE_ORB(ENTITY), EYE_OF_ENDER(ENTITY), FALLING_BLOCK(ENTITY), - FIREWORK_ROCKET(ENTITY), ITEM(ENTITY), - LLAMA_SPIT(ENTITY), TNT(ENTITY), - SHULKER_BULLET(ENTITY), - FISHING_BOBBER(ENTITY), - - LIVINGENTITY(ENTITY, null), - ARMOR_STAND(LIVINGENTITY), MARKER(ENTITY), - PLAYER(LIVINGENTITY), + LIGHTNING_BOLT(ENTITY), + INTERACTION(ENTITY), DISPLAY(ENTITY, null), BLOCK_DISPLAY(DISPLAY), ITEM_DISPLAY(DISPLAY), TEXT_DISPLAY(DISPLAY), - INTERACTION(ENTITY), + // Hanging entities + ABSTRACT_HANGING(ENTITY, null), + LEASH_KNOT(ABSTRACT_HANGING), + PAINTING(ABSTRACT_HANGING), + ITEM_FRAME(ABSTRACT_HANGING), + GLOW_ITEM_FRAME(ITEM_FRAME), + + // Projectiles + PROJECTILE_ABSTRACT(ENTITY, null), // Not actually its own abstract type, but useful for categorizing + SNOWBALL(PROJECTILE_ABSTRACT), + ENDER_PEARL(PROJECTILE_ABSTRACT), + EGG(PROJECTILE_ABSTRACT), + POTION(PROJECTILE_ABSTRACT), + EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), + FIREWORK_ROCKET(PROJECTILE_ABSTRACT), + LLAMA_SPIT(PROJECTILE_ABSTRACT), + SHULKER_BULLET(PROJECTILE_ABSTRACT), + FISHING_BOBBER(PROJECTILE_ABSTRACT), + WITHER_SKULL(PROJECTILE_ABSTRACT), + DRAGON_FIREBALL(PROJECTILE_ABSTRACT), // Doesn't actually inherit fireball + WIND_CHARGE(PROJECTILE_ABSTRACT), + + ABSTRACT_ARROW(PROJECTILE_ABSTRACT, null), + ARROW(ABSTRACT_ARROW), + SPECTRAL_ARROW(ABSTRACT_ARROW), + TRIDENT(ABSTRACT_ARROW), + + ABSTRACT_FIREBALL(ENTITY, null), + FIREBALL(ABSTRACT_FIREBALL), + SMALL_FIREBALL(ABSTRACT_FIREBALL), + + // Vehicles + VEHICLE(ENTITY, null), + BOAT(VEHICLE), + + MINECART_ABSTRACT(VEHICLE, null), + MINECART(MINECART_ABSTRACT), + FURNACE_MINECART(MINECART_ABSTRACT), + COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), + TNT_MINECART(MINECART_ABSTRACT), + SPAWNER_MINECART(MINECART_ABSTRACT), + CHEST_BOAT(BOAT), + + CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), + CHEST_MINECART(CHESTED_MINECART_ABSTRACT), + HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), + + // Living entities as a larger subclass + LIVINGENTITY(ENTITY, null), + ARMOR_STAND(LIVINGENTITY), + PLAYER(LIVINGENTITY), + + // Mobs as a larger subclass ABSTRACT_INSENTIENT(LIVINGENTITY, null), ENDER_DRAGON(ABSTRACT_INSENTIENT), - BEE(ABSTRACT_INSENTIENT), + SLIME(ABSTRACT_INSENTIENT), + MAGMA_CUBE(SLIME), + // Ambient mobs + ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), + BAT(ABSTRACT_AMBIENT), + + // Flying mobs + ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), + GHAST(ABSTRACT_FLYING), + PHANTOM(ABSTRACT_FLYING), + + // Pathfinder mobs and its subclasses ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null), + ALLAY(ABSTRACT_CREATURE), - ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), - VILLAGER(ABSTRACT_AGEABLE), - WANDERING_TRADER(ABSTRACT_AGEABLE), - - // Animals - ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), - AXOLOTL(ABSTRACT_ANIMAL), - DOLPHIN(ABSTRACT_INSENTIENT), - CHICKEN(ABSTRACT_ANIMAL), - COW(ABSTRACT_ANIMAL), - MOOSHROOM(COW), - PANDA(ABSTRACT_INSENTIENT), - PIG(ABSTRACT_ANIMAL), - POLAR_BEAR(ABSTRACT_ANIMAL), - RABBIT(ABSTRACT_ANIMAL), - SHEEP(ABSTRACT_ANIMAL), - TURTLE(ABSTRACT_ANIMAL), - FOX(ABSTRACT_ANIMAL), - FROG(ABSTRACT_ANIMAL), - GOAT(ABSTRACT_ANIMAL), - SNIFFER(ABSTRACT_ANIMAL), - - ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), - CAT(ABSTRACT_TAMEABLE_ANIMAL), - OCELOT(ABSTRACT_TAMEABLE_ANIMAL), - WOLF(ABSTRACT_TAMEABLE_ANIMAL), - - ABSTRACT_PARROT(ABSTRACT_TAMEABLE_ANIMAL, null), - PARROT(ABSTRACT_PARROT), - - // Horses - ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), - CHESTED_HORSE(ABSTRACT_HORSE, null), - DONKEY(CHESTED_HORSE), - MULE(CHESTED_HORSE), - LLAMA(CHESTED_HORSE), - TRADER_LLAMA(CHESTED_HORSE), - HORSE(ABSTRACT_HORSE), - SKELETON_HORSE(ABSTRACT_HORSE), - ZOMBIE_HORSE(ABSTRACT_HORSE), - CAMEL(ABSTRACT_HORSE), - - // Golem ABSTRACT_GOLEM(ABSTRACT_CREATURE, null), SNOW_GOLEM(ABSTRACT_GOLEM), IRON_GOLEM(ABSTRACT_GOLEM), SHULKER(ABSTRACT_GOLEM), - // Fish - ABSTRACT_FISHES(ABSTRACT_CREATURE, null), - COD(ABSTRACT_FISHES), + // Water mobs + ABSTRACT_WATERMOB(ABSTRACT_CREATURE, null), + DOLPHIN(ABSTRACT_WATERMOB), + + SQUID(ABSTRACT_WATERMOB), + GLOW_SQUID(SQUID), + + ABSTRACT_FISHES(ABSTRACT_WATERMOB, null), PUFFERFISH(ABSTRACT_FISHES), - SALMON(ABSTRACT_FISHES), - TROPICAL_FISH(ABSTRACT_FISHES), + TADPOLE(ABSTRACT_FISHES), + + ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISHES, null), + COD(ABSTRACT_SCHOOLING_FISH), + SALMON(ABSTRACT_SCHOOLING_FISH), + TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH), + + // Ageable mobs and (tamable) animals + ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), + ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null), + VILLAGER(ABSTRACT_VILLAGER), + WANDERING_TRADER(ABSTRACT_VILLAGER), + + ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), + AXOLOTL(ABSTRACT_ANIMAL), + CHICKEN(ABSTRACT_ANIMAL), + PANDA(ABSTRACT_ANIMAL), + PIG(ABSTRACT_ANIMAL), + POLAR_BEAR(ABSTRACT_ANIMAL), + RABBIT(ABSTRACT_ANIMAL), + SHEEP(ABSTRACT_ANIMAL), + BEE(ABSTRACT_ANIMAL), + TURTLE(ABSTRACT_ANIMAL), + FOX(ABSTRACT_ANIMAL), + FROG(ABSTRACT_ANIMAL), + GOAT(ABSTRACT_ANIMAL), + HOGLIN(ABSTRACT_ANIMAL), + STRIDER(ABSTRACT_ANIMAL), + SNIFFER(ABSTRACT_ANIMAL), + + COW(ABSTRACT_ANIMAL), + MOOSHROOM(COW), + + ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), + CAT(ABSTRACT_TAMEABLE_ANIMAL), + OCELOT(ABSTRACT_TAMEABLE_ANIMAL), + WOLF(ABSTRACT_TAMEABLE_ANIMAL), + PARROT(ABSTRACT_TAMEABLE_ANIMAL), + + ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), + HORSE(ABSTRACT_HORSE), + SKELETON_HORSE(ABSTRACT_HORSE), + ZOMBIE_HORSE(ABSTRACT_HORSE), + CAMEL(ABSTRACT_HORSE), + + CHESTED_HORSE(ABSTRACT_HORSE, null), + DONKEY(CHESTED_HORSE), + MULE(CHESTED_HORSE), + LLAMA(CHESTED_HORSE), + TRADER_LLAMA(LLAMA), // Monsters ABSTRACT_MONSTER(ABSTRACT_CREATURE, null), @@ -127,112 +195,43 @@ public enum EntityTypes1_20_3 implements EntityType { GIANT(ABSTRACT_MONSTER), SILVERFISH(ABSTRACT_MONSTER), VEX(ABSTRACT_MONSTER), - WITCH(ABSTRACT_MONSTER), WITHER(ABSTRACT_MONSTER), - RAVAGER(ABSTRACT_MONSTER), BREEZE(ABSTRACT_MONSTER), - - ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null), - - PIGLIN(ABSTRACT_PIGLIN), - PIGLIN_BRUTE(ABSTRACT_PIGLIN), - - HOGLIN(ABSTRACT_ANIMAL), - STRIDER(ABSTRACT_ANIMAL), - TADPOLE(ABSTRACT_FISHES), ZOGLIN(ABSTRACT_MONSTER), WARDEN(ABSTRACT_MONSTER), - // Illagers - ABSTRACT_ILLAGER_BASE(ABSTRACT_MONSTER, null), - ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), - EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), - ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER), - VINDICATOR(ABSTRACT_ILLAGER_BASE), - PILLAGER(ABSTRACT_ILLAGER_BASE), - - // Skeletons ABSTRACT_SKELETON(ABSTRACT_MONSTER, null), SKELETON(ABSTRACT_SKELETON), STRAY(ABSTRACT_SKELETON), WITHER_SKELETON(ABSTRACT_SKELETON), - // Guardians - GUARDIAN(ABSTRACT_MONSTER), - ELDER_GUARDIAN(GUARDIAN), - - // Spiders - SPIDER(ABSTRACT_MONSTER), - CAVE_SPIDER(SPIDER), - - // Zombies ZOMBIE(ABSTRACT_MONSTER), DROWNED(ZOMBIE), HUSK(ZOMBIE), ZOMBIFIED_PIGLIN(ZOMBIE), ZOMBIE_VILLAGER(ZOMBIE), - // Flying entities - ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), - GHAST(ABSTRACT_FLYING), - PHANTOM(ABSTRACT_FLYING), + GUARDIAN(ABSTRACT_MONSTER), + ELDER_GUARDIAN(GUARDIAN), - ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), - BAT(ABSTRACT_AMBIENT), - ALLAY(ABSTRACT_CREATURE), + SPIDER(ABSTRACT_MONSTER), + CAVE_SPIDER(SPIDER), - ABSTRACT_WATERMOB(ABSTRACT_INSENTIENT, null), - SQUID(ABSTRACT_WATERMOB), - GLOW_SQUID(SQUID), + ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null), + PIGLIN(ABSTRACT_PIGLIN), + PIGLIN_BRUTE(ABSTRACT_PIGLIN), - // Slimes - SLIME(ABSTRACT_INSENTIENT), - MAGMA_CUBE(SLIME), + // Raiders + ABSTRACT_RAIDER(ABSTRACT_MONSTER, null), + WITCH(ABSTRACT_RAIDER), + RAVAGER(ABSTRACT_RAIDER), - // Hangable objects - ABSTRACT_HANGING(ENTITY, null), - LEASH_KNOT(ABSTRACT_HANGING), - ITEM_FRAME(ABSTRACT_HANGING), - GLOW_ITEM_FRAME(ITEM_FRAME), - PAINTING(ABSTRACT_HANGING), - - ABSTRACT_LIGHTNING(ENTITY, null), - LIGHTNING_BOLT(ABSTRACT_LIGHTNING), - - // Arrows - ABSTRACT_ARROW(ENTITY, null), - ARROW(ABSTRACT_ARROW), - SPECTRAL_ARROW(ABSTRACT_ARROW), - TRIDENT(ABSTRACT_ARROW), - - // Fireballs - ABSTRACT_FIREBALL(ENTITY, null), - DRAGON_FIREBALL(ABSTRACT_FIREBALL), - FIREBALL(ABSTRACT_FIREBALL), - SMALL_FIREBALL(ABSTRACT_FIREBALL), - WITHER_SKULL(ABSTRACT_FIREBALL), - - // Projectiles - PROJECTILE_ABSTRACT(ENTITY, null), - SNOWBALL(PROJECTILE_ABSTRACT), - ENDER_PEARL(PROJECTILE_ABSTRACT), - EGG(PROJECTILE_ABSTRACT), - POTION(PROJECTILE_ABSTRACT), - EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), - WIND_CHARGE(PROJECTILE_ABSTRACT), - - // Vehicles - MINECART_ABSTRACT(ENTITY, null), - CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), - CHEST_MINECART(CHESTED_MINECART_ABSTRACT), - HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), - MINECART(MINECART_ABSTRACT), - FURNACE_MINECART(MINECART_ABSTRACT), - COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), - TNT_MINECART(MINECART_ABSTRACT), - SPAWNER_MINECART(MINECART_ABSTRACT), - BOAT(ENTITY), - CHEST_BOAT(BOAT); + ABSTRACT_ILLAGER_BASE(ABSTRACT_RAIDER, null), + ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), + VINDICATOR(ABSTRACT_ILLAGER_BASE), + PILLAGER(ABSTRACT_ILLAGER_BASE), + EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), + ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER); private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values()); private final EntityType parent; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_5.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_5.java index 7428be5a1..1e1c65099 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_5.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_5.java @@ -38,89 +38,159 @@ public enum EntityTypes1_20_5 implements EntityType { EXPERIENCE_ORB(ENTITY), EYE_OF_ENDER(ENTITY), FALLING_BLOCK(ENTITY), - FIREWORK_ROCKET(PROJECTILE_ABSTRACT), ITEM(ENTITY), - LLAMA_SPIT(PROJECTILE_ABSTRACT), TNT(ENTITY), - SHULKER_BULLET(PROJECTILE_ABSTRACT), - FISHING_BOBBER(PROJECTILE_ABSTRACT), OMINOUS_ITEM_SPAWNER(ENTITY), - - LIVINGENTITY(ENTITY, null), - ARMOR_STAND(LIVINGENTITY), MARKER(ENTITY), - PLAYER(LIVINGENTITY), + LIGHTNING_BOLT(ENTITY), + INTERACTION(ENTITY), DISPLAY(ENTITY, null), BLOCK_DISPLAY(DISPLAY), ITEM_DISPLAY(DISPLAY), TEXT_DISPLAY(DISPLAY), - INTERACTION(ENTITY), + // Hanging entities + ABSTRACT_HANGING(ENTITY, null), + LEASH_KNOT(ABSTRACT_HANGING), + PAINTING(ABSTRACT_HANGING), + ITEM_FRAME(ABSTRACT_HANGING), + GLOW_ITEM_FRAME(ITEM_FRAME), + + // Projectiles + PROJECTILE_ABSTRACT(ENTITY, null), // Not actually its own abstract type, but useful for categorizing + SNOWBALL(PROJECTILE_ABSTRACT), + ENDER_PEARL(PROJECTILE_ABSTRACT), + EGG(PROJECTILE_ABSTRACT), + POTION(PROJECTILE_ABSTRACT), + EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), + FIREWORK_ROCKET(PROJECTILE_ABSTRACT), + LLAMA_SPIT(PROJECTILE_ABSTRACT), + SHULKER_BULLET(PROJECTILE_ABSTRACT), + FISHING_BOBBER(PROJECTILE_ABSTRACT), + WITHER_SKULL(PROJECTILE_ABSTRACT), + DRAGON_FIREBALL(PROJECTILE_ABSTRACT), // Doesn't actually inherit fireball + + ABSTRACT_ARROW(PROJECTILE_ABSTRACT, null), + ARROW(ABSTRACT_ARROW), + SPECTRAL_ARROW(ABSTRACT_ARROW), + TRIDENT(ABSTRACT_ARROW), + + ABSTRACT_FIREBALL(ENTITY, null), + FIREBALL(ABSTRACT_FIREBALL), + SMALL_FIREBALL(ABSTRACT_FIREBALL), + + ABSTRACT_WIND_CHARGE(PROJECTILE_ABSTRACT, null), + WIND_CHARGE(ABSTRACT_WIND_CHARGE), + BREEZE_WIND_CHARGE(ABSTRACT_WIND_CHARGE), + + // Vehicles + VEHICLE(ENTITY, null), + BOAT(VEHICLE), + + MINECART_ABSTRACT(VEHICLE, null), + MINECART(MINECART_ABSTRACT), + FURNACE_MINECART(MINECART_ABSTRACT), + COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), + TNT_MINECART(MINECART_ABSTRACT), + SPAWNER_MINECART(MINECART_ABSTRACT), + CHEST_BOAT(BOAT), + + CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), + CHEST_MINECART(CHESTED_MINECART_ABSTRACT), + HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), + + // Living entities as a larger subclass + LIVINGENTITY(ENTITY, null), + ARMOR_STAND(LIVINGENTITY), + PLAYER(LIVINGENTITY), + + // Mobs as a larger subclass ABSTRACT_INSENTIENT(LIVINGENTITY, null), ENDER_DRAGON(ABSTRACT_INSENTIENT), - BEE(ABSTRACT_ANIMAL), + SLIME(ABSTRACT_INSENTIENT), + MAGMA_CUBE(SLIME), + // Ambient mobs + ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), + BAT(ABSTRACT_AMBIENT), + + // Flying mobs + ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), + GHAST(ABSTRACT_FLYING), + PHANTOM(ABSTRACT_FLYING), + + // Pathfinder mobs and its subclasses ABSTRACT_CREATURE(ABSTRACT_INSENTIENT, null), + ALLAY(ABSTRACT_CREATURE), - ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), - ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null), - VILLAGER(ABSTRACT_VILLAGER), - WANDERING_TRADER(ABSTRACT_VILLAGER), - - // Animals - ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), - AXOLOTL(ABSTRACT_ANIMAL), - DOLPHIN(ABSTRACT_WATERMOB), - CHICKEN(ABSTRACT_ANIMAL), - COW(ABSTRACT_ANIMAL), - MOOSHROOM(COW), - PANDA(ABSTRACT_ANIMAL), - PIG(ABSTRACT_ANIMAL), - POLAR_BEAR(ABSTRACT_ANIMAL), - RABBIT(ABSTRACT_ANIMAL), - SHEEP(ABSTRACT_ANIMAL), - TURTLE(ABSTRACT_ANIMAL), - FOX(ABSTRACT_ANIMAL), - FROG(ABSTRACT_ANIMAL), - GOAT(ABSTRACT_ANIMAL), - SNIFFER(ABSTRACT_ANIMAL), - ARMADILLO(ABSTRACT_ANIMAL), - - ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), - CAT(ABSTRACT_TAMEABLE_ANIMAL), - OCELOT(ABSTRACT_TAMEABLE_ANIMAL), - WOLF(ABSTRACT_TAMEABLE_ANIMAL), - - PARROT(ABSTRACT_TAMEABLE_ANIMAL), - - // Horses - ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), - CHESTED_HORSE(ABSTRACT_HORSE, null), - DONKEY(CHESTED_HORSE), - MULE(CHESTED_HORSE), - LLAMA(CHESTED_HORSE), - TRADER_LLAMA(LLAMA), - HORSE(ABSTRACT_HORSE), - SKELETON_HORSE(ABSTRACT_HORSE), - ZOMBIE_HORSE(ABSTRACT_HORSE), - CAMEL(ABSTRACT_HORSE), - - // Golem ABSTRACT_GOLEM(ABSTRACT_CREATURE, null), SNOW_GOLEM(ABSTRACT_GOLEM), IRON_GOLEM(ABSTRACT_GOLEM), SHULKER(ABSTRACT_GOLEM), - // Fish + // Water mobs + ABSTRACT_WATERMOB(ABSTRACT_CREATURE, null), + DOLPHIN(ABSTRACT_WATERMOB), + + SQUID(ABSTRACT_WATERMOB), + GLOW_SQUID(SQUID), + ABSTRACT_FISHES(ABSTRACT_WATERMOB, null), + PUFFERFISH(ABSTRACT_FISHES), + TADPOLE(ABSTRACT_FISHES), + ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISHES, null), COD(ABSTRACT_SCHOOLING_FISH), - PUFFERFISH(ABSTRACT_FISHES), SALMON(ABSTRACT_SCHOOLING_FISH), TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH), + // Ageable mobs and (tamable) animals + ABSTRACT_AGEABLE(ABSTRACT_CREATURE, null), + ABSTRACT_VILLAGER(ABSTRACT_AGEABLE, null), + VILLAGER(ABSTRACT_VILLAGER), + WANDERING_TRADER(ABSTRACT_VILLAGER), + + ABSTRACT_ANIMAL(ABSTRACT_AGEABLE, null), + AXOLOTL(ABSTRACT_ANIMAL), + CHICKEN(ABSTRACT_ANIMAL), + PANDA(ABSTRACT_ANIMAL), + PIG(ABSTRACT_ANIMAL), + POLAR_BEAR(ABSTRACT_ANIMAL), + RABBIT(ABSTRACT_ANIMAL), + SHEEP(ABSTRACT_ANIMAL), + BEE(ABSTRACT_ANIMAL), + TURTLE(ABSTRACT_ANIMAL), + FOX(ABSTRACT_ANIMAL), + FROG(ABSTRACT_ANIMAL), + GOAT(ABSTRACT_ANIMAL), + HOGLIN(ABSTRACT_ANIMAL), + STRIDER(ABSTRACT_ANIMAL), + SNIFFER(ABSTRACT_ANIMAL), + ARMADILLO(ABSTRACT_ANIMAL), + + COW(ABSTRACT_ANIMAL), + MOOSHROOM(COW), + + ABSTRACT_TAMEABLE_ANIMAL(ABSTRACT_ANIMAL, null), + CAT(ABSTRACT_TAMEABLE_ANIMAL), + OCELOT(ABSTRACT_TAMEABLE_ANIMAL), + WOLF(ABSTRACT_TAMEABLE_ANIMAL), + PARROT(ABSTRACT_TAMEABLE_ANIMAL), + + ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), + HORSE(ABSTRACT_HORSE), + SKELETON_HORSE(ABSTRACT_HORSE), + ZOMBIE_HORSE(ABSTRACT_HORSE), + CAMEL(ABSTRACT_HORSE), + + CHESTED_HORSE(ABSTRACT_HORSE, null), + DONKEY(CHESTED_HORSE), + MULE(CHESTED_HORSE), + LLAMA(CHESTED_HORSE), + TRADER_LLAMA(LLAMA), + // Monsters ABSTRACT_MONSTER(ABSTRACT_CREATURE, null), BLAZE(ABSTRACT_MONSTER), @@ -130,117 +200,44 @@ public enum EntityTypes1_20_5 implements EntityType { GIANT(ABSTRACT_MONSTER), SILVERFISH(ABSTRACT_MONSTER), VEX(ABSTRACT_MONSTER), - WITCH(ABSTRACT_RAIDER), WITHER(ABSTRACT_MONSTER), - RAVAGER(ABSTRACT_RAIDER), BREEZE(ABSTRACT_MONSTER), - - ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null), - - PIGLIN(ABSTRACT_PIGLIN), - PIGLIN_BRUTE(ABSTRACT_PIGLIN), - - HOGLIN(ABSTRACT_ANIMAL), - STRIDER(ABSTRACT_ANIMAL), - TADPOLE(ABSTRACT_FISHES), ZOGLIN(ABSTRACT_MONSTER), WARDEN(ABSTRACT_MONSTER), - // Illagers - ABSTRACT_RAIDER(ABSTRACT_MONSTER, null), - ABSTRACT_ILLAGER_BASE(ABSTRACT_RAIDER, null), - ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), - EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), - ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER), - VINDICATOR(ABSTRACT_ILLAGER_BASE), - PILLAGER(ABSTRACT_ILLAGER_BASE), - - // Skeletons ABSTRACT_SKELETON(ABSTRACT_MONSTER, null), SKELETON(ABSTRACT_SKELETON), STRAY(ABSTRACT_SKELETON), WITHER_SKELETON(ABSTRACT_SKELETON), BOGGED(ABSTRACT_SKELETON), - // Guardians - GUARDIAN(ABSTRACT_MONSTER), - ELDER_GUARDIAN(GUARDIAN), - - // Spiders - SPIDER(ABSTRACT_MONSTER), - CAVE_SPIDER(SPIDER), - - // Zombies ZOMBIE(ABSTRACT_MONSTER), DROWNED(ZOMBIE), HUSK(ZOMBIE), ZOMBIFIED_PIGLIN(ZOMBIE), ZOMBIE_VILLAGER(ZOMBIE), - // Flying entities - ABSTRACT_FLYING(ABSTRACT_INSENTIENT, null), - GHAST(ABSTRACT_FLYING), - PHANTOM(ABSTRACT_FLYING), + GUARDIAN(ABSTRACT_MONSTER), + ELDER_GUARDIAN(GUARDIAN), - ABSTRACT_AMBIENT(ABSTRACT_INSENTIENT, null), - BAT(ABSTRACT_AMBIENT), - ALLAY(ABSTRACT_CREATURE), + SPIDER(ABSTRACT_MONSTER), + CAVE_SPIDER(SPIDER), - ABSTRACT_WATERMOB(ABSTRACT_CREATURE, null), - SQUID(ABSTRACT_WATERMOB), - GLOW_SQUID(SQUID), + ABSTRACT_PIGLIN(ABSTRACT_MONSTER, null), + PIGLIN(ABSTRACT_PIGLIN), + PIGLIN_BRUTE(ABSTRACT_PIGLIN), - // Slimes - SLIME(ABSTRACT_INSENTIENT), - MAGMA_CUBE(SLIME), + // Raiders + ABSTRACT_RAIDER(ABSTRACT_MONSTER, null), + WITCH(ABSTRACT_RAIDER), + RAVAGER(ABSTRACT_RAIDER), - // Hangable objects - ABSTRACT_HANGING(ENTITY, null), - LEASH_KNOT(ABSTRACT_HANGING), - ITEM_FRAME(ABSTRACT_HANGING), - GLOW_ITEM_FRAME(ITEM_FRAME), - PAINTING(ABSTRACT_HANGING), - - ABSTRACT_LIGHTNING(ENTITY, null), - LIGHTNING_BOLT(ABSTRACT_LIGHTNING), - - // Arrows - ABSTRACT_ARROW(PROJECTILE_ABSTRACT, null), - ARROW(ABSTRACT_ARROW), - SPECTRAL_ARROW(ABSTRACT_ARROW), - TRIDENT(ABSTRACT_ARROW), - - // Fireballs - ABSTRACT_FIREBALL(ENTITY, null), - DRAGON_FIREBALL(PROJECTILE_ABSTRACT), - FIREBALL(ABSTRACT_FIREBALL), - SMALL_FIREBALL(ABSTRACT_FIREBALL), - WITHER_SKULL(PROJECTILE_ABSTRACT), - - // Projectiles - PROJECTILE_ABSTRACT(ENTITY, null), // Not actually its own abstract type, but useful for categorizing - SNOWBALL(PROJECTILE_ABSTRACT), - ENDER_PEARL(PROJECTILE_ABSTRACT), - EGG(PROJECTILE_ABSTRACT), - POTION(PROJECTILE_ABSTRACT), - EXPERIENCE_BOTTLE(PROJECTILE_ABSTRACT), - ABSTRACT_WIND_CHARGE(PROJECTILE_ABSTRACT, null), - WIND_CHARGE(ABSTRACT_WIND_CHARGE), - BREEZE_WIND_CHARGE(ABSTRACT_WIND_CHARGE), - - // Vehicles - VEHICLE(ENTITY, null), - MINECART_ABSTRACT(VEHICLE, null), - CHESTED_MINECART_ABSTRACT(MINECART_ABSTRACT, null), - CHEST_MINECART(CHESTED_MINECART_ABSTRACT), - HOPPER_MINECART(CHESTED_MINECART_ABSTRACT), - MINECART(MINECART_ABSTRACT), - FURNACE_MINECART(MINECART_ABSTRACT), - COMMAND_BLOCK_MINECART(MINECART_ABSTRACT), - TNT_MINECART(MINECART_ABSTRACT), - SPAWNER_MINECART(MINECART_ABSTRACT), - BOAT(VEHICLE), - CHEST_BOAT(BOAT); + ABSTRACT_ILLAGER_BASE(ABSTRACT_RAIDER, null), + ABSTRACT_EVO_ILLU_ILLAGER(ABSTRACT_ILLAGER_BASE, null), + VINDICATOR(ABSTRACT_ILLAGER_BASE), + PILLAGER(ABSTRACT_ILLAGER_BASE), + EVOKER(ABSTRACT_EVO_ILLU_ILLAGER), + ILLUSIONER(ABSTRACT_EVO_ILLU_ILLAGER); private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values()); private final EntityType parent; diff --git a/api/src/main/java/com/viaversion/viaversion/util/EntityTypeUtil.java b/api/src/main/java/com/viaversion/viaversion/util/EntityTypeUtil.java index 2ef2f92ea..b0beaaa91 100644 --- a/api/src/main/java/com/viaversion/viaversion/util/EntityTypeUtil.java +++ b/api/src/main/java/com/viaversion/viaversion/util/EntityTypeUtil.java @@ -24,6 +24,7 @@ package com.viaversion.viaversion.util; import com.google.common.base.Preconditions; import com.viaversion.viaversion.api.Via; +import com.viaversion.viaversion.api.data.FullMappings; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.protocol.Protocol; import java.util.ArrayList; @@ -62,16 +63,21 @@ public final class EntityTypeUtil { * @param entity type */ public static void initialize(final T[] values, final EntityType[] typesToFill, final Protocol protocol, final EntityIdSetter idSetter) { + final FullMappings mappings = protocol.getMappingData().getEntityMappings(); for (final T type : values) { if (type.isAbstractType()) { continue; } - final int id = protocol.getMappingData().getEntityMappings().mappedId(type.identifier()); + final int id = mappings.mappedId(type.identifier()); Preconditions.checkArgument(id != -1, "Entity type %s has no id", type.identifier()); idSetter.setId(type, id); typesToFill[id] = type; } + + if (typesToFill.length != mappings.mappedSize()) { + throw new IllegalArgumentException("typesToFill length doesn't match the amount of entity types: " + typesToFill.length + " != " + mappings.size()); + } } public static EntityType[] createSizedArray(final EntityType[] values) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java index a6410b182..07aea2ba5 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/Protocol1_14To1_13_2.java @@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_14to1_13_2; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.ClientWorld; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.misc.ParticleType; @@ -145,6 +146,7 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol new enum entity type - */ - public & EntityType> void mapTypes(EntityType[] oldTypes, Class newTypeClass) { - if (typeMappings == null) { - typeMappings = Int2IntMapMappings.of(); - } - for (EntityType oldType : oldTypes) { - try { - E newType = Enum.valueOf(newTypeClass, oldType.name()); - typeMappings.setNewId(oldType.getId(), newType.getId()); - } catch (IllegalArgumentException notFound) { - if (!typeMappings.contains(oldType.getId())) { - Via.getPlatform().getLogger().warning("Could not find new entity type for " + oldType + "! " + - "Old type: " + oldType.getClass().getEnclosingClass().getSimpleName() + ", new type: " + newTypeClass.getEnclosingClass().getSimpleName()); - } - } - } - } - /** * Maps entity ids based on the protocol's mapping data. */ diff --git a/common/src/main/resources/assets/viaversion/data/identifiers-1.13.2.nbt b/common/src/main/resources/assets/viaversion/data/identifiers-1.13.2.nbt index 10afd3a988c3cbdfdd64ac7bc56ba449b8c81535..60df090b6159109984ae45a919daae4c74965053 100644 GIT binary patch literal 520 zcmajcO)mpc6vpv0_ms3#FD2AV5JE#2EWCvcB0>q`Wg%77OxnA+p-l9K#M0NY@y+;8 znu(Q|XGa+2pfHxvmaYoEOH&URG7b`;09b?x5mH(wyewE~q)haV!+$cu?Q!yFVD z^dgTw^kW30C}I**n8qv?u!vQxVI3RT#1^(u!3oZBflFNB2Dhl;4)=ud&kRYJG)Rtl z5CbS+9AlWk4CYZn87oMF>|hUv_`m^h##-ylwwmq88H< zL-t`AuoLQC1z`*J`Ifb!ToPmL%l#zicGliL% Nfu$HM!(ha~006V>4C(*? diff --git a/common/src/main/resources/assets/viaversion/data/identifiers-1.13.nbt b/common/src/main/resources/assets/viaversion/data/identifiers-1.13.nbt index f86defc3a87546005c8f9d55d8329f42c9bb51e1..4bd4ba1ff0f31d69c7859d31f67646df87556525 100644 GIT binary patch delta 36 ncma!xn;^mR9|$JOXp4hrMh2$L6lP`ymg3B+R0akHBL)TlF(nNb delta 36 qcma!xn;^l$z`*J`QAS&wfq|ivk%1{Qg_)Uwr8u)H6)0fDzyJVulLg`c diff --git a/common/src/main/resources/assets/viaversion/data/identifiers-1.14.nbt b/common/src/main/resources/assets/viaversion/data/identifiers-1.14.nbt index 2fa2634360087865716c0de6e4816eb421cebb85..b309e9962a1fb2f4074afcb95084c109f54d672c 100644 GIT binary patch delta 360 zcmZY5!Ae3w6vpv$y;qT|r5npY5(>i>wQ!+HLPC*7&_+t#2v_d}LzsfI3PSJ|T>B7h z17E5a$p2Y8@PorJ%=dAAgTK@=6bU75KAm;eEPM&4(R^;=p8Yca98VH9_IwEzT!_ef zMiP-@D8om9EDmsp0*-KuQ|P-hT;LLQG;o8a$Wm?@T6o3_dU(Yf`WRq@2xCkT)56Ud z^mlELLJry>k0P|e3C>Z0reC9mHXgCklm~S11Wg)3)2h(4d&Ky_9lE%}jLjvjGt>RG O{ggIdp!-{Iz3&}U(K6Zq delta 47 zcmeywwu?oEi-CcQfi<%vHMf|Vfh#w$pdd9RII}91fq~U?a|q*HMivGJhSJGjnQ8$d C^9-Q? diff --git a/common/src/main/resources/assets/viaversion/data/identifiers-1.15.nbt b/common/src/main/resources/assets/viaversion/data/identifiers-1.15.nbt index bd172f5c4b067a81afea660afbfa335b3cd47c44..7b38c1ce9a344e62a73d47c4fa0c848e6dd5867f 100644 GIT binary patch delta 352 zcmZY5!Ab&A6vpv0&O|bjx+(?9AVL#r(Z&=-K}m(EMPar{rsfhCF$M2R2*FqANnG?I zg3puxv+lz0ayXms<7|WV;VKjfC278#b=E9=38&F~ZsI4qG=Dr#5;pdH2^K6w-@AyCrLjyNs&;|iC zSsP@b$=V`AuoLQC1z`*Lc*@tl}BMSoqL+NBz=2`#{ Cn+t0I diff --git a/common/src/main/resources/assets/viaversion/data/identifiers-1.16.2.nbt b/common/src/main/resources/assets/viaversion/data/identifiers-1.16.2.nbt index b9126757924618948f2d92ca58996ad8d7d9cec3..e330e7a63512710fae9b866a24565b97590bca95 100644 GIT binary patch delta 145 zcmeywb&9*5i-CcQfg?4qB(o$lwV0WKD>t#AAT=d8vnusJ5HK<@Wu`DPGq4l`1sE6@ za=00o5=(##W+;{i(z-ywl6t#AAT=d8vnusJ5HK<@Wu`DPGq4l`1sE6@ zvbhJVrQWFteGXLxmXR~D9^>h0EvFPUH}EK B3zPr= diff --git a/common/src/main/resources/assets/viaversion/data/identifiers-1.17.nbt b/common/src/main/resources/assets/viaversion/data/identifiers-1.17.nbt index efd5bb74081e01ef5fe91c52ff3c82af3b03638c..9b91c117acea854e3e7b716cbc90f59353343124 100644 GIT binary patch delta 92 zcmZ1^azVt4i-CcQfg?4qB(o$lwV0WKD>t#AAT=d8vnusJ5HK<@Wu`DQGq4l`1sE6@ a3W2IwGfPr)F_mtVQRQR->6z@xc^3dp*ddGn delta 28 icmca0vPgu9i(#UH7z+aftLH{9RZbv-p>%RF=Uo6-wFX`Q diff --git a/common/src/main/resources/assets/viaversion/data/identifiers-1.18.nbt b/common/src/main/resources/assets/viaversion/data/identifiers-1.18.nbt index 26eeb3a801e249b4b499d2d80d008a7b3227e455..d1104932e39055f15223143f93d590e991481e0f 100644 GIT binary patch delta 57 zcmbO%I$3mrG|PV=m?*CfrZ;-&a)KF~t2r4N#X(Yx3{06R%*+fd#hF#93=9l<3=9A` C{}>Yh delta 57 zcmbO%I$3mrGz$X*L-Ry=bs){^xzS6P6C_Z&xtf!aQ5?v!WMp85G|PV=m?%FJOmEz?lpD<0oXVrf2xd+0;w=RLCO8=@ delta 42 scmew_{a<>5Gz$X*L-R!WnLwJ=bK{<++#rF{&8a+!j3AcfR2@#w8i@z2CIx`uc delta 44 vcmeya@LgeoGz$X*L-R)YnT$XNtLNrDjJ&)cq0-G~`7}Xd43?9B@z(+X2zd)G diff --git a/common/src/main/resources/assets/viaversion/data/identifiers-1.19.nbt b/common/src/main/resources/assets/viaversion/data/identifiers-1.19.nbt index 9167274f8aff0b6f3dd169c15d26a5cc963b76cb..74b9cac8c54d3e9f2630eb98550db089286d1ad2 100644 GIT binary patch delta 42 ncmew&^+jreG|PV=m?+-~rZ=uR%LQg^uH{x_1hXbD;<*F>BsCeO delta 42 scmew&^+jreGz$X*L-R!WP9V+dxpB=|E|5U!=2~t=Mi9$#@*yAXu{ diff --git a/common/src/main/resources/assets/viaversion/data/identifiers-1.20.nbt b/common/src/main/resources/assets/viaversion/data/identifiers-1.20.nbt index 5c47b3c843dca4499ca55cb85a197815e072632f..958703bc2520bdb5d80fe1c729910466a7bd3250 100644 GIT binary patch delta 44 ncmdn5xLma)Vz|+lFZa%W(Ka@#Dap~*2~dU+h*^M~l6)wKm4N{OSy&JB delta 9 QcmbQha)NooaYjZ401;FI*#H0l diff --git a/common/src/main/resources/assets/viaversion/data/mappings-1.15to1.16.nbt b/common/src/main/resources/assets/viaversion/data/mappings-1.15to1.16.nbt index 77ee4d68a101d55e638f5c48138b836e4b33f2af..ce1925932b4aa1cb2c7d6cadd45767147987d0e9 100644 GIT binary patch delta 291 zcmXBP%L+k37{KvyS%|Ph*&HG90`B6-PFavkLWeUk$)%i?jXZBwd-l!l9En^2B$))& diff --git a/common/src/main/resources/assets/viaversion/data/mappings-1.16to1.16.2.nbt b/common/src/main/resources/assets/viaversion/data/mappings-1.16to1.16.2.nbt index 9f2d595f0bf92b43c39fd749a5dd1c4fb4cda65d..31a994e84d6852c59618cac91a8f4ae56eaff937 100644 GIT binary patch delta 81 zcmdnM@`GiAK9eUG14n9JNoGlAYB4hdS8ifKL262HW>qQ!149lY15;)SBQpa_F+?Dn Xn}I2@1SrD@#I`_ANj{Wg$G`vpO9c=r delta 9 QcmeytvVmoTJ`*DY01^EHlK=n! diff --git a/common/src/test/java/com/viaversion/viaversion/common/entities/EntityTypesTest.java b/common/src/test/java/com/viaversion/viaversion/common/entities/EntityTypesTest.java deleted file mode 100644 index 8f7f3e11f..000000000 --- a/common/src/test/java/com/viaversion/viaversion/common/entities/EntityTypesTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.viaversion.viaversion.common.entities; - -import com.viaversion.viaversion.api.minecraft.entities.EntityType; -import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14; -import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15; -import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16; -import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2; -import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17; -import java.util.function.Function; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -/** - * Test to make sure the array storage approach of entity types works correctly. - */ -public class EntityTypesTest { - - @Test - void testArrayOrder() { - testArrayOrder(EntityTypes1_14.values(), EntityTypes1_14::getTypeFromId); - testArrayOrder(EntityTypes1_15.values(), EntityTypes1_15::getTypeFromId); - testArrayOrder(EntityTypes1_16.values(), EntityTypes1_16::getTypeFromId); - testArrayOrder(EntityTypes1_16_2.values(), EntityTypes1_16_2::getTypeFromId); - testArrayOrder(EntityTypes1_17.values(), EntityTypes1_17::getTypeFromId); - // Newer type enums are automatically filled using mappings - } - - private void testArrayOrder(EntityType[] types, Function returnFunction) { - for (EntityType type : types) { - if (type.getId() != -1) { - Assertions.assertEquals(type, returnFunction.apply(type.getId())); - } - } - } -}