From f97c67d42a34fc9f3a8e96b0be5cca0076c9fff5 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 26 Jul 2022 23:50:19 -0700 Subject: [PATCH] Extract entity animation codes --- .../valence_extractor/extractors/EntityData.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/dev/_00a/valence_extractor/extractors/EntityData.java b/extractor/src/main/java/dev/_00a/valence_extractor/extractors/EntityData.java index 14d7bb2..051d3c4 100644 --- a/extractor/src/main/java/dev/_00a/valence_extractor/extractors/EntityData.java +++ b/extractor/src/main/java/dev/_00a/valence_extractor/extractors/EntityData.java @@ -4,9 +4,12 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import dev._00a.valence_extractor.Main; import net.minecraft.entity.EntityPose; +import net.minecraft.entity.EntityStatuses; +import net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket; import net.minecraft.util.math.Direction; import net.minecraft.util.registry.Registry; +import java.lang.reflect.Modifier; import java.util.Locale; public class EntityData implements Main.Extractor { @@ -20,7 +23,7 @@ public class EntityData implements Main.Extractor { var dataJson = new JsonObject(); var statusesJson = new JsonObject(); - for (var field : net.minecraft.entity.EntityStatuses.class.getDeclaredFields()) { + for (var field : EntityStatuses.class.getDeclaredFields()) { if (field.canAccess(null) && field.get(null) instanceof Byte code) { if (field.getName().equals("field_30030")) { statusesJson.addProperty("stop_attack", code); @@ -31,6 +34,15 @@ public class EntityData implements Main.Extractor { } dataJson.add("statuses", statusesJson); + var animationsJson = new JsonObject(); + for (var field : EntityAnimationS2CPacket.class.getDeclaredFields()) { + field.setAccessible(true); + if (Modifier.isStatic(field.getModifiers()) && field.canAccess(null) && field.get(null) instanceof Integer i) { + animationsJson.addProperty(field.getName().toLowerCase(Locale.ROOT), i); + } + } + dataJson.add("animations", animationsJson); + var villagerTypesJson = new JsonObject(); for (var type : Registry.VILLAGER_TYPE) { villagerTypesJson.addProperty(Registry.VILLAGER_TYPE.getId(type).getPath(), Registry.VILLAGER_TYPE.getRawId(type));