mirror of
https://github.com/GTNewHorizons/GTNHLib.git
synced 2026-11-28 07:35:51 +00:00
Remove copypastad code
This commit is contained in:
1 parent
ea5cc46af6
commit
7b159576d0
1 file changed
-39
@@ -3,12 +3,8 @@ package com.gtnewhorizon.gtnhlib.json;
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.UnbakedModel;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.JSONVariant;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectList;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MultipartState implements StateModelMap {
|
||||
private final ObjectList<Case> multipart;
|
||||
@@ -22,41 +18,6 @@ public class MultipartState implements StateModelMap {
|
||||
return null;
|
||||
}
|
||||
|
||||
static class StateMatch {
|
||||
private final boolean matchAll;
|
||||
private final Object2ObjectMap<String, String> states;
|
||||
|
||||
StateMatch(String s) {
|
||||
if (s.isEmpty()) {
|
||||
matchAll = true;
|
||||
states = null;
|
||||
return;
|
||||
}
|
||||
matchAll = false;
|
||||
states = new Object2ObjectOpenHashMap<>();
|
||||
|
||||
final var cases = s.split(",");
|
||||
for (var c : cases) {
|
||||
final int eidx = c.indexOf("=");
|
||||
if (eidx == -1) throw new RuntimeException("Unexpected blockstate case '" + c + "'!");
|
||||
|
||||
states.put(c.substring(0, eidx), c.substring(eidx));
|
||||
}
|
||||
}
|
||||
|
||||
boolean matches(Map<String, String> properties) {
|
||||
if (matchAll) return true;
|
||||
|
||||
final var iter = Object2ObjectMaps.fastIterator(states);
|
||||
while (iter.hasNext()) {
|
||||
final var e = iter.next();
|
||||
if (!Objects.equals(properties.get(e.getKey()), e.getValue())) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
record Case(ObjectList<JSONVariant> apply, Condition when) {
|
||||
|
||||
interface Condition {
|
||||
|
||||
Reference in new issue
Block a user