From 682f73bda86137a103003693093dd97334fb3e58 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 20 Jul 2022 23:35:19 -0700 Subject: [PATCH] Extract entity status codes --- .../dev/_00a/valence_extractor/Extractor.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/extractor/src/main/java/dev/_00a/valence_extractor/Extractor.java b/extractor/src/main/java/dev/_00a/valence_extractor/Extractor.java index b59e43d..a1e2d72 100644 --- a/extractor/src/main/java/dev/_00a/valence_extractor/Extractor.java +++ b/extractor/src/main/java/dev/_00a/valence_extractor/Extractor.java @@ -5,6 +5,7 @@ import net.fabricmc.api.ModInitializer; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityPose; +import net.minecraft.entity.EntityStatuses; import net.minecraft.entity.EntityType; import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.TrackedData; @@ -135,6 +136,7 @@ public class Extractor implements ModInitializer { extractBlocks(); extractEntities(); + extractEntityStatuses(); } catch (Throwable e) { LOGGER.error("Extraction failed", e); System.exit(1); @@ -269,6 +271,23 @@ public class Extractor implements ModInitializer { writeJsonFile("entities.json", entitiesJson); } + private void extractEntityStatuses() throws IllegalAccessException, IOException { + var statusesJson = new JsonObject(); + + for (var field : EntityStatuses.class.getDeclaredFields()) { + if (field.canAccess(null) && field.get(null) instanceof Byte code) { + if (field.getName().equals("field_30030")) { + // TODO: temp + statusesJson.addProperty("stop_attack", code); + } else { + statusesJson.addProperty(field.getName().toLowerCase(Locale.ROOT), code); + } + } + } + + writeJsonFile("entity_statuses.json", statusesJson); + } + private void writeJsonFile(String fileName, JsonElement element) throws IOException { var out = outputDirectory.resolve(fileName); var fileWriter = new FileWriter(out.toFile(), StandardCharsets.UTF_8);