From 8f8bc55bd01087f09b7866d9995aa66fca761be3 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 13 Nov 2024 16:11:36 +0100 Subject: [PATCH] 24w46a --- .../minecraft/entities/EntityTypes1_21_4.java | 313 ++++++++++++++++++ .../api/protocol/version/ProtocolVersion.java | 2 +- .../Protocol1_21_2To1_21_4.java | 5 +- .../rewriter/EntityPacketRewriter1_21_4.java | 17 +- .../viaversion/data/identifiers-1.21.4.nbt | Bin 5587 -> 5583 bytes .../data/mappings-1.21.2to1.21.4.nbt | Bin 503 -> 575 bytes 6 files changed, 328 insertions(+), 9 deletions(-) create mode 100644 api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_21_4.java diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_21_4.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_21_4.java new file mode 100644 index 000000000..c66581468 --- /dev/null +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_21_4.java @@ -0,0 +1,313 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2024 ViaVersion and contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +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 com.viaversion.viaversion.util.Key; +import java.util.Locale; +import org.checkerframework.checker.nullness.qual.Nullable; + +public enum EntityTypes1_21_4 implements EntityType { + + ENTITY(null, null), + + AREA_EFFECT_CLOUD(ENTITY), + END_CRYSTAL(ENTITY), + EVOKER_FANGS(ENTITY), + EXPERIENCE_ORB(ENTITY), + EYE_OF_ENDER(ENTITY), + FALLING_BLOCK(ENTITY), + ITEM(ENTITY), + TNT(ENTITY), + OMINOUS_ITEM_SPAWNER(ENTITY), + MARKER(ENTITY), + LIGHTNING_BOLT(ENTITY), + INTERACTION(ENTITY), + + DISPLAY(ENTITY, null), + BLOCK_DISPLAY(DISPLAY), + ITEM_DISPLAY(DISPLAY), + TEXT_DISPLAY(DISPLAY), + + // Hanging entities + HANGING_ENTITY(ENTITY, null), + LEASH_KNOT(HANGING_ENTITY), + PAINTING(HANGING_ENTITY), + ITEM_FRAME(HANGING_ENTITY), + GLOW_ITEM_FRAME(ITEM_FRAME), + + // Projectiles + PROJECTILE(ENTITY, null), + ITEM_PROJECTILE(PROJECTILE, null), + SNOWBALL(ITEM_PROJECTILE), + ENDER_PEARL(ITEM_PROJECTILE), + EGG(ITEM_PROJECTILE), + POTION(ITEM_PROJECTILE), + EXPERIENCE_BOTTLE(ITEM_PROJECTILE), + FIREWORK_ROCKET(PROJECTILE), + LLAMA_SPIT(PROJECTILE), + SHULKER_BULLET(PROJECTILE), + FISHING_BOBBER(PROJECTILE), + WITHER_SKULL(PROJECTILE), + DRAGON_FIREBALL(PROJECTILE), // Doesn't actually inherit fireball + + ABSTRACT_ARROW(PROJECTILE, 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, null), + WIND_CHARGE(ABSTRACT_WIND_CHARGE), + BREEZE_WIND_CHARGE(ABSTRACT_WIND_CHARGE), + + // Vehicles + VEHICLE(ENTITY, null), + + ABSTRACT_MINECART(VEHICLE, null), + MINECART(ABSTRACT_MINECART), + FURNACE_MINECART(ABSTRACT_MINECART), + COMMAND_BLOCK_MINECART(ABSTRACT_MINECART), + TNT_MINECART(ABSTRACT_MINECART), + SPAWNER_MINECART(ABSTRACT_MINECART), + + ABSTRACT_MINECART_CONTAINER(ABSTRACT_MINECART, null), + CHEST_MINECART(ABSTRACT_MINECART_CONTAINER), + HOPPER_MINECART(ABSTRACT_MINECART_CONTAINER), + + ABSTRACT_BOAT(VEHICLE, null), + ABSTRACT_CHEST_BOAT(ABSTRACT_BOAT, null), + ACACIA_BOAT(ABSTRACT_BOAT), + ACACIA_CHEST_BOAT(ABSTRACT_CHEST_BOAT), + BAMBOO_CHEST_RAFT(ABSTRACT_CHEST_BOAT), + BAMBOO_RAFT(ABSTRACT_BOAT), + BIRCH_BOAT(ABSTRACT_BOAT), + BIRCH_CHEST_BOAT(ABSTRACT_CHEST_BOAT), + CHERRY_BOAT(ABSTRACT_BOAT), + CHERRY_CHEST_BOAT(ABSTRACT_CHEST_BOAT), + DARK_OAK_BOAT(ABSTRACT_BOAT), + DARK_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT), + JUNGLE_BOAT(ABSTRACT_BOAT), + JUNGLE_CHEST_BOAT(ABSTRACT_CHEST_BOAT), + MANGROVE_BOAT(ABSTRACT_BOAT), + MANGROVE_CHEST_BOAT(ABSTRACT_CHEST_BOAT), + OAK_BOAT(ABSTRACT_BOAT), + OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT), + PALE_OAK_BOAT(ABSTRACT_BOAT), + PALE_OAK_CHEST_BOAT(ABSTRACT_CHEST_BOAT), + SPRUCE_BOAT(ABSTRACT_BOAT), + SPRUCE_CHEST_BOAT(ABSTRACT_CHEST_BOAT), + + // Living entities as a larger subclass + LIVING_ENTITY(ENTITY, null), + ARMOR_STAND(LIVING_ENTITY), + PLAYER(LIVING_ENTITY), + + // Mobs as a larger subclass + MOB(LIVING_ENTITY, null), + ENDER_DRAGON(MOB), + + SLIME(MOB), + MAGMA_CUBE(SLIME), + + // Ambient mobs + AMBIENT_CREATURE(MOB, null), + BAT(AMBIENT_CREATURE), + + // Flying mobs + FLYING_MOB(MOB, null), + GHAST(FLYING_MOB), + PHANTOM(FLYING_MOB), + + // Pathfinder mobs and its subclasses + PATHFINDER_MOB(MOB, null), + ALLAY(PATHFINDER_MOB), + + ABSTRACT_GOLEM(PATHFINDER_MOB, null), + SNOW_GOLEM(ABSTRACT_GOLEM), + IRON_GOLEM(ABSTRACT_GOLEM), + SHULKER(ABSTRACT_GOLEM), + + // Ageable mobs and (tamable) animals + ABSTRACT_AGEABLE(PATHFINDER_MOB, 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), + + TAMABLE_ANIMAL(ABSTRACT_ANIMAL, null), + CAT(TAMABLE_ANIMAL), + OCELOT(TAMABLE_ANIMAL), + WOLF(TAMABLE_ANIMAL), + PARROT(TAMABLE_ANIMAL), + + ABSTRACT_HORSE(ABSTRACT_ANIMAL, null), + HORSE(ABSTRACT_HORSE), + SKELETON_HORSE(ABSTRACT_HORSE), + ZOMBIE_HORSE(ABSTRACT_HORSE), + CAMEL(ABSTRACT_HORSE), + + ABSTRACT_CHESTED_HORSE(ABSTRACT_HORSE, null), + DONKEY(ABSTRACT_CHESTED_HORSE), + MULE(ABSTRACT_CHESTED_HORSE), + LLAMA(ABSTRACT_CHESTED_HORSE), + TRADER_LLAMA(LLAMA), + + // Monsters + ABSTRACT_MONSTER(PATHFINDER_MOB, 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), + BREEZE(ABSTRACT_MONSTER), + ZOGLIN(ABSTRACT_MONSTER), + WARDEN(ABSTRACT_MONSTER), + CREAKING(ABSTRACT_MONSTER), + + ABSTRACT_SKELETON(ABSTRACT_MONSTER, null), + SKELETON(ABSTRACT_SKELETON), + STRAY(ABSTRACT_SKELETON), + WITHER_SKELETON(ABSTRACT_SKELETON), + BOGGED(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), + + // Water mobs + AGEABLE_WATER_CREATURE(ABSTRACT_AGEABLE, null), + DOLPHIN(AGEABLE_WATER_CREATURE), + + SQUID(AGEABLE_WATER_CREATURE), + GLOW_SQUID(SQUID), + + WATER_ANIMAL(PATHFINDER_MOB, null), + ABSTRACT_FISH(WATER_ANIMAL, null), + PUFFERFISH(ABSTRACT_FISH), + TADPOLE(ABSTRACT_FISH), + + ABSTRACT_SCHOOLING_FISH(ABSTRACT_FISH, null), + COD(ABSTRACT_SCHOOLING_FISH), + SALMON(ABSTRACT_SCHOOLING_FISH), + TROPICAL_FISH(ABSTRACT_SCHOOLING_FISH), + + // Raiders + ABSTRACT_RAIDER(ABSTRACT_MONSTER, null), + WITCH(ABSTRACT_RAIDER), + RAVAGER(ABSTRACT_RAIDER), + + ABSTRACT_ILLAGER(ABSTRACT_RAIDER, null), + SPELLCASTER_ILLAGER(ABSTRACT_ILLAGER, null), + VINDICATOR(ABSTRACT_ILLAGER), + PILLAGER(ABSTRACT_ILLAGER), + EVOKER(SPELLCASTER_ILLAGER), + ILLUSIONER(SPELLCASTER_ILLAGER); + + private static final EntityType[] TYPES = EntityTypeUtil.createSizedArray(values()); + private final EntityType parent; + private final String identifier; + private int id = -1; + + EntityTypes1_21_4(final EntityType parent) { + this.parent = parent; + this.identifier = Key.namespaced(name().toLowerCase(Locale.ROOT)); + } + + EntityTypes1_21_4(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 String identifier() { + Preconditions.checkArgument(identifier != null, "Called identifier method on abstract type"); + return identifier; + } + + @Override + public @Nullable EntityType getParent() { + return parent; + } + + @Override + public boolean isAbstractType() { + return identifier == null; + } + + 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/protocol/version/ProtocolVersion.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java index f5f0247f5..f06ec6c03 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java @@ -87,7 +87,7 @@ public class ProtocolVersion implements Comparable { public static final ProtocolVersion v1_20_5 = register(766, "1.20.5-1.20.6", new SubVersionRange("1.20", 5, 6)); public static final ProtocolVersion v1_21 = register(767, "1.21-1.21.1", new SubVersionRange("1.21", 0, 1)); public static final ProtocolVersion v1_21_2 = register(768, "1.21.2-1.21.3", new SubVersionRange("1.21", 2, 3)); - public static final ProtocolVersion v1_21_4 = register(769, 221, "1.21.4"); + public static final ProtocolVersion v1_21_4 = register(769, 222, "1.21.4"); public static final ProtocolVersion unknown = new ProtocolVersion(VersionType.SPECIAL, -1, -1, "UNKNOWN", null); static { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21_2to1_21_4/Protocol1_21_2To1_21_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21_2to1_21_4/Protocol1_21_2To1_21_4.java index 2d2832279..7a5de843f 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21_2to1_21_4/Protocol1_21_2To1_21_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21_2to1_21_4/Protocol1_21_2To1_21_4.java @@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.data.MappingData; import com.viaversion.viaversion.api.data.MappingDataBase; import com.viaversion.viaversion.api.minecraft.Particle; import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey; -import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_2; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_4; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider; import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider; @@ -152,6 +152,7 @@ public final class Protocol1_21_2To1_21_4 extends AbstractProtocol { + filter().type(EntityTypes1_21_4.CREAKING).addIndex(18); // Is tearing down + filter().type(EntityTypes1_21_4.SALMON).index(17).handler((event, data) -> { final String type = data.value(); final int typeId = switch (type) { case "small" -> 0; @@ -139,8 +139,13 @@ public final class EntityPacketRewriter1_21_4 extends EntityRewriterY|AQ(_5Fh7pM6fSi(iC`Wek8b)sbF;N){ delta 32 ocmdnb@|}5tKI5#326e1;3=Hym6F2W=ESX%$XvJtX`3s{r0Jvrf>Hq)$