From 0f303c95f3281f8ef5151243a8f4acbd62e79fc4 Mon Sep 17 00:00:00 2001 From: trinsdar <30245301+Trinsdar@users.noreply.github.com> Date: Sat, 10 Aug 2024 22:08:56 -0400 Subject: [PATCH] started work on reactor model loader --- .../gregtech/client/ReactorModelLoader.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 common/src/main/java/muramasa/gregtech/client/ReactorModelLoader.java diff --git a/common/src/main/java/muramasa/gregtech/client/ReactorModelLoader.java b/common/src/main/java/muramasa/gregtech/client/ReactorModelLoader.java new file mode 100644 index 000000000..fb0883a7b --- /dev/null +++ b/common/src/main/java/muramasa/gregtech/client/ReactorModelLoader.java @@ -0,0 +1,45 @@ +package muramasa.gregtech.client; + +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonObject; +import muramasa.antimatter.AntimatterAPI; +import muramasa.antimatter.client.model.loader.AntimatterModelLoader; +import muramasa.antimatter.machine.MachineState; +import net.minecraft.client.renderer.block.model.BlockModel; +import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.resources.ResourceLocation; + +import java.util.HashMap; +import java.util.Map; + +public class ReactorModelLoader extends AntimatterModelLoader { + public ReactorModelLoader(ResourceLocation loc) { + super(loc); + } + + @Override + public ReactorModel readModel(JsonDeserializationContext context, JsonObject json) { + ResourceLocation particle = json.has("particle") ? new ResourceLocation(json.get("particle").getAsString()) : MissingTextureAtlasSprite.getLocation(); + Map m = new HashMap<>(); + AntimatterAPI.all(MachineState.class, t -> { + if (json.has(t.toString().toLowerCase())) { + JsonArray arr = json.get(t.toString().toLowerCase()).getAsJsonArray(); + UnbakedModel[] a = new UnbakedModel[6]; + for (int i = 0; i < 6; i++) { + a[i] = context.deserialize(arr.get(i), BlockModel.class); + } + m.put(t, a); + } + }); + UnbakedModel[] rods = new UnbakedModel[4]; + String[] array = new String[]{"north-west", "south-west", "north-east", "south-east"}; + //northwest is 0, southwest is 1, northeast is 2, southeast is 3 + for (int i = 0; i < 4; i++) { + //rods[i] = context.deserialize(J) + } + + return null; + } +}