mirror of
https://github.com/GTNewHorizons/GTNHLib.git
synced 2026-11-28 07:35:51 +00:00
Move Axis into an inner class
This commit is contained in:
1 parent
62e0148f66
commit
a806f34766
3 files changed
+25
-30
No files matched your search
@@ -15,8 +15,9 @@ import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.json.ModelDisplay.Position;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.json.ModelElement.Axis;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.loading.ResourceLoc;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.Axis;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.DirectionUtil;
|
||||
import com.gtnewhorizon.gtnhlib.util.JsonUtil;
|
||||
|
||||
@@ -63,11 +64,10 @@ public class ModelDeserializer implements JsonDeserializer<JSONModel> {
|
||||
return new ModelDisplay(rotation, translation, scale);
|
||||
}
|
||||
|
||||
private Map<ModelDisplay.Position, ModelDisplay> loadDisplay(JsonObject in) {
|
||||
private Map<Position, ModelDisplay> loadDisplay(JsonObject in) {
|
||||
|
||||
// wow such long
|
||||
final Map<ModelDisplay.Position, ModelDisplay> ret = new Object2ObjectOpenHashMap<>(
|
||||
ModelDisplay.Position.values().length);
|
||||
final Map<Position, ModelDisplay> ret = new Object2ObjectOpenHashMap<>(Position.values().length);
|
||||
|
||||
if (in.has("display")) {
|
||||
|
||||
@@ -76,12 +76,12 @@ public class ModelDeserializer implements JsonDeserializer<JSONModel> {
|
||||
for (Map.Entry<String, JsonElement> j : display.entrySet()) {
|
||||
|
||||
final String name = j.getKey();
|
||||
final ModelDisplay.Position pos = ModelDisplay.Position.getByName(name);
|
||||
final Position pos = Position.getByName(name);
|
||||
ret.put(pos, loadADisplay(j.getValue().getAsJsonObject()));
|
||||
}
|
||||
}
|
||||
|
||||
for (ModelDisplay.Position p : ModelDisplay.Position.values()) {
|
||||
for (Position p : Position.values()) {
|
||||
ret.putIfAbsent(p, ModelDisplay.DEFAULT);
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ public class ModelDeserializer implements JsonDeserializer<JSONModel> {
|
||||
}
|
||||
|
||||
final boolean useAO = JsonUtil.loadBool(in, "ambientocclusion", true);
|
||||
final Map<ModelDisplay.Position, ModelDisplay> display = loadDisplay(in);
|
||||
final Map<Position, ModelDisplay> display = loadDisplay(in);
|
||||
final Map<String, String> textures = loadTextures(in);
|
||||
final List<ModelElement> elements = loadElements(in);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gtnewhorizon.gtnhlib.client.model.json;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -10,7 +9,7 @@ import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.Axis;
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
|
||||
@Desugar
|
||||
public record ModelElement(Vector3f from, Vector3f to, @Nullable Rotation rotation, boolean shade, List<Face> faces) {
|
||||
@@ -25,8 +24,7 @@ public record ModelElement(Vector3f from, Vector3f to, @Nullable Rotation rotati
|
||||
|
||||
@Desugar
|
||||
public record Face(ForgeDirection name, Vector4f uv, String texture, ForgeDirection cullFace, int rotation,
|
||||
int tintIndex) {
|
||||
}
|
||||
int tintIndex) {}
|
||||
|
||||
@Desugar
|
||||
public record Rotation(Vector3f origin, Axis axis, float angle, boolean rescale) {
|
||||
@@ -56,4 +54,20 @@ public record ModelElement(Vector3f from, Vector3f to, @Nullable Rotation rotati
|
||||
return ret.translateLocal(this.origin.x, this.origin.y, this.origin.z);
|
||||
}
|
||||
}
|
||||
|
||||
public enum Axis {
|
||||
|
||||
X,
|
||||
Y,
|
||||
Z;
|
||||
|
||||
public static Axis fromName(String dir) {
|
||||
return switch (dir) {
|
||||
case "y" -> Y;
|
||||
case "z" -> Z;
|
||||
case "x" -> X;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.gtnewhorizon.gtnhlib.client.renderer.quad;
|
||||
|
||||
public enum Axis {
|
||||
|
||||
X,
|
||||
Y,
|
||||
Z;
|
||||
|
||||
public static Axis fromName(String dir) {
|
||||
return switch (dir) {
|
||||
case "y" -> Y;
|
||||
case "z" -> Z;
|
||||
case "x" -> X;
|
||||
default -> null;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user