Compare commits

..
40 Commits
Author SHA1 Message Date
Nassim Jahnke 113bf1e275 4.10.2 Release 2024-05-10 13:24:23 +02:00
EnZaXD 2aec3ce6d1 Expose StructuredDataConverter#removeBackupTag (#3838) 2024-05-09 20:50:45 +02:00
EnZaXD f60e31ac78 Add block entity ids in 1.20.3->.5 conversion (#3837) 2024-05-09 20:37:20 +02:00
EnZaXD 8c4ff7ebfc Remove fix which got merged into MCStructs (#3836) 2024-05-09 20:04:36 +02:00
Nassim Jahnke 4c7729e602 Fixup banner handling, some other fixes 2024-05-09 19:33:26 +02:00
Nassim Jahnke 3dfc3bb15b Actually add properties tag in 1.20.5->1.20.4 item handler 2024-05-09 17:21:53 +02:00
EnZaXD 69b33dc2d2 Handle invalid disconnect message in 1.8->1.9 (#3834) 2024-05-09 09:26:28 +02:00
EnZaXD c24169c410 [ci skip] Use login/status packet enums in older protocols (#3835) 2024-05-09 09:25:54 +02:00
Nassim Jahnke 31211c2214 Fix tipped arrow and area effect cloud color 2024-05-08 20:28:55 +02:00
Nassim Jahnke cb5fc9fb08 Fix empty effect handling
Fixes #3832
2024-05-08 11:55:35 +02:00
EnZaXD a8d7ab62e3 Add alpha to particle colors in 1.20.3->.5 (#3827) 2024-05-06 09:51:41 +02:00
Nassim Jahnke 71313b4753 Simplify raider check in 1.13->1.14 entity data handler 2024-05-06 09:42:49 +02:00
Nassim Jahnke 994bc8eefc Move down super onMappingDataLoaded calls 2024-05-05 23:15:20 +02:00
Nassim Jahnke 7d35826637 Bump version to 4.10.2-SNAPSHOT 2024-05-05 23:12:43 +02:00
Nassim Jahnke 4f40372392 4.10.1 Release 2024-05-05 16:38:28 +02:00
Nassim Jahnke e993be751c Filter items in entity data with amount < 1 2024-05-05 16:36:46 +02:00
Nassim Jahnke f1b92fea8d Move loadFullMappings to MappingDataBase, use loadMiMappings 2024-05-05 14:41:30 +02:00
Nassim Jahnke fc9d5b6d9d Clean up entriesLength usage 2024-05-05 13:33:21 +02:00
EnZaXD 9549a18cec Handle duplicated registry ids in 1.20.3->.5 (#3825)
Minecraft 1.20.4 and earlier silently overrides the previous values if multiple registry elements have the same id (Tested using a Fabric 1.20.4 mod by parsing a registry sent by a server and then printing the parsed objects).
2024-05-05 13:08:09 +02:00
Nassim Jahnke d691096ce1 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
2024-05-05 12:10:57 +02:00
Nassim Jahnke 73ed425bf7 Fixup entity type hierarchy 2024-05-04 18:11:50 +02:00
EnZaXD cdc9c3ae95 Update mappings (#3823)
https://github.com/ViaVersion/Mappings/commit/48167fe5b6db1d51157d88a7cc028c11da922514
2024-05-03 19:12:24 +02:00
EnZaXD c113e19d41 Convert plain to json instead of doing component conversion in DeathListener (#3821)
Closes https://github.com/ViaVersion/ViaVersion/issues/3817
2024-05-02 17:09:27 +02:00
EnZaXD d3af70d76c Add optional registry utils to TagUtil (#3819) 2024-05-02 15:45:19 +02:00
Nassim Jahnke c00bc6b667 Check both namespaced and implicit key when replacing registry 2024-05-01 10:28:53 +02:00
Nassim Jahnke fa3c933b2f Fix banner pattern backup
Fixes #3816
2024-05-01 00:06:22 +02:00
Nassim Jahnke 07bb0269c3 Auto: Update copyright headers 2024-04-30 22:23:11 +02:00
Nassim Jahnke 57c0d83608 Clean up component rewriter 2024-04-30 16:09:11 +02:00
Nassim Jahnke 4854b131b8 Some cleanup 2024-04-30 09:02:24 +02:00
Nassim Jahnke 1864b66e42 Handle new banner patterns in backwards translation 2024-04-29 23:58:57 +02:00
Nassim Jahnke 8aa6769193 Handle empty items in item lists 2024-04-29 23:11:10 +02:00
Nassim Jahnke 5f90bcbbaf Fix item cost type reading 2024-04-28 15:15:17 +02:00
Nassim Jahnke d068822143 Add paperweight-mappings-namespace manifest attribute 2024-04-28 03:51:56 +02:00
Nassim Jahnke a77e328dfe Put components in entity data through component rewriter
Cursed, but possibly needed
2024-04-27 21:39:20 +02:00
Gero 9c84e0dbe9 Fix remapping of 1.20.5 CLICK_WINDOW_BUTTON 2024-04-27 21:26:28 +02:00
Nassim Jahnke 66e0453398 Fix block protocols disconnect packet 2024-04-27 12:13:09 +02:00
Nassim Jahnke 7ec6888a30 Handle invalid command argument types
The client ignores these presumably for modded servers
Fixes #3806
2024-04-27 11:26:18 +02:00
Nassim Jahnke c9733948b3 Use raw data filler in 1.12->1.13 2024-04-27 10:23:04 +02:00
Nassim Jahnke 798b70cbe6 Be even more defensive about half valid items in hover events
While they aren't particularly useful or intended, they were valid
2024-04-26 19:00:37 +02:00
Nassim Jahnke 1f43ff571d Bump to 4.10.1-SNAPSHOT 2024-04-26 18:26:37 +02:00
84 changed files with 2397 additions and 2085 deletions

No files matched your search

@@ -49,17 +49,17 @@ public interface FullMappings extends BiMappings {
* Returns the unmapped string identifier for the given mapped id.
*
* @param id unmapped id
* @return unmapped string identifier
* @return unmapped string identifier, or null if out of bounds
*/
String identifier(int id);
@Nullable String identifier(int id);
/**
* Returns the mapped string identifier for the given mapped id.
*
* @param mappedId mapped id
* @return mapped string identifier
* @return mapped string identifier, or null if out of bounds
*/
String mappedIdentifier(int mappedId);
@Nullable String mappedIdentifier(int mappedId);
/**
* Returns the mapped string identifier for the given unmapped identifier.
@@ -66,12 +66,20 @@ public class FullMappingsBase implements FullMappings {
@Override
public String identifier(final int id) {
if (id < 0 || id >= idToString.length) {
return null;
}
final String identifier = idToString[id];
return Key.namespaced(identifier);
}
@Override
public String mappedIdentifier(final int mappedId) {
if (mappedId < 0 || mappedId >= mappedIdToString.length) {
return null;
}
final String identifier = mappedIdToString[mappedId];
return Key.namespaced(identifier);
}
@@ -132,8 +132,19 @@ public class MappingDataBase implements MappingData {
return MappingDataLoader.INSTANCE.loadMappings(data, key);
}
protected @Nullable FullMappings loadFullMappings(final CompoundTag data, final CompoundTag unmappedIdentifiers, final CompoundTag mappedIdentifiers, final String key) {
return MappingDataLoader.INSTANCE.loadFullMappings(data, unmappedIdentifiers, mappedIdentifiers, key);
protected @Nullable FullMappings loadFullMappings(final CompoundTag data, final CompoundTag unmappedIdentifiersTag, final CompoundTag mappedIdentifiersTag, final String key) {
if (!unmappedIdentifiersTag.contains(key) || !mappedIdentifiersTag.contains(key)) {
return null;
}
final List<String> unmappedIdentifiers = identifiersFromGlobalIds(unmappedIdentifiersTag, key);
final List<String> mappedIdentifiers = identifiersFromGlobalIds(mappedIdentifiersTag, key);
Mappings mappings = loadBiMappings(data, key); // Load as bi-mappings to keep the inverse cached
if (mappings == null) {
mappings = new IdentityMappings(unmappedIdentifiers.size(), mappedIdentifiers.size());
}
return new FullMappingsBase(unmappedIdentifiers, mappedIdentifiers, mappings);
}
protected @Nullable BiMappings loadBiMappings(final CompoundTag data, final String key) {
@@ -53,7 +53,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.checkerframework.checker.nullness.qual.Nullable;
public class MappingDataLoader {
@@ -276,21 +275,6 @@ public class MappingDataLoader {
return mappingsSupplier.create(mappings, mappedSizeTag.asInt());
}
public FullMappings loadFullMappings(final CompoundTag mappingsTag, final CompoundTag unmappedIdentifiersTag, final CompoundTag mappedIdentifiersTag, final String key) {
if (!unmappedIdentifiersTag.contains(key) || !mappedIdentifiersTag.contains(key)) {
return null;
}
final List<String> unmappedIdentifiers = identifiersFromGlobalIds(unmappedIdentifiersTag, key);
final List<String> mappedIdentifiers = identifiersFromGlobalIds(mappedIdentifiersTag, key);
Mappings mappings = loadMappings(mappingsTag, key);
if (mappings == null) {
mappings = new IdentityMappings(unmappedIdentifiers.size(), mappedIdentifiers.size());
}
return new FullMappingsBase(unmappedIdentifiers, mappedIdentifiers, mappings);
}
public @Nullable List<String> identifiersFromGlobalIds(final CompoundTag mappingsTag, final String key) {
final Mappings mappings = loadMappings(mappingsTag, key);
if (mappings == null) {
@@ -22,6 +22,7 @@
*/
package com.viaversion.viaversion.api.minecraft.data;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.FullMappings;
import com.viaversion.viaversion.api.protocol.Protocol;
@@ -44,7 +45,7 @@ public final class StructuredDataContainer {
public StructuredDataContainer(final StructuredData<?>[] dataArray) {
this(new Reference2ObjectOpenHashMap<>(dataArray.length));
for (final StructuredData<?> data : dataArray) {
add(data);
this.data.put(data.key(), data);
}
}
@@ -138,6 +139,7 @@ public final class StructuredDataContainer {
*/
public void setIdLookup(final Protocol<?, ?, ?, ?> protocol, final boolean mappedNames) {
this.lookup = protocol.getMappingData().getDataComponentSerializerMappings();
Preconditions.checkNotNull(this.lookup, "Data component serializer mappings are null");
this.mappedNames = mappedNames;
}
@@ -159,10 +161,6 @@ public final class StructuredDataContainer {
return data;
}
private <T> void add(final StructuredData<T> data) {
set(data.key(), data.value());
}
@Override
public String toString() {
return "StructuredDataContainer{" +
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
public static void initialize(final Protocol<?, ?, ?, ?> protocol) {
EntityTypeUtil.initialize(values(), TYPES, protocol, (type, id) -> type.id = id);
}
}
@@ -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);
}
}
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
* 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
@@ -38,87 +38,158 @@ public enum EntityTypes1_20_5 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),
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_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),
ARMADILLO(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(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
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),
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),
@@ -129,115 +200,44 @@ public enum EntityTypes1_20_5 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),
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_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),
ABSTRACT_WIND_CHARGE(PROJECTILE_ABSTRACT, null),
WIND_CHARGE(ABSTRACT_WIND_CHARGE),
BREEZE_WIND_CHARGE(ABSTRACT_WIND_CHARGE),
// 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;
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
* 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
@@ -62,7 +62,7 @@ public class ItemType1_20_5 extends Type<Item> {
return new Reference2ObjectOpenHashMap<>();
}
final Map<StructuredDataKey<?>, StructuredData<?>> map = new Reference2ObjectOpenHashMap<>(valuesSize + markersSize);
final Map<StructuredDataKey<?>, StructuredData<?>> map = new Reference2ObjectOpenHashMap<>();
for (int i = 0; i < valuesSize; i++) {
final StructuredData<?> value = dataType.read(buffer);
final StructuredDataKey<?> key = dataType.key(value.id());
@@ -79,10 +79,10 @@ public class StructuredDataType extends Type<StructuredData<?>> {
types = new StructuredDataKey[mappings.mappedSize()];
}
public DataFiller add(final StructuredDataKey<?> reader) {
final int id = mappings.mappedId(reader.identifier());
Preconditions.checkArgument(id != -1, "No mapped id found for %s", reader.identifier());
types[id] = reader;
public DataFiller add(final StructuredDataKey<?> key) {
final int id = mappings.mappedId(key.identifier());
Preconditions.checkArgument(id != -1, "No mapped id found for %s", key.identifier());
types[id] = key;
return this;
}
}
@@ -22,6 +22,7 @@
*/
package com.viaversion.viaversion.api.type.types.misc;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.data.FullMappings;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.type.Type;
@@ -58,6 +59,10 @@ public abstract class DynamicType<T extends IdHolder> extends Type<T> {
}
}
public RawDataFiller rawFiller() {
return new RawDataFiller();
}
public final class DataFiller {
private final FullMappings mappings;
@@ -65,6 +70,7 @@ public abstract class DynamicType<T extends IdHolder> extends Type<T> {
private DataFiller(final Protocol<?, ?, ?, ?> protocol, final boolean useMappedNames) {
this.mappings = mappings(protocol);
Preconditions.checkNotNull(mappings, "Mappings for %s are null", protocol.getClass());
this.useMappedNames = useMappedNames;
}
@@ -72,8 +78,11 @@ public abstract class DynamicType<T extends IdHolder> extends Type<T> {
readers.put(useMappedNames ? mappings.mappedId(identifier) : mappings.id(identifier), reader);
return this;
}
}
public DataFiller reader(final int id, final DataReader<T> reader) {
public final class RawDataFiller {
public RawDataFiller reader(final int id, final DataReader<T> reader) {
readers.put(id, reader);
return this;
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
* 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
@@ -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 <T> entity type
*/
public static <T extends EntityType> void initialize(final T[] values, final EntityType[] typesToFill, final Protocol<?, ?, ?, ?> protocol, final EntityIdSetter<T> 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) {
@@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
import com.viaversion.viaversion.util.ComponentUtil;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -58,12 +59,12 @@ public class DeathListener extends ViaBukkitListener {
// If online
UserConnection userConnection = getUserConnection(p);
if (userConnection != null) {
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.COMBAT_EVENT, null, userConnection);
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.COMBAT_EVENT, userConnection);
try {
wrapper.write(Type.VAR_INT, 2); // Event - Entity dead
wrapper.write(Type.VAR_INT, p.getEntityId()); // Player ID
wrapper.write(Type.INT, p.getEntityId()); // Entity ID
Protocol1_9To1_8.STRING_TO_JSON.write(wrapper, msg); // Message
wrapper.write(Type.COMPONENT, ComponentUtil.plainToJson(msg)); // Message
wrapper.scheduleSend(Protocol1_9To1_8.class);
} catch (Exception e) {
+1 -1
View File
@@ -22,4 +22,4 @@ tasks.named<Jar>("sourcesJar") {
from(project(":viaversion-api").sourceSets.main.get().allSource)
}
publishShadowJar()
publishShadowJar()
@@ -23,6 +23,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.ProtocolInfo;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.ProtocolPathEntry;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
@@ -158,20 +159,22 @@ public class BaseProtocol1_7 extends AbstractProtocol<BaseClientboundPacket, Bas
// Login Start Packet
registerServerbound(ServerboundLoginPackets.HELLO, wrapper -> {
ProtocolVersion protocol = wrapper.user().getProtocolInfo().protocolVersion();
final UserConnection user = wrapper.user();
final ProtocolVersion protocol = user.getProtocolInfo().protocolVersion();
if (Via.getConfig().blockedProtocolVersions().contains(protocol)) {
if (!wrapper.user().getChannel().isOpen()) return;
if (!wrapper.user().shouldApplyBlockProtocol()) return;
if (!user.getChannel().isOpen() || !user.shouldApplyBlockProtocol()) {
return;
}
final String disconnectMessage = ChatColorUtil.translateAlternateColorCodes(Via.getConfig().getBlockedDisconnectMsg());
PacketWrapper disconnectPacket = PacketWrapper.create(ClientboundLoginPackets.LOGIN_DISCONNECT, wrapper.user()); // Disconnect Packet
wrapper.write(Type.COMPONENT, ComponentUtil.plainToJson(disconnectMessage));
wrapper.cancel(); // cancel current
final String disconnectMessage = ChatColorUtil.translateAlternateColorCodes(Via.getConfig().getBlockedDisconnectMsg());
final PacketWrapper disconnectPacket = PacketWrapper.create(ClientboundLoginPackets.LOGIN_DISCONNECT, user);
disconnectPacket.write(Type.COMPONENT, ComponentUtil.plainToJson(disconnectMessage));
// Send and close
ChannelFuture future = disconnectPacket.sendFuture(null);
future.addListener(f -> wrapper.user().getChannel().close());
final ChannelFuture future = disconnectPacket.sendFuture(null);
future.addListener(f -> user.getChannel().close());
}
});
@@ -39,6 +39,8 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
import com.viaversion.viaversion.api.type.types.version.Types1_13;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
import com.viaversion.viaversion.protocols.base.ClientboundStatusPackets;
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
@@ -170,9 +172,11 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
EntityPackets.register(this);
WorldPackets.register(this);
registerClientbound(State.LOGIN, 0x00, 0x00, wrapper -> componentRewriter.processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT)));
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), wrapper -> {
componentRewriter.processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT));
});
registerClientbound(State.STATUS, 0x00, 0x00, new PacketHandlers() {
registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE.getId(), ClientboundStatusPackets.STATUS_RESPONSE.getId(), new PacketHandlers() {
@Override
public void register() {
map(Type.STRING);
@@ -840,12 +844,11 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
ConnectionData.init();
RecipeData.init();
BlockIdData.init();
Types1_13.PARTICLE.filler(this)
Types1_13.PARTICLE.rawFiller()
.reader(3, ParticleType.Readers.BLOCK)
.reader(20, ParticleType.Readers.DUST)
.reader(11, ParticleType.Readers.DUST)
@@ -854,6 +857,8 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
if (Via.getConfig().isServersideBlockConnections() && Via.getManager().getProviders().get(BlockConnectionProvider.class) instanceof PacketBlockConnectionProvider) {
BlockConnectionStorage.init();
}
super.onMappingDataLoaded();
}
@Override
@@ -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;
@@ -140,11 +141,11 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_1
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
WorldPackets.air = MAPPINGS.getBlockStateMappings().getNewId(0);
WorldPackets.voidAir = MAPPINGS.getBlockStateMappings().getNewId(8591);
WorldPackets.caveAir = MAPPINGS.getBlockStateMappings().getNewId(8592);
EntityTypes1_14.initialize(this);
Types1_13_2.PARTICLE.filler(this, false)
.reader("block", ParticleType.Readers.BLOCK)
.reader("dust", ParticleType.Readers.DUST)
@@ -155,6 +156,8 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_1
.reader("dust", ParticleType.Readers.DUST)
.reader("falling_dust", ParticleType.Readers.BLOCK)
.reader("item", ParticleType.Readers.ITEM1_13_2);
super.onMappingDataLoaded();
}
@Override
@@ -38,13 +38,6 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
public MetadataRewriter1_14To1_13_2(Protocol1_14To1_13_2 protocol) {
super(protocol);
mapTypes(EntityTypes1_13.EntityType.values(), EntityTypes1_14.class);
if (Via.getConfig().translateOcelotToCat()) {
// A better solution for this would be to despawn the ocelot and spawn a cat in its place, but that would
// require a lot of data tracking and is not worth the effort.
mapEntityType(EntityTypes1_13.EntityType.OCELOT, EntityTypes1_14.CAT);
}
}
@Override
@@ -66,7 +59,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
EntityTracker1_14 tracker = tracker(event.user());
int entityId = event.entityId();
tracker.setInsentientData(entityId, (byte) ((((Number) meta.getValue()).byteValue() & ~0x4)
| (tracker.getInsentientData(entityId) & 0x4))); // New attacking metadata
| (tracker.getInsentientData(entityId) & 0x4))); // New attacking metadata
meta.setValue(tracker.getInsentientData(entityId));
});
@@ -92,7 +85,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
EntityTracker1_14 tracker = tracker(event.user());
int entityId = event.entityId();
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
| ((boolean) meta.getValue() ? 0x4 : 0))); // New attacking
| ((boolean) meta.getValue() ? 0x4 : 0))); // New attacking
event.createExtraMeta(new Metadata(13, Types1_14.META_TYPES.byteType, tracker.getInsentientData(entityId)));
event.cancel(); // "Are hands held up"
} else if (meta.id() > 16) {
@@ -150,7 +143,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
EntityTracker1_14 tracker = tracker(event.user());
int entityId = event.entityId();
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
| ((boolean) meta.getValue() ? 0x4 : 0))); // New attacking
| ((boolean) meta.getValue() ? 0x4 : 0))); // New attacking
event.createExtraMeta(new Metadata(13, Types1_14.META_TYPES.byteType, tracker.getInsentientData(entityId)));
event.cancel(); // "Is swinging arms"
});
@@ -174,14 +167,17 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
filter().type(EntityTypes1_14.OCELOT).removeIndex(16); // owner uuid
filter().type(EntityTypes1_14.OCELOT).removeIndex(15); // data
filter().handler((event, meta) -> {
EntityType type = event.entityType();
if (type.is(EntityTypes1_14.WITCH) || type.is(EntityTypes1_14.RAVAGER) || type.isOrHasParent(EntityTypes1_14.ABSTRACT_ILLAGER_BASE)) {
if (meta.id() >= 14) { // 19w13 added a new boolean (raid participant - is celebrating) with id 14
meta.setId(meta.id() + 1);
}
}
});
filter().type(EntityTypes1_14.ABSTRACT_RAIDER).addIndex(14); // celebrating
}
@Override
public void onMappingDataLoaded() {
mapTypes();
if (Via.getConfig().translateOcelotToCat()) {
// A better solution for this would be to despawn the ocelot and spawn a cat in its place, but that would
// require a lot of data tracking and is not worth the effort.
mapEntityType(EntityTypes1_13.EntityType.OCELOT, EntityTypes1_14.CAT);
}
}
@Override
@@ -66,7 +66,7 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_1
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
EntityTypes1_15.initialize(this);
int[] shulkerBoxes = new int[17];
int shulkerBoxOffset = 501;
@@ -74,6 +74,8 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_1
shulkerBoxes[i] = shulkerBoxOffset + i;
}
tagRewriter.addTag(RegistryType.BLOCK, "minecraft:shulker_boxes", shulkerBoxes);
super.onMappingDataLoaded();
}
@Override
@@ -84,7 +84,7 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
EntityTypes1_16_2.initialize(this);
tagRewriter.addTag(RegistryType.ITEM, "minecraft:stone_crafting_materials", 14, 962);
tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:mushroom_grow_block");
@@ -99,6 +99,8 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1
"minecraft:stone_pressure_plates", "minecraft:nylium", "minecraft:gold_ores", "minecraft:pressure_plates",
"minecraft:logs_that_burn", "minecraft:strider_warm_blocks", "minecraft:warped_stems", "minecraft:infiniburn_end",
"minecraft:base_stone_nether", "minecraft:base_stone_overworld");
super.onMappingDataLoaded();
}
@Override
@@ -18,7 +18,6 @@
package com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.metadata;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2;
import com.viaversion.viaversion.api.type.types.version.Types1_16;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
@@ -29,7 +28,6 @@ public class MetadataRewriter1_16_2To1_16_1 extends EntityRewriter<ClientboundPa
public MetadataRewriter1_16_2To1_16_1(Protocol1_16_2To1_16_1 protocol) {
super(protocol);
mapTypes(EntityTypes1_16.values(), EntityTypes1_16_2.class);
}
@Override
@@ -48,6 +46,11 @@ public class MetadataRewriter1_16_2To1_16_1 extends EntityRewriter<ClientboundPa
});
}
@Override
public void onMappingDataLoaded() {
mapTypes();
}
@Override
public EntityType typeFromId(int type) {
return EntityTypes1_16_2.getTypeFromId(type);
@@ -35,6 +35,8 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
import com.viaversion.viaversion.api.type.types.version.Types1_16;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
import com.viaversion.viaversion.protocols.base.ClientboundStatusPackets;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.TranslationMappings;
@@ -79,14 +81,14 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
new StatisticsRewriter<>(this).register(ClientboundPackets1_15.STATISTICS);
// Login Success
registerClientbound(State.LOGIN, 0x02, 0x02, wrapper -> {
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), wrapper -> {
// Transform string to a uuid
UUID uuid = UUID.fromString(wrapper.read(Type.STRING));
wrapper.write(Type.UUID, uuid);
});
// Motd Status - line breaks are no longer allowed for player samples
registerClientbound(State.STATUS, 0x00, 0x00, wrapper -> {
registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE.getId(), ClientboundStatusPackets.STATUS_RESPONSE.getId(), wrapper -> {
String original = wrapper.passthrough(Type.STRING);
JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class);
JsonObject players = object.getAsJsonObject("players");
@@ -212,8 +214,6 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
int[] wallPostOverrideTag = new int[47];
int arrayIndex = 0;
wallPostOverrideTag[arrayIndex++] = 140;
@@ -257,11 +257,14 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
tagRewriter.addEmptyTags(RegistryType.ITEM, "minecraft:beds", "minecraft:coals", "minecraft:fences", "minecraft:flowers",
"minecraft:lectern_books", "minecraft:music_discs", "minecraft:small_flowers", "minecraft:tall_flowers", "minecraft:trapdoors", "minecraft:walls", "minecraft:wooden_fences");
EntityTypes1_16.initialize(this);
Types1_16.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
.reader("dust", ParticleType.Readers.DUST)
.reader("falling_dust", ParticleType.Readers.BLOCK)
.reader("item", ParticleType.Readers.ITEM1_13_2);
super.onMappingDataLoaded();
}
@Override
@@ -18,7 +18,6 @@
package com.viaversion.viaversion.protocols.protocol1_16to1_15_2.metadata;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.type.types.version.Types1_16;
@@ -30,8 +29,6 @@ public class MetadataRewriter1_16To1_15_2 extends EntityRewriter<ClientboundPack
public MetadataRewriter1_16To1_15_2(Protocol1_16To1_15_2 protocol) {
super(protocol);
mapEntityType(EntityTypes1_15.ZOMBIE_PIGMAN, EntityTypes1_16.ZOMBIFIED_PIGLIN);
mapTypes(EntityTypes1_15.values(), EntityTypes1_16.class);
}
@Override
@@ -50,6 +47,11 @@ public class MetadataRewriter1_16To1_15_2 extends EntityRewriter<ClientboundPack
});
}
@Override
public void onMappingDataLoaded() {
mapTypes();
}
@Override
public EntityType typeFromId(int type) {
return EntityTypes1_16.getTypeFromId(type);
@@ -188,8 +188,6 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
tagRewriter.addEmptyTags(RegistryType.ITEM, "minecraft:candles", "minecraft:ignored_by_piglin_babies", "minecraft:piglin_food", "minecraft:freeze_immune_wearables",
"minecraft:axolotl_tempt_items", "minecraft:occludes_vibration_signals", "minecraft:fox_food",
"minecraft:diamond_ores", "minecraft:iron_ores", "minecraft:lapis_ores", "minecraft:redstone_ores",
@@ -203,6 +201,7 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
tagRewriter.addEmptyTags(RegistryType.ENTITY, "minecraft:powder_snow_walkable_mobs", "minecraft:axolotl_always_hostiles", "minecraft:axolotl_tempted_hostiles",
"minecraft:axolotl_hunt_targets", "minecraft:freeze_hurts_extra_types", "minecraft:freeze_immune_entity_types");
EntityTypes1_17.initialize(this);
Types1_17.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
.reader("dust", ParticleType.Readers.DUST)
@@ -210,6 +209,8 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION)
.reader("item", ParticleType.Readers.ITEM1_13_2)
.reader("vibration", ParticleType.Readers.VIBRATION);
super.onMappingDataLoaded();
}
@Override
@@ -22,7 +22,6 @@ import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
@@ -40,7 +39,6 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
public EntityPackets(Protocol1_17To1_16_4 protocol) {
super(protocol);
mapTypes(EntityTypes1_16_2.values(), EntityTypes1_17.class);
}
@Override
@@ -174,6 +172,11 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
filter().type(EntityTypes1_17.SHULKER).removeIndex(17);
}
@Override
public void onMappingDataLoaded() {
mapTypes();
}
@Override
public EntityType typeFromId(int type) {
return EntityTypes1_17.getTypeFromId(type);
@@ -85,7 +85,6 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
Types1_18.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
.reader("block_marker", ParticleType.Readers.BLOCK)
@@ -94,6 +93,8 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION)
.reader("item", ParticleType.Readers.ITEM1_13_2)
.reader("vibration", ParticleType.Readers.VIBRATION);
super.onMappingDataLoaded();
}
@Override
@@ -190,7 +190,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
chatTypeStorage.clear();
final CompoundTag registry = wrapper.passthrough(Type.NAMED_COMPOUND_TAG);
final ListTag<CompoundTag> chatTypes = TagUtil.getRegistryEntries(registry, "chat_type");
final ListTag<CompoundTag> chatTypes = TagUtil.removeRegistryEntries(registry, "chat_type");
for (final CompoundTag chatType : chatTypes) {
final NumberTag idTag = chatType.getNumberTag("id");
chatTypeStorage.addChatType(idTag.asInt(), chatType);
@@ -342,7 +342,6 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
Types1_19_3.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
.reader("block_marker", ParticleType.Readers.BLOCK)
@@ -354,6 +353,8 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
.reader("shriek", ParticleType.Readers.SHRIEK);
EntityTypes1_19_3.initialize(this);
super.onMappingDataLoaded();
}
@Override
@@ -93,7 +93,6 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
EntityTypes1_19_4.initialize(this);
Types1_19_4.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
@@ -105,6 +104,8 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
.reader("vibration", ParticleType.Readers.VIBRATION1_19)
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
.reader("shriek", ParticleType.Readers.SHRIEK);
super.onMappingDataLoaded();
}
@Override
@@ -289,7 +289,6 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
Types1_19.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
.reader("block_marker", ParticleType.Readers.BLOCK)
@@ -301,6 +300,8 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
.reader("shriek", ParticleType.Readers.SHRIEK);
EntityTypes1_19.initialize(this);
super.onMappingDataLoaded();
}
@Override
@@ -345,7 +345,6 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
EntityTypes1_20_3.initialize(this);
Types1_20_3.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
@@ -357,6 +356,8 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
.reader("vibration", ParticleType.Readers.VIBRATION1_20_3)
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
.reader("shriek", ParticleType.Readers.SHRIEK);
super.onMappingDataLoaded();
}
@Override
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
* 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
@@ -68,7 +68,7 @@ public final class Protocol1_20_5To1_20_3 extends AbstractProtocol<ClientboundPa
private final EntityPacketRewriter1_20_5 entityRewriter = new EntityPacketRewriter1_20_5(this);
private final BlockItemPacketRewriter1_20_5 itemRewriter = new BlockItemPacketRewriter1_20_5(this);
private final TagRewriter<ClientboundPacket1_20_3> tagRewriter = new TagRewriter<>(this);
private final ComponentRewriter<ClientboundPacket1_20_3> componentRewriter = new ComponentRewriter1_20_5(this);
private final ComponentRewriter1_20_5<ClientboundPacket1_20_3> componentRewriter = new ComponentRewriter1_20_5<>(this, Types1_20_5.STRUCTURED_DATA);
public Protocol1_20_5To1_20_3() {
super(ClientboundPacket1_20_3.class, ClientboundPacket1_20_5.class, ServerboundPacket1_20_3.class, ServerboundPacket1_20_5.class);
@@ -243,8 +243,6 @@ public final class Protocol1_20_5To1_20_3 extends AbstractProtocol<ClientboundPa
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
EntityTypes1_20_5.initialize(this);
Types1_20_5.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
@@ -280,6 +278,8 @@ public final class Protocol1_20_5To1_20_3 extends AbstractProtocol<ClientboundPa
.add(StructuredDataKey.ITEM_NAME).add(StructuredDataKey.OMINOUS_BOTTLE_AMPLIFIER);
tagRewriter.addTag(RegistryType.ITEM, "minecraft:dyeable", 853, 854, 855, 856, 1120);
super.onMappingDataLoaded();
}
@Override
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
* 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
@@ -24,7 +24,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public final class BannerPatterns1_20_5 {
private static final KeyMappings PATTERNS = new KeyMappings(
public static final KeyMappings PATTERNS = new KeyMappings(
"base",
"square_bottom_left",
"square_bottom_right",
@@ -0,0 +1,110 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectSet;
public final class DamageTypes1_20_3 {
private static final Object2ObjectMap<String, CompoundTag> DAMAGE_TYPES = new Object2ObjectOpenHashMap<>();
static {
DAMAGE_TYPES.put("in_fire", create("inFire", 0.1F));
DAMAGE_TYPES.put("lightning_bolt", create("lightningBolt", 0.1F));
DAMAGE_TYPES.put("on_fire", create("onFire", 0.0F, "burning"));
DAMAGE_TYPES.put("lava", create("lava", 0.1F, "burning"));
DAMAGE_TYPES.put("hot_floor", create("hotFloor", 0.1F, "burning"));
DAMAGE_TYPES.put("in_wall", create("inWall", 0.0F));
DAMAGE_TYPES.put("cramming", create("cramming", 0.0F));
DAMAGE_TYPES.put("drown", create("drown", 0.0F, "drowning"));
DAMAGE_TYPES.put("starve", create("starve", 0.0F));
DAMAGE_TYPES.put("cactus", create("cactus", 0.1F));
DAMAGE_TYPES.put("fall", create("fall", "when_caused_by_living_non_player", 0.0F, null, "fall_variants"));
DAMAGE_TYPES.put("fly_into_wall", create("flyIntoWall", 0.0F));
DAMAGE_TYPES.put("out_of_world", create("outOfWorld", 0.0F));
DAMAGE_TYPES.put("generic", create("generic", 0.0F));
DAMAGE_TYPES.put("magic", create("magic", 0.0F));
DAMAGE_TYPES.put("wither", create("wither", 0.0F));
DAMAGE_TYPES.put("dragon_breath", create("dragonBreath", 0.0F));
DAMAGE_TYPES.put("dry_out", create("dryout", 0.1F));
DAMAGE_TYPES.put("sweet_berry_bush", create("sweetBerryBush", 0.1F, "poking"));
DAMAGE_TYPES.put("freeze", create("freeze", 0.0F, "freezing"));
DAMAGE_TYPES.put("stalagmite", create("stalagmite", 0.0F));
DAMAGE_TYPES.put("falling_block", create("fallingBlock", 0.1F));
DAMAGE_TYPES.put("falling_anvil", create("anvil", 0.1F));
DAMAGE_TYPES.put("falling_stalactite", create("fallingStalactite", 0.1F));
DAMAGE_TYPES.put("sting", create("sting", 0.1F));
DAMAGE_TYPES.put("mob_attack", create("mob", 0.1F));
DAMAGE_TYPES.put("mob_attack_no_aggro", create("mob", 0.1F));
DAMAGE_TYPES.put("player_attack", create("player", 0.1F));
DAMAGE_TYPES.put("arrow", create("arrow", 0.1F));
DAMAGE_TYPES.put("trident", create("trident", 0.1F));
DAMAGE_TYPES.put("mob_projectile", create("mob", 0.1F));
DAMAGE_TYPES.put("fireworks", create("fireworks", 0.1F));
DAMAGE_TYPES.put("unattributed_fireball", create("onFire", 0.1F, "burning"));
DAMAGE_TYPES.put("fireball", create("fireball", 0.1F, "burning"));
DAMAGE_TYPES.put("wither_skull", create("witherSkull", 0.1F));
DAMAGE_TYPES.put("thrown", create("thrown", 0.1F));
DAMAGE_TYPES.put("indirect_magic", create("indirectMagic", 0.0F));
DAMAGE_TYPES.put("thorns", create("thorns", 0.1F, "thorns"));
DAMAGE_TYPES.put("explosion", create("explosion", "always", 0.1F));
DAMAGE_TYPES.put("player_explosion", create("explosion.player", "always", 0.1F));
DAMAGE_TYPES.put("sonic_boom", create("sonic_boom", "always", 0.0F));
DAMAGE_TYPES.put("bad_respawn_point", create("badRespawnPoint", "always", 0.1F, "hurt", "intentional_game_design"));
DAMAGE_TYPES.put("outside_border", create("outsideBorder", 0.0F));
DAMAGE_TYPES.put("generic_kill", create("genericKill", 0.0F));
}
public static CompoundTag get(String key) {
return DAMAGE_TYPES.get(key);
}
public static ObjectSet<String> keys() {
return DAMAGE_TYPES.keySet();
}
private static CompoundTag create(String messageId, String scaling, float exhaustion) {
return create(messageId, scaling, exhaustion, null, null);
}
private static CompoundTag create(String messageId, float exhaustion, String effects) {
return create(messageId, "when_caused_by_living_non_player", exhaustion, effects, null);
}
private static CompoundTag create(String messageId, float exhaustion) {
return create(messageId, "when_caused_by_living_non_player", exhaustion);
}
private static CompoundTag create(String messageId, String scaling, float exhaustion, String damageEffects, String deathMessageType) {
final CompoundTag tag = new CompoundTag();
tag.putString("message_id", messageId);
tag.putString("scaling", scaling);
tag.putFloat("exhaustion", exhaustion);
if (damageEffects != null) {
tag.putString("effects", damageEffects);
}
if (deathMessageType != null) {
tag.putString("death_message_type", deathMessageType);
}
return tag;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
* 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
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
* 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
@@ -94,6 +94,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimMater
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimPatterns1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPacket1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPackets1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.storage.BannerPatternStorage;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.rewriter.ItemRewriter;
import com.viaversion.viaversion.util.ComponentUtil;
@@ -159,10 +160,10 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_20_3.WINDOW_PROPERTY);
registerCreativeInvAction(ServerboundPackets1_20_5.CREATIVE_INVENTORY_ACTION);
protocol.registerServerbound(ServerboundPackets1_20_5.CLICK_WINDOW_BUTTON, wrapper -> {
final byte containerId = wrapper.read(Type.BYTE);
final byte buttonId = wrapper.read(Type.BYTE);
wrapper.write(Type.VAR_INT, (int) containerId);
wrapper.write(Type.VAR_INT, (int) buttonId);
final byte containerId = wrapper.read(Type.VAR_INT).byteValue();
final byte buttonId = wrapper.read(Type.VAR_INT).byteValue();
wrapper.write(Type.BYTE, containerId);
wrapper.write(Type.BYTE, buttonId);
});
protocol.registerClientbound(ClientboundPackets1_20_3.ADVANCEMENTS, wrapper -> {
@@ -352,10 +353,10 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
if (item == null) return null;
super.handleItemToServer(connection, item);
return toOldItem(item, DATA_CONVERTER);
return toOldItem(connection, item, DATA_CONVERTER);
}
public Item toOldItem(final Item item, final StructuredDataConverter dataConverter) {
public Item toOldItem(final UserConnection connection, final Item item, final StructuredDataConverter dataConverter) {
// Start out with custom data and add the rest on top, or short-curcuit with the original item
final StructuredDataContainer data = item.structuredData();
data.setIdLookup(protocol, true);
@@ -368,7 +369,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
}
for (final StructuredData<?> structuredData : data.data().values()) {
dataConverter.writeToTag(structuredData, tag);
dataConverter.writeToTag(connection, structuredData, tag);
}
return dataItem;
@@ -627,24 +628,22 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
final int useDuration = instrument.getInt("use_duration");
final float range = instrument.getFloat("range");
Holder<SoundEvent> soundEvent;
final Tag soundEventTag = instrument.get("sound_event");
if (soundEventTag instanceof IntTag) {
soundEvent = Holder.of(((IntTag) soundEventTag).asInt());
} else if (soundEventTag instanceof CompoundTag) {
final CompoundTag soundEventCompound = (CompoundTag) soundEventTag;
final StringTag identifier = soundEventCompound.getStringTag("identifier");
final Holder<SoundEvent> soundEvent;
final CompoundTag soundEventTag = instrument.getCompoundTag("sound_event");
if (soundEventTag != null) {
final StringTag identifier = soundEventTag.getStringTag("identifier");
if (identifier == null) {
return;
}
soundEvent = Holder.of(new SoundEvent(
identifier.getValue(),
soundEventCompound.contains("fixed_range") ?
soundEventCompound.getFloat("fixed_range") : null
soundEventTag.contains("fixed_range") ? soundEventTag.getFloat("fixed_range") : null
));
} else {
return;
soundEvent = Holder.of(instrument.getInt("sound_event"));
}
data.set(StructuredDataKey.INSTRUMENT, Holder.of(new Instrument(soundEvent, useDuration, range)));
}
@@ -665,6 +664,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
if (potionEffectTag == null) {
continue;
}
possibleEffects.add(new FoodEffect(
new PotionEffect(
potionEffectTag.getInt("effect"),
@@ -696,6 +696,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
if (blocks == null) {
continue;
}
rules.add(new ToolRule(
blocks,
tag.contains("speed") ? tag.getFloat("speed") : null,
@@ -713,14 +714,17 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
final List<BannerPatternLayer> patternLayer = new ArrayList<>();
for (final CompoundTag tag : bannerPatterns) {
final CompoundTag patternTag = tag.getCompoundTag("pattern");
if (patternTag == null) {
continue;
final Holder<BannerPattern> pattern;
if (patternTag != null) {
final String assetId = patternTag.getString("asset_id");
final String translationKey = patternTag.getString("translation_key");
pattern = Holder.of(new BannerPattern(assetId, translationKey));
} else {
pattern = Holder.of(tag.getInt("pattern"));
}
final String assetId = patternTag.getString("asset_id");
final String translationKey = patternTag.getString("translation_key");
final int dyeColor = tag.getInt("dye_color");
patternLayer.add(new BannerPatternLayer(Holder.of(new BannerPattern(assetId, translationKey)), dyeColor));
patternLayer.add(new BannerPatternLayer(pattern, dyeColor));
}
data.set(StructuredDataKey.BANNER_PATTERNS, patternLayer.toArray(new BannerPatternLayer[0]));
}
@@ -1336,6 +1340,12 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
}
}
private void addBlockEntityId(final CompoundTag tag, final String id) {
if (!tag.contains("id")) {
tag.putString("id", id);
}
}
private void updateBlockEntityTag(final UserConnection connection, @Nullable final StructuredDataContainer data, final CompoundTag tag) {
if (tag == null) {
return;
@@ -1350,6 +1360,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
final ListTag<CompoundTag> beesTag = tag.getListTag("Bees", CompoundTag.class);
if (beesTag != null) {
updateBees(data, beesTag);
addBlockEntityId(tag, "beehive");
}
final ListTag<StringTag> sherdsTag = tag.getListTag("sherds", StringTag.class);
@@ -1365,11 +1376,13 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
toMappedItemId(rightSherd),
toMappedItemId(frontSherd)
));
addBlockEntityId(tag, "decorated_pot");
}
final StringTag noteBlockSoundTag = tag.getStringTag("note_block_sound");
if (noteBlockSoundTag != null) {
data.set(StructuredDataKey.NOTE_BLOCK_SOUND, noteBlockSoundTag.getValue());
addBlockEntityId(tag, "player_head");
}
final StringTag lootTableTag = tag.getStringTag("LootTable");
@@ -1401,6 +1414,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
final ListTag<CompoundTag> patternsTag = tag.getListTag("Patterns", CompoundTag.class);
if (patternsTag != null) {
final BannerPatternStorage patternStorage = connection.get(BannerPatternStorage.class);
final BannerPatternLayer[] layers = patternsTag.stream().map(patternTag -> {
final String pattern = patternTag.getString("Pattern", "");
final int color = patternTag.getInt("Color", -1);
@@ -1414,11 +1428,12 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
patternTag.putString("pattern", fullPatternIdentifier);
patternTag.putString("color", DyeColors.colorById(color));
final int id = BannerPatterns1_20_5.keyToId(fullPatternIdentifier);
return new BannerPatternLayer(Holder.of(id), color);
final int id = patternStorage != null ? patternStorage.bannerPatterns().keyToId(fullPatternIdentifier) : BannerPatterns1_20_5.keyToId(fullPatternIdentifier);
return id != -1 ? new BannerPatternLayer(Holder.of(id), color) : null;
}).filter(Objects::nonNull).toArray(BannerPatternLayer[]::new);
tag.remove("Patterns");
tag.put("patterns", patternsTag);
addBlockEntityId(tag, "banner");
if (data != null) {
data.set(StructuredDataKey.BANNER_PATTERNS, layers);
@@ -71,7 +71,8 @@ import com.viaversion.viaversion.api.minecraft.item.data.ToolRule;
import com.viaversion.viaversion.api.minecraft.item.data.Unbreakable;
import com.viaversion.viaversion.api.minecraft.item.data.WrittenBook;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPacket1_20_3;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.type.types.item.StructuredDataType;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.ArmorMaterials1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_5;
@@ -93,18 +94,25 @@ import com.viaversion.viaversion.util.UUIDUtil;
import com.viaversion.viaversion.util.Unit;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import java.util.HashMap;
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import org.checkerframework.checker.nullness.qual.Nullable;
// 1.20.5 data component -> 1.20.5 nbt conversion
public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket1_20_3> {
public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends ComponentRewriter<C> {
@SuppressWarnings("rawtypes")
protected final Map<StructuredDataKey, DataConverter> rewriters = new HashMap<>();
private final Map<StructuredDataKey<?>, ConverterPair<?>> converters = new Reference2ObjectOpenHashMap<>();
private final StructuredDataType structuredDataType;
public ComponentRewriter1_20_5(final Protocol<ClientboundPacket1_20_3, ?, ?, ?> protocol) {
/**
* @param protocol protocol
* @param structuredDataType unmapped structured data type
*/
public ComponentRewriter1_20_5(final Protocol<C, ?, ?, ?> protocol, final StructuredDataType structuredDataType) {
super(protocol, ReadType.NBT);
this.structuredDataType = structuredDataType;
register(StructuredDataKey.CUSTOM_DATA, this::convertCustomData);
register(StructuredDataKey.MAX_STACK_SIZE, this::convertMaxStackSize);
@@ -166,6 +174,8 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
@Override
protected void handleHoverEvent(final UserConnection connection, final CompoundTag hoverEventTag) {
super.handleHoverEvent(connection, hoverEventTag);
final StringTag actionTag = hoverEventTag.getStringTag("action");
if (actionTag == null) {
return;
@@ -194,19 +204,16 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
return;
}
final int itemId = Protocol1_20_5To1_20_3.MAPPINGS.getFullItemMappings().id(idTag.getValue());
int itemId = Protocol1_20_5To1_20_3.MAPPINGS.getFullItemMappings().id(idTag.getValue());
if (itemId == -1) {
return;
// Default to stone (anything that is not air)
itemId = 1;
}
final StringTag tag = contentsTag.remove("tag");
if (tag == null) {
return;
}
final CompoundTag tagTag;
try {
tagTag = (CompoundTag) SerializerVersion.V1_20_3.toTag(tag.getValue());
tagTag = tag != null ? (CompoundTag) SerializerVersion.V1_20_3.toTag(tag.getValue()) : null;
} catch (final Exception e) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().log(Level.WARNING, "Error reading 1.20.3 NBT in show_item: " + contentsTag, e);
@@ -214,19 +221,20 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
return;
}
final Item oldItem = new DataItem();
oldItem.setIdentifier(itemId);
final Item dataItem = new DataItem();
dataItem.setIdentifier(itemId);
if (tagTag != null) { // We don't need to remap data if there is none
oldItem.setTag(tagTag);
dataItem.setTag(tagTag);
}
final Item newItem = protocol.getItemRewriter().handleItemToClient(connection, oldItem);
if (newItem == null) {
return;
final Item structuredItem = protocol.getItemRewriter().handleItemToClient(connection, dataItem);
if (structuredItem.amount() < 1) {
// Cannot be empty
structuredItem.setAmount(1);
}
if (newItem.identifier() != 0) {
final String itemName = Protocol1_20_5To1_20_3.MAPPINGS.getFullItemMappings().mappedIdentifier(newItem.identifier());
if (structuredItem.identifier() != 0) {
final String itemName = Protocol1_20_5To1_20_3.MAPPINGS.getFullItemMappings().mappedIdentifier(structuredItem.identifier());
if (itemName != null) {
contentsTag.putString("id", itemName);
}
@@ -235,7 +243,7 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
contentsTag.putString("id", "minecraft:stone");
}
final Map<StructuredDataKey<?>, StructuredData<?>> data = newItem.structuredData().data();
final Map<StructuredDataKey<?>, StructuredData<?>> data = structuredItem.structuredData().data();
if (!data.isEmpty()) {
final CompoundTag components;
try {
@@ -270,34 +278,62 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
}
}
protected CompoundTag toTag(final Map<StructuredDataKey<?>, StructuredData<?>> data, final boolean empty) {
public CompoundTag toTag(final Map<StructuredDataKey<?>, StructuredData<?>> data, final boolean empty) {
final CompoundTag tag = new CompoundTag();
for (final Map.Entry<StructuredDataKey<?>, StructuredData<?>> entry : data.entrySet()) {
final StructuredDataKey<?> key = entry.getKey();
if (!rewriters.containsKey(key)) { // Should NOT happen
Via.getPlatform().getLogger().severe("No converter for " + key.identifier() + " found!");
final String identifier = key.identifier();
//noinspection rawtypes
final ConverterPair converter = converters.get(key);
if (converter == null) { // Should NOT happen
Via.getPlatform().getLogger().severe("No converter found for data component: " + identifier);
continue;
}
final StructuredData<?> value = entry.getValue();
if (value.isEmpty()) {
if (empty) {
// Theoretically not needed here, but we'll keep it for consistency
tag.put("!" + key.identifier(), new CompoundTag());
tag.put("!" + identifier, new CompoundTag());
continue;
}
throw new IllegalArgumentException("Empty structured data: " + key.identifier());
throw new IllegalArgumentException("Empty structured data: " + identifier);
}
//noinspection unchecked
final Tag valueTag = rewriters.get(key).convert(value.value());
final Tag valueTag = converter.dataConverter.convert(value.value());
if (valueTag == null) {
continue;
}
tag.put(key.identifier(), valueTag);
tag.put(identifier, valueTag);
}
return tag;
}
public List<StructuredData<?>> toData(final CompoundTag tag) {
final List<StructuredData<?>> list = new ArrayList<>();
for (final Map.Entry<String, Tag> entry : tag.entrySet()) {
final StructuredData<?> data = readFromTag(entry.getKey(), entry.getValue());
list.add(data);
}
return list;
}
public StructuredData<?> readFromTag(final String identifier, final Tag tag) {
final int id = protocol.getMappingData().getDataComponentSerializerMappings().mappedId(identifier);
Preconditions.checkArgument(id != -1, "Unknown data component: %s", identifier);
final StructuredDataKey<?> key = structuredDataType.key(id);
return readFromTag(key, id, tag);
}
private <T> StructuredData<T> readFromTag(final StructuredDataKey<T> key, final int id, final Tag tag) {
final TagConverter<T> converter = tagConverter(key);
Preconditions.checkNotNull(converter, "No converter found for: %s", key);
return StructuredData.of(key, converter.convert(tag), id);
}
// ---------------------------------------------------------------------------------------
// Conversion methods, can be overridden in future protocols to handle new changes
@@ -365,27 +401,11 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
convertHolderSet(predicateTag, "blocks", predicate.holderSet());
}
if (predicate.propertyMatchers() != null) {
final CompoundTag state = new CompoundTag();
for (final StatePropertyMatcher matcher : predicate.propertyMatchers()) {
final Either<String, StatePropertyMatcher.RangedMatcher> match = matcher.matcher();
if (match.isLeft()) {
state.putString(matcher.name(), match.left());
} else {
final StatePropertyMatcher.RangedMatcher range = match.right();
final CompoundTag rangeTag = new CompoundTag();
if (range.minValue() != null) {
rangeTag.putString("min", range.minValue());
}
if (range.maxValue() != null) {
rangeTag.putString("max", range.maxValue());
}
state.put(matcher.name(), rangeTag);
}
}
final CompoundTag state = convertPredicate(predicate);
predicateTag.put("state", state);
}
if (predicate.tag() != null) {
predicateTag.putString("nbt", serializerVersion().toSNBT(predicate.tag()));
predicateTag.put("nbt", predicate.tag());
}
predicates.add(predicateTag);
@@ -397,6 +417,27 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
return tag;
}
protected CompoundTag convertPredicate(final BlockPredicate predicate) {
final CompoundTag state = new CompoundTag();
for (final StatePropertyMatcher matcher : predicate.propertyMatchers()) {
final Either<String, StatePropertyMatcher.RangedMatcher> match = matcher.matcher();
if (match.isLeft()) {
state.putString(matcher.name(), match.left());
} else {
final StatePropertyMatcher.RangedMatcher range = match.right();
final CompoundTag rangeTag = new CompoundTag();
if (range.minValue() != null) {
rangeTag.putString("min", range.minValue());
}
if (range.maxValue() != null) {
rangeTag.putString("max", range.maxValue());
}
state.put(matcher.name(), rangeTag);
}
}
return state;
}
protected CompoundTag convertCanBreak(final AdventureModePredicate value) {
return convertCanPlaceOn(value);
}
@@ -587,7 +628,7 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
final ListTag<CompoundTag> pagesTag = new ListTag<>(CompoundTag.class);
for (final FilterableString page : value) {
final CompoundTag pageTag = new CompoundTag();
convertFilterableString(pageTag, page, 0, 1024);
convertFilterableString(pageTag, page, 1024);
pagesTag.add(pageTag);
}
tag.put("pages", pagesTag);
@@ -596,14 +637,14 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
protected CompoundTag convertWrittenBookContent(final WrittenBook value) {
final CompoundTag tag = new CompoundTag();
convertFilterableString(tag, value.title(), 0, 32);
convertFilterableString(tag, value.title(), 32);
tag.putString("author", value.author());
if (value.generation() != 0) {
tag.put("generation", convertIntRange(value.generation(), 0, 3));
}
final CompoundTag title = new CompoundTag();
convertFilterableString(title, value.title(), 0, 32);
convertFilterableString(title, value.title(), 32);
tag.put("title", title);
final ListTag<CompoundTag> pagesTag = new ListTag<>(CompoundTag.class);
@@ -730,7 +771,7 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
protected CompoundTag convertLodestoneTracker(final LodestoneTracker value) {
final CompoundTag tag = new CompoundTag();
if (value.pos() != null) {
convertGlobalPos(tag, "target", value.pos());
convertGlobalPos(tag, value.pos());
}
if (!value.tracked()) {
tag.putBoolean("tracked", false);
@@ -781,7 +822,7 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
tag.put("id", new IntArrayTag(UUIDUtil.toIntArray(value.id())));
}
if (value.properties().length > 0) {
convertProperties(tag, "properties", value.properties());
convertProperties(tag, value.properties());
}
return tag;
}
@@ -794,7 +835,7 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
final ListTag<CompoundTag> tag = new ListTag<>(CompoundTag.class);
for (final BannerPatternLayer layer : value) {
final CompoundTag layerTag = new CompoundTag();
convertBannerPattern(layerTag, "pattern", layer.pattern());
convertBannerPattern(layerTag, layer.pattern());
layerTag.put("color", convertDyeColor(layer.dyeColor()));
tag.add(layerTag);
}
@@ -897,7 +938,7 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
}
}
protected void convertHolderSet(final CompoundTag tag, final String name, HolderSet set) {
protected void convertHolderSet(final CompoundTag tag, final String name, final HolderSet set) {
if (set.hasTagKey()) {
tag.putString(name, set.tagKey());
} else {
@@ -930,10 +971,10 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
tag.put("components", toTag(components, true));
}
protected void convertFilterableString(final CompoundTag tag, final FilterableString string, final int min, final int max) {
tag.put("raw", convertString(string.raw(), min, max));
protected void convertFilterableString(final CompoundTag tag, final FilterableString string, final int max) {
tag.put("raw", convertString(string.raw(), 0, max));
if (string.filtered() != null) {
tag.put("filtered", convertString(string.filtered(), min, max));
tag.put("filtered", convertString(string.filtered(), 0, max));
}
}
@@ -944,14 +985,14 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
}
}
protected void convertGlobalPos(final CompoundTag tag, final String name, final GlobalPosition position) {
protected void convertGlobalPos(final CompoundTag tag, final GlobalPosition position) {
final CompoundTag posTag = new CompoundTag();
posTag.putString("dimension", position.dimension());
posTag.put("pos", new IntArrayTag(new int[]{position.x(), position.y(), position.z()}));
tag.put(name, posTag);
tag.put("target", posTag);
}
protected void convertProperties(final CompoundTag tag, final String name, final GameProfile.Property[] properties) {
protected void convertProperties(final CompoundTag tag, final GameProfile.Property[] properties) {
final ListTag<CompoundTag> propertiesTag = new ListTag<>(CompoundTag.class);
for (final GameProfile.Property property : properties) {
final CompoundTag propertyTag = new CompoundTag();
@@ -962,12 +1003,12 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
}
propertiesTag.add(propertyTag);
}
tag.put(name, propertiesTag);
tag.put("properties", propertiesTag);
}
protected void convertBannerPattern(final CompoundTag tag, final String name, final Holder<BannerPattern> pattern) {
protected void convertBannerPattern(final CompoundTag tag, final Holder<BannerPattern> pattern) {
if (pattern.hasId()) {
tag.putString(name, BannerPatterns1_20_5.idToKey(pattern.id()));
tag.putString("pattern", BannerPatterns1_20_5.idToKey(pattern.id()));
return;
}
@@ -975,7 +1016,7 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
final CompoundTag patternTag = new CompoundTag();
patternTag.put("asset_id", convertIdentifier(bannerPattern.assetId()));
patternTag.putString("translation_key", bannerPattern.translationKey());
tag.put(name, patternTag);
tag.put("pattern", patternTag);
}
// ---------------------------------------------------------------------------------------
@@ -1012,12 +1053,12 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
}
protected StringTag convertComponent(final Tag value) {
return convertComponent(value, 0, Integer.MAX_VALUE);
return convertComponent(value, Integer.MAX_VALUE);
}
protected StringTag convertComponent(final Tag value, final int min, final int max) {
protected StringTag convertComponent(final Tag value, final int max) {
final String json = serializerVersion().toString(serializerVersion().toComponent(value));
return new StringTag(checkStringRange(min, max, json));
return new StringTag(checkStringRange(0, max, json));
}
protected ListTag<StringTag> convertComponents(final Tag[] value, final int maxLength) {
@@ -1081,8 +1122,24 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
// ---------------------------------------------------------------------------------------
private <T> void register(final StructuredDataKey<T> key, final DataConverter<T> converter) {
rewriters.put(key, converter);
protected <T> void register(final StructuredDataKey<T> key, final DataConverter<T> dataConverter) { // TODO Remove this method
converters.put(key, new ConverterPair<>(dataConverter, null));
}
protected <T> void register(final StructuredDataKey<T> key, final DataConverter<T> dataConverter, final TagConverter<T> tagConverter) {
converters.put(key, new ConverterPair<>(dataConverter, tagConverter));
}
protected @Nullable <T> DataConverter<T> dataConverter(final StructuredDataKey<T> key) {
//noinspection unchecked
final ConverterPair<T> converters = (ConverterPair<T>) this.converters.get(key);
return converters != null ? converters.dataConverter : null;
}
protected @Nullable <T> TagConverter<T> tagConverter(final StructuredDataKey<T> key) {
//noinspection unchecked
final ConverterPair<T> converters = (ConverterPair<T>) this.converters.get(key);
return converters != null ? converters.tagConverter : null;
}
public SerializerVersion serializerVersion() {
@@ -1094,4 +1151,20 @@ public class ComponentRewriter1_20_5 extends ComponentRewriter<ClientboundPacket
Tag convert(T value);
}
@FunctionalInterface
protected interface TagConverter<T> {
T convert(final Tag tag);
}
private static final class ConverterPair<T> {
private final DataConverter<T> dataConverter;
private final TagConverter<T> tagConverter;
ConverterPair(final DataConverter<T> dataConverter, final TagConverter<T> tagConverter) {
this.dataConverter = dataConverter;
this.tagConverter = tagConverter;
}
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2023 ViaVersion and contributors
* 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
@@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@@ -40,15 +41,20 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.Clientb
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.DamageTypes1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundConfigurationPackets1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPackets1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.storage.AcknowledgedMessagesStorage;
import com.viaversion.viaversion.rewriter.EntityRewriter;
import com.viaversion.viaversion.util.Key;
import com.viaversion.viaversion.util.TagUtil;
import it.unimi.dsi.fastutil.ints.IntArraySet;
import it.unimi.dsi.fastutil.ints.IntSet;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.checkerframework.checker.nullness.qual.Nullable;
public final class EntityPacketRewriter1_20_5 extends EntityRewriter<ClientboundPacket1_20_3, Protocol1_20_5To1_20_3> {
@@ -112,37 +118,55 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
final CompoundTag entryTag = (CompoundTag) entry.getValue();
final String type = entryTag.getString("type");
final ListTag<CompoundTag> valueTag = entryTag.getListTag("value", CompoundTag.class);
RegistryEntry[] registryEntries = new RegistryEntry[valueTag.size()];
// Calculate number of entries (exclude duplicated ids)
RegistryEntry[] registryEntries = new RegistryEntry[valueTag.stream().map(e -> e.getInt("id")).distinct().toArray().length];
boolean requiresDummyValues = false;
int entriesLength = registryEntries.length;
int highestId = -1;
final IntSet ids = new IntArraySet();
for (final CompoundTag tag : valueTag) {
final String name = tag.getString("name");
final int id = tag.getInt("id");
entriesLength = Math.max(entriesLength, id + 1);
if (id >= registryEntries.length) {
// It was previously possible to have arbitrary ids
registryEntries = Arrays.copyOf(registryEntries, Math.max(registryEntries.length * 2, id + 1));
requiresDummyValues = true;
if (ids.add(id)) { // Override duplicated id without incrementing entries length
highestId = Math.max(highestId, id);
if (id >= registryEntries.length) {
// It was previously possible to have arbitrary ids, increase array length if needed
registryEntries = Arrays.copyOf(registryEntries, Math.max(registryEntries.length * 2, id + 1));
requiresDummyValues = true;
}
}
registryEntries[id] = new RegistryEntry(name, tag.get("element"));
}
// Add spit damage type
if (Key.stripMinecraftNamespace(type).equals("damage_type")) {
final int length = registryEntries.length;
registryEntries = Arrays.copyOf(registryEntries, length + 1);
// Add spit damage type
highestId++;
registryEntries = Arrays.copyOf(registryEntries, highestId + 1);
final CompoundTag spitData = new CompoundTag();
spitData.putString("scaling", "when_caused_by_living_non_player");
spitData.putString("message_id", "mob");
spitData.putFloat("exhaustion", 0.1F);
registryEntries[length] = new RegistryEntry("minecraft:spit", spitData);
registryEntries[highestId] = new RegistryEntry("minecraft:spit", spitData);
// Fill in missing damage types with 1.20.3/4 defaults
final Set<String> registryEntryKeys = Arrays.stream(registryEntries).map(e -> Key.stripMinecraftNamespace(e.key())).collect(Collectors.toSet());
for (final String key : DamageTypes1_20_3.keys()) {
if (registryEntryKeys.contains(key)) {
continue;
}
highestId++;
registryEntries = Arrays.copyOf(registryEntries, highestId + 1);
registryEntries[highestId] = new RegistryEntry(Key.namespaced(key), DamageTypes1_20_3.get(key));
}
}
if (requiresDummyValues) {
// Truncate and replace null values
if (registryEntries.length != entriesLength) {
registryEntries = Arrays.copyOf(registryEntries, entriesLength);
final int finalLength = highestId + 1;
if (registryEntries.length != finalLength) {
registryEntries = Arrays.copyOf(registryEntries, finalLength);
}
replaceNullValues(registryEntries);
}
@@ -362,6 +386,10 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
}
}
private int withAlpha(final int rgb) {
return 255 << 24 | rgb & 0xffffff;
}
@Override
protected void registerRewrites() {
filter().mapMetaType(typeId -> {
@@ -385,11 +413,27 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
Types1_20_5.META_TYPES.particleType,
null
);
filter().metaType(Types1_20_5.META_TYPES.componentType).handler((event, meta) -> protocol.getComponentRewriter().processTag(event.user(), meta.value()));
filter().metaType(Types1_20_5.META_TYPES.optionalComponentType).handler((event, meta) -> protocol.getComponentRewriter().processTag(event.user(), meta.value()));
filter().metaType(Types1_20_5.META_TYPES.itemType).handler((event, meta) -> {
final Item item = meta.value();
if (item != null && item.amount() <= 0) {
// No longer accepted by the client, needs to be properly empty
meta.setValue(null);
}
});
filter().type(EntityTypes1_20_5.LIVINGENTITY).index(10).handler((event, meta) -> {
final int effectColor = meta.value();
if (effectColor == 0) {
// No effect
meta.setTypeAndValue(Types1_20_5.META_TYPES.particlesType, new Particle[0]);
return;
}
final Particle particle = new Particle(protocol.getMappingData().getParticleMappings().mappedId("entity_effect"));
particle.add(Type.INT, effectColor);
particle.add(Type.INT, withAlpha(effectColor));
meta.setTypeAndValue(Types1_20_5.META_TYPES.particlesType, new Particle[]{particle});
});
@@ -400,7 +444,17 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
if (metaIndex == 9) {
// If the color is found first
final Metadata particleData = event.metaAtIndex(11);
addColor(particleData, meta.value());
final int color = meta.value();
if (particleData == null) {
if (color != 0) {
// Add default particle with data
final Particle particle = new Particle(protocol.getMappingData().getParticleMappings().mappedId("entity_effect"));
particle.add(Type.INT, withAlpha(color));
event.createExtraMeta(new Metadata(10, Types1_20_5.META_TYPES.particleType, particle));
}
} else {
addColor(particleData, color);
}
event.cancel();
return;
@@ -419,6 +473,13 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
}
});
filter().type(EntityTypes1_20_5.ARROW).index(10).handler((event, meta) -> {
final int color = meta.value();
if (color != -1) {
meta.setValue(withAlpha(color));
}
});
filter().type(EntityTypes1_20_5.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
final int blockState = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState));
@@ -432,7 +493,7 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
final Particle particle = particleMeta.value();
if (particle.id() == protocol.getMappingData().getParticleMappings().mappedId("entity_effect")) {
particle.getArgument(0).setValue(color);
particle.getArgument(0).setValue(withAlpha(color));
}
}
@@ -25,6 +25,7 @@ import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.GameProfile;
import com.viaversion.viaversion.api.minecraft.HolderSet;
import com.viaversion.viaversion.api.minecraft.SoundEvent;
@@ -60,6 +61,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.MapDecora
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.PotionEffects1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Potions1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimMaterials1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.storage.BannerPatternStorage;
import com.viaversion.viaversion.util.ComponentUtil;
import com.viaversion.viaversion.util.UUIDUtil;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
@@ -215,8 +217,8 @@ public final class StructuredDataConverter {
}
});
register(StructuredDataKey.BASE_COLOR, (data, tag) -> tag.putInt("Base", data));
register(StructuredDataKey.CHARGED_PROJECTILES, (data, tag) -> convertItemList(data, tag, "ChargedProjectiles"));
register(StructuredDataKey.BUNDLE_CONTENTS, (data, tag) -> convertItemList(data, tag, "Items"));
register(StructuredDataKey.CHARGED_PROJECTILES, (connection, data, tag) -> convertItemList(connection, data, tag, "ChargedProjectiles"));
register(StructuredDataKey.BUNDLE_CONTENTS, (connection, data, tag) -> convertItemList(connection, data, tag, "Items"));
register(StructuredDataKey.LODESTONE_TRACKER, (data, tag) -> {
final CompoundTag positionTag = new CompoundTag();
tag.put("LodestonePos", positionTag);
@@ -264,6 +266,7 @@ public final class StructuredDataConverter {
values.add(propertyTag);
propertiesTag.put(property.name(), values);
}
profileTag.put("Properties", propertiesTag);
});
register(StructuredDataKey.INSTRUMENT, (data, tag) -> {
// Can't do anything with direct values
@@ -303,10 +306,10 @@ public final class StructuredDataConverter {
beeTag.putInt("MinOccupationTicks", bee.minTicksInHive());
bees.add(beeTag);
}
getBlockEntityTag(tag).put("Bees", bees);
getBlockEntityTag(tag, "beehive").put("Bees", bees);
});
register(StructuredDataKey.LOCK, (data, tag) -> getBlockEntityTag(tag).put("Lock", data));
register(StructuredDataKey.NOTE_BLOCK_SOUND, (data, tag) -> getBlockEntityTag(tag).putString("note_block_sound", data));
register(StructuredDataKey.NOTE_BLOCK_SOUND, (data, tag) -> getBlockEntityTag(tag, "player_head").putString("note_block_sound", data));
register(StructuredDataKey.POT_DECORATIONS, (data, tag) -> {
IntArrayTag originalSherds = null;
@@ -326,7 +329,7 @@ public final class StructuredDataConverter {
if (originalSherds != null) {
getBackupTag(tag).put("pot_decorations", originalSherds);
}
getBlockEntityTag(tag).put("sherds", sherds);
getBlockEntityTag(tag, "decorated_pot").put("sherds", sherds);
});
register(StructuredDataKey.CREATIVE_SLOT_LOCK, (data, tag) -> tag.put("CustomCreativeLock", new CompoundTag()));
register(StructuredDataKey.DEBUG_STICK_STATE, (data, tag) -> tag.put("DebugProperty", data));
@@ -341,7 +344,13 @@ public final class StructuredDataConverter {
});
register(StructuredDataKey.BLOCK_ENTITY_DATA, (data, tag) -> {
// Handling of previously block entity tags is done using the getBlockEntityTag method
tag.put("BlockEntityTag", data);
// Merge with already added tag if needed
final CompoundTag blockEntityTag = tag.getCompoundTag("BlockEntityTag");
if (blockEntityTag != null) {
blockEntityTag.putAll(data);
} else {
tag.put("BlockEntityTag", data);
}
});
register(StructuredDataKey.CONTAINER_LOOT, (data, tag) -> {
final Tag lootTable = data.get("loot_table");
@@ -420,19 +429,33 @@ public final class StructuredDataConverter {
}
tag.put("effects", effectsTag);
});
register(StructuredDataKey.BANNER_PATTERNS, (data, tag) -> {
register(StructuredDataKey.BANNER_PATTERNS, (connection, data, tag) -> {
final BannerPatternStorage patternStorage = connection.get(BannerPatternStorage.class);
if (backupInconvertibleData) {
// Backup whole data if one of the entries is inconvertible
// Since we don't want to break the order of the entries
if (Arrays.stream(data).anyMatch(layer -> layer.pattern().isDirect() || BannerPatterns1_20_5.idToKey(layer.pattern().id()) == null)) {
if (Arrays.stream(data).anyMatch(layer -> {
if (layer.pattern().isDirect()) {
return true;
}
final int id = layer.pattern().id();
final String identifier = patternStorage != null ? patternStorage.pattern(id) : BannerPatterns1_20_5.idToKey(id);
return identifier == null || identifier.equals("flow") || identifier.equals("guster");
})) {
final ListTag<CompoundTag> originalPatterns = new ListTag<>(CompoundTag.class);
for (final BannerPatternLayer layer : data) {
final CompoundTag layerTag = new CompoundTag();
final CompoundTag patternTag = new CompoundTag();
final BannerPattern pattern = layer.pattern().value();
patternTag.putString("asset_id", pattern.assetId());
patternTag.putString("translation_key", pattern.translationKey());
layerTag.put("pattern", patternTag);
if (layer.pattern().isDirect()) {
final CompoundTag patternTag = new CompoundTag();
final BannerPattern pattern = layer.pattern().value();
patternTag.putString("asset_id", pattern.assetId());
patternTag.putString("translation_key", pattern.translationKey());
layerTag.put("pattern", patternTag);
} else {
layerTag.putInt("pattern", layer.pattern().id());
}
layerTag.putInt("dye_color", layer.dyeColor());
originalPatterns.add(layerTag);
}
@@ -446,20 +469,25 @@ public final class StructuredDataConverter {
continue;
}
final String key = BannerPatterns1_20_5.idToKey(layer.pattern().id());
final int id = layer.pattern().id();
final String key = patternStorage != null ? patternStorage.pattern(id) : BannerPatterns1_20_5.idToKey(id);
if (key == null) {
continue;
}
final String compactKey = BannerPatterns1_20_5.fullIdToCompact(key);
if (compactKey == null) {
continue;
}
final CompoundTag patternTag = new CompoundTag();
patternTag.putString("Pattern", compactKey);
patternTag.putInt("Color", layer.dyeColor());
patternsTag.add(patternTag);
}
tag.put("Patterns", patternsTag);
getBlockEntityTag(tag, "banner").put("Patterns", patternsTag);
});
register(StructuredDataKey.CONTAINER, (data, tag) -> convertItemList(data, tag, "Items"));
register(StructuredDataKey.CONTAINER, (connection, data, tag) -> convertItemList(connection, data, tag, "Items"));
register(StructuredDataKey.CAN_PLACE_ON, (data, tag) -> convertBlockPredicates(tag, data, "CanPlaceOn", HIDE_CAN_PLACE_ON));
register(StructuredDataKey.CAN_BREAK, (data, tag) -> convertBlockPredicates(tag, data, "CanDestroy", HIDE_CAN_DESTROY));
register(StructuredDataKey.MAP_POST_PROCESSING, (data, tag) -> {
@@ -637,6 +665,15 @@ public final class StructuredDataConverter {
return getOrCreate(tag, "BlockEntityTag");
}
private CompoundTag getBlockEntityTag(final CompoundTag tag, final String blockEntity) {
final CompoundTag blockEntityTag = getOrCreate(tag, "BlockEntityTag");
if (!blockEntityTag.contains("id")) {
// Add in the assumed (and required) block entity id
blockEntityTag.putString("id", blockEntity);
}
return blockEntityTag;
}
private static CompoundTag getDisplayTag(final CompoundTag tag) {
return getOrCreate(tag, "display");
}
@@ -655,7 +692,7 @@ public final class StructuredDataConverter {
return subTag;
}
static @Nullable CompoundTag removeBackupTag(final CompoundTag tag) {
public static @Nullable CompoundTag removeBackupTag(final CompoundTag tag) {
final CompoundTag backupTag = tag.getCompoundTag(BACKUP_TAG_KEY);
if (backupTag != null) {
tag.remove(BACKUP_TAG_KEY);
@@ -751,22 +788,27 @@ public final class StructuredDataConverter {
return effectDataTag;
}
private void convertItemList(final Item[] items, final CompoundTag tag, final String key) {
private void convertItemList(final UserConnection connection, final Item[] items, final CompoundTag tag, final String key) {
final ListTag<CompoundTag> itemsTag = new ListTag<>(CompoundTag.class);
for (final Item item : items) {
final CompoundTag savedItem = new CompoundTag();
final String name = toMappedItemName(item.identifier());
savedItem.putString("id", name);
if (backupInconvertibleData && name.isEmpty()) {
savedItem.putInt(ITEM_BACKUP_TAG_KEY, item.identifier());
}
savedItem.putByte("Count", (byte) item.amount());
if (item != null) {
final String name = toMappedItemName(item.identifier());
savedItem.putString("id", name);
if (backupInconvertibleData && name.isEmpty()) {
savedItem.putInt(ITEM_BACKUP_TAG_KEY, item.identifier());
}
savedItem.putByte("Count", (byte) item.amount());
final CompoundTag itemTag = new CompoundTag();
for (final StructuredData<?> data : item.structuredData().data().values()) {
writeToTag(data, itemTag);
final CompoundTag itemTag = new CompoundTag();
for (final StructuredData<?> data : item.structuredData().data().values()) {
writeToTag(connection, data, itemTag);
}
savedItem.put("tag", itemTag);
} else {
savedItem.putString("id", "air");
}
savedItem.put("tag", itemTag);
itemsTag.add(savedItem);
}
tag.put(key, itemsTag);
@@ -805,7 +847,7 @@ public final class StructuredDataConverter {
tag.putInt("HideFlags", tag.getInt("HideFlags") | value);
}
public <T> void writeToTag(final StructuredData<T> data, final CompoundTag tag) {
public <T> void writeToTag(final UserConnection connection, final StructuredData<T> data, final CompoundTag tag) {
if (data.isEmpty()) {
return;
}
@@ -813,16 +855,27 @@ public final class StructuredDataConverter {
//noinspection unchecked
final DataConverter<T> converter = (DataConverter<T>) rewriters.get(data.key());
Preconditions.checkNotNull(converter, "No converter for %s found", data.key());
converter.convert(data.value(), tag);
converter.convert(connection, data.value(), tag);
}
private <T> void register(final StructuredDataKey<T> key, final DataConverter<T> converter) {
rewriters.put(key, converter);
}
private <T> void register(final StructuredDataKey<T> key, final SimpleDataConverter<T> converter) {
final DataConverter<T> c = (connection, data, tag) -> converter.convert(data, tag);
rewriters.put(key, c);
}
@FunctionalInterface
interface DataConverter<T> {
interface SimpleDataConverter<T> {
void convert(T data, CompoundTag tag);
}
@FunctionalInterface
interface DataConverter<T> {
void convert(UserConnection connection, T data, CompoundTag tag);
}
}
@@ -1,65 +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 <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.rewriter;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.minecraft.data.StructuredData;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
// 1.20.5 nbt -> 1.20.5 data component conversion, technically only needed in VB but kept here to make maintenance easier
public final class StructuredNBTConverter {
private static final Map<String, DataConverter<?>> rewriters = new HashMap<>();
static {
register(StructuredDataKey.CUSTOM_DATA, tag -> (CompoundTag) tag);
// TODO Add missing handlers for other data types, this will probably be done after the component rework
}
public static List<StructuredData<?>> toData(final CompoundTag tag) {
final List<StructuredData<?>> data = new ArrayList<>();
for (final Map.Entry<String, Tag> entry : tag.entrySet()) {
final StructuredData<?> structuredData = readFromTag(entry.getKey(), entry.getValue());
data.add(structuredData);
}
return data;
}
@SuppressWarnings("unchecked")
public static <T> StructuredData<T> readFromTag(final String identifier, final Tag tag) {
final DataConverter<T> converter = (DataConverter<T>) rewriters.get(identifier);
Preconditions.checkNotNull(converter, "No converter for %s found", identifier);
return (StructuredData<T>) converter.convert(tag);
}
private static <T> void register(final StructuredDataKey<T> key, final DataConverter<T> converter) {
rewriters.put(key.identifier(), converter);
}
@FunctionalInterface
interface DataConverter<T> {
T convert(final Tag tag);
}
}
@@ -18,16 +18,29 @@
package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
import com.viaversion.viaversion.util.KeyMappings;
import org.checkerframework.checker.nullness.qual.Nullable;
//TODO Item rewriting doesn't have user connection context yet. That's a fairly disruptive change, so it'll be done later
// Replace BannerPatterns1_20_5.idToKey
// Used by VB
public final class BannerPatternStorage implements StorableObject {
private final Int2ObjectMap<String> bannerPatterns = new Int2ObjectOpenHashMap<>();
private KeyMappings bannerPatterns = BannerPatterns1_20_5.PATTERNS;
public Int2ObjectMap<String> bannerPatterns() {
public KeyMappings bannerPatterns() {
return bannerPatterns;
}
public void setBannerPatterns(final KeyMappings bannerPatterns) {
this.bannerPatterns = bannerPatterns;
}
public @Nullable String pattern(final int id) {
return bannerPatterns.idToKey(id);
}
@Override
public boolean clearOnServerSwitch() {
return false;
}
}
@@ -69,7 +69,6 @@ public final class Protocol1_20To1_19_4 extends AbstractProtocol<ClientboundPack
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded();
Types1_20.PARTICLE.filler(this)
.reader("block", ParticleType.Readers.BLOCK)
.reader("block_marker", ParticleType.Readers.BLOCK)
@@ -80,6 +79,8 @@ public final class Protocol1_20To1_19_4 extends AbstractProtocol<ClientboundPack
.reader("vibration", ParticleType.Readers.VIBRATION1_19)
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
.reader("shriek", ParticleType.Readers.SHRIEK);
super.onMappingDataLoaded();
}
@Override
@@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
@@ -86,7 +87,7 @@ public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, Cl
protected void registerPackets() {
super.registerPackets();
registerClientbound(State.LOGIN, 0x00, 0x00, wrapper -> {
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), wrapper -> {
if (wrapper.isReadable(Type.COMPONENT, 0)) {
// Already written as component in the base protocol
return;
@@ -18,12 +18,14 @@
package com.viaversion.viaversion.rewriter;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.data.FullMappings;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type;
import java.util.HashMap;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Abstract rewriter for the declare commands packet to handle argument type name and content changes.
@@ -118,16 +120,23 @@ public class CommandRewriter<C extends ClientboundPacketType> {
if (nodeType == 2) { // Argument node
int argumentTypeId = wrapper.read(Type.VAR_INT);
String argumentType = argumentType(argumentTypeId);
if (argumentType == null) {
// Modded servers may send unknown argument types that are ignored by the client
// Adjust the id to the hopefully still assumed out-of-bounds pos...
wrapper.write(Type.VAR_INT, mapInvalidArgumentType(argumentTypeId));
continue;
}
String newArgumentType = handleArgumentType(argumentType);
Preconditions.checkNotNull(newArgumentType, "No mapping for argument type %s", argumentType);
wrapper.write(Type.VAR_INT, mappedArgumentTypeId(newArgumentType));
// Always call the handler using the previous name
handleArgument(wrapper, argumentType);
}
if ((flags & 0x10) != 0) {
wrapper.passthrough(Type.STRING); // Suggestion type
if ((flags & 0x10) != 0) {
wrapper.passthrough(Type.STRING); // Suggestion type
}
}
}
@@ -148,21 +157,35 @@ public class CommandRewriter<C extends ClientboundPacketType> {
* @param argumentType argument type
* @return mapped argument type
*/
public String handleArgumentType(String argumentType) {
public String handleArgumentType(final String argumentType) {
if (protocol.getMappingData() != null && protocol.getMappingData().getArgumentTypeMappings() != null) {
return protocol.getMappingData().getArgumentTypeMappings().mappedIdentifier(argumentType);
}
return argumentType;
}
protected String argumentType(int argumentTypeId) {
return protocol.getMappingData().getArgumentTypeMappings().identifier(argumentTypeId);
protected @Nullable String argumentType(final int argumentTypeId) {
final FullMappings mappings = protocol.getMappingData().getArgumentTypeMappings();
final String identifier = mappings.identifier(argumentTypeId);
// Allow unknown argument types to be passed through as long as they are actually out of bounds
Preconditions.checkArgument(identifier != null || argumentTypeId >= mappings.size(), "Unknown argument type id %s", argumentTypeId);
return identifier;
}
protected int mappedArgumentTypeId(String mappedArgumentType) {
protected int mappedArgumentTypeId(final String mappedArgumentType) {
return protocol.getMappingData().getArgumentTypeMappings().mappedId(mappedArgumentType);
}
private int mapInvalidArgumentType(final int id) {
if (id < 0) {
return id;
}
final FullMappings mappings = protocol.getMappingData().getArgumentTypeMappings();
final int idx = id - mappings.size();
return mappings.mappedSize() + idx;
}
@FunctionalInterface
public interface CommandArgumentConsumer {
@@ -170,30 +170,6 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
typeMappings.setNewId(id, mappedId);
}
/**
* Maps entity ids based on the enum constant's names.
*
* @param oldTypes entity types of the higher version
* @param newTypeClass entity types enum class of the lower version
* @param <E> new enum entity type
*/
public <E extends Enum<E> & EntityType> void mapTypes(EntityType[] oldTypes, Class<E> 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.
*/
@@ -19,17 +19,10 @@ package com.viaversion.viaversion.rewriter;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.MappingData;
import com.viaversion.viaversion.api.data.Mappings;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.rewriter.RewriterBase;
import com.viaversion.viaversion.api.type.Type;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -26,13 +26,42 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public final class TagUtil {
public static ListTag<CompoundTag> getRegistryEntries(final CompoundTag tag, final String key) {
return getRegistryEntries(tag, key, null);
}
public static ListTag<CompoundTag> getRegistryEntries(final CompoundTag tag, final String key, final @Nullable ListTag<CompoundTag> defaultValue) {
CompoundTag registry = tag.getCompoundTag(Key.namespaced(key));
if (registry == null) {
registry = tag.getCompoundTag(Key.stripMinecraftNamespace(key));
if (registry == null) {
return defaultValue;
}
}
return registry.getListTag("value", CompoundTag.class);
}
public static ListTag<CompoundTag> removeRegistryEntries(final CompoundTag tag, final String key) {
return removeRegistryEntries(tag, key, null);
}
public static ListTag<CompoundTag> removeRegistryEntries(final CompoundTag tag, final String key, final @Nullable ListTag<CompoundTag> defaultValue) {
String currentKey = Key.namespaced(key);
CompoundTag registry = tag.getCompoundTag(currentKey);
if (registry == null) {
currentKey = Key.stripMinecraftNamespace(key);
registry = tag.getCompoundTag(currentKey);
if (registry == null) {
return defaultValue;
}
}
tag.remove(currentKey);
return registry.getListTag("value", CompoundTag.class);
}
public static boolean removeNamespaced(final CompoundTag tag, final String key) {
return tag.remove(Key.namespaced(key)) != null || tag.remove(Key.stripMinecraftNamespace(key)) != null;
}
public static Tag handleDeep(final Tag tag, final TagUpdater consumer) {
return handleDeep(null, tag, consumer);
}
@@ -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 <http://www.gnu.org/licenses/>.
*/
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<Integer, EntityType> returnFunction) {
for (EntityType type : types) {
if (type.getId() != -1) {
Assertions.assertEquals(type, returnFunction.apply(type.getId()));
}
}
}
}
+3 -3
View File
@@ -1,9 +1,9 @@
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
projectVersion=4.10.0
projectVersion=4.10.2
# Smile emoji
mcVersions=1.20.5,1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9
mcVersionRange=1.8-1.20.5
mcVersions=1.20.6,1.20.5,1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9
mcVersionRange=1.8-1.20.6
waterfallVersion=1.20
velocityVersion=3.3
@@ -85,8 +85,6 @@ public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1
@Override
protected void onMappingDataLoaded() {
super.onMappingDataLoaded(); // Calls load methods on rewriters
// Uncomment this if the entity types enum has been newly added specifically for this Protocol
// EntityTypes1_20_5.initialize(this);
@@ -101,6 +99,8 @@ public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1
.reader("vibration", ParticleType.Readers.VIBRATION1_20_3)
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
.reader("shriek", ParticleType.Readers.SHRIEK);*/
super.onMappingDataLoaded(); // Calls load methods on rewriters. Last in case the rewriters access the above filled data
}
@Override
+3
View File
@@ -14,6 +14,9 @@ dependencies {
tasks {
shadowJar {
manifest {
attributes["paperweight-mappings-namespace"] = "mojang"
}
archiveClassifier.set("")
archiveFileName.set("ViaVersion-${project.version}.jar")
destinationDirectory.set(rootProject.projectDir.resolve("build/libs"))