Merge branch 'development' into render

This commit is contained in:
Bixilon 2020-11-10 16:04:48 +01:00
commit a3ccc9579a
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
6 changed files with 25 additions and 25 deletions

View File

@ -61,10 +61,10 @@ public class Block {
for (Map.Entry<String, JsonElement> property : properties.entrySet()) { for (Map.Entry<String, JsonElement> property : properties.entrySet()) {
String key = property.getKey(); String key = property.getKey();
String value = property.getValue().getAsString(); String value = property.getValue().getAsString();
if (BlockProperties.propertiesMapping.containsKey(key)) { if (BlockProperties.PROPERTIES_MAPPING.containsKey(key)) {
this.properties.add(BlockProperties.propertiesMapping.get(key).get(value)); this.properties.add(BlockProperties.PROPERTIES_MAPPING.get(key).get(value));
} else if (BlockRotations.rotationMapping.containsKey(key)) { } else if (BlockRotations.ROTATION_MAPPING.containsKey(key)) {
rotation = BlockRotations.rotationMapping.get(value); rotation = BlockRotations.ROTATION_MAPPING.get(value);
} }
} }
this.rotation = rotation; this.rotation = rotation;

View File

@ -419,15 +419,15 @@ public enum BlockProperties {
BUTTON_FACE_WALL, BUTTON_FACE_WALL,
BUTTON_FACE_CEILING; BUTTON_FACE_CEILING;
public static final HashMap<String, HashMap<String, BlockProperties>> propertiesMapping = new HashMap<>(); public static final HashMap<String, HashMap<String, BlockProperties>> PROPERTIES_MAPPING = new HashMap<>();
static { static {
// add all to hashmap // add all to hashmap
for (BlockProperties property : values()) { for (BlockProperties property : values()) {
if (!propertiesMapping.containsKey(property.getGroup())) { if (!PROPERTIES_MAPPING.containsKey(property.getGroup())) {
propertiesMapping.put(property.getGroup(), new HashMap<>()); PROPERTIES_MAPPING.put(property.getGroup(), new HashMap<>());
} }
propertiesMapping.get(property.getGroup()).put(property.getValue(), property); PROPERTIES_MAPPING.get(property.getGroup()).put(property.getValue(), property);
} }
} }

View File

@ -67,13 +67,13 @@ public enum BlockRotations {
AXIS_Y("y"), AXIS_Y("y"),
AXIS_Z("z"); AXIS_Z("z");
public static final HashMap<String, BlockRotations> rotationMapping = new HashMap<>(); public static final HashMap<String, BlockRotations> ROTATION_MAPPING = new HashMap<>();
static { static {
// add all to hashmap // add all to hashmap
for (BlockRotations rotation : values()) { for (BlockRotations rotation : values()) {
rotationMapping.put(rotation.name().toLowerCase(), rotation); ROTATION_MAPPING.put(rotation.name().toLowerCase(), rotation);
rotation.getAliases().forEach((alias) -> rotationMapping.put(alias, rotation)); rotation.getAliases().forEach((alias) -> ROTATION_MAPPING.put(alias, rotation));
} }
} }

View File

@ -35,28 +35,28 @@ public class Blocks {
JsonObject propertiesJSON = statesJSON.getAsJsonObject("properties"); JsonObject propertiesJSON = statesJSON.getAsJsonObject("properties");
BlockRotations rotation = BlockRotations.NONE; BlockRotations rotation = BlockRotations.NONE;
if (propertiesJSON.has("facing")) { if (propertiesJSON.has("facing")) {
rotation = BlockRotations.rotationMapping.get(propertiesJSON.get("facing").getAsString()); rotation = BlockRotations.ROTATION_MAPPING.get(propertiesJSON.get("facing").getAsString());
propertiesJSON.remove("facing"); propertiesJSON.remove("facing");
} else if (propertiesJSON.has("rotation")) { } else if (propertiesJSON.has("rotation")) {
rotation = BlockRotations.rotationMapping.get(propertiesJSON.get("rotation").getAsString()); rotation = BlockRotations.ROTATION_MAPPING.get(propertiesJSON.get("rotation").getAsString());
propertiesJSON.remove("rotation"); propertiesJSON.remove("rotation");
} else if (propertiesJSON.has("orientation")) { } else if (propertiesJSON.has("orientation")) {
rotation = BlockRotations.rotationMapping.get(propertiesJSON.get("orientation").getAsString()); rotation = BlockRotations.ROTATION_MAPPING.get(propertiesJSON.get("orientation").getAsString());
propertiesJSON.remove("orientation"); propertiesJSON.remove("orientation");
} else if (propertiesJSON.has("axis")) { } else if (propertiesJSON.has("axis")) {
rotation = BlockRotations.rotationMapping.get(propertiesJSON.get("axis").getAsString()); rotation = BlockRotations.ROTATION_MAPPING.get(propertiesJSON.get("axis").getAsString());
propertiesJSON.remove("axis"); propertiesJSON.remove("axis");
} }
HashSet<BlockProperties> properties = new HashSet<>(); HashSet<BlockProperties> properties = new HashSet<>();
for (String propertyName : propertiesJSON.keySet()) { for (String propertyName : propertiesJSON.keySet()) {
if (BlockProperties.propertiesMapping.get(propertyName) == null) { if (BlockProperties.PROPERTIES_MAPPING.get(propertyName) == null) {
throw new RuntimeException(String.format("Unknown block property: %s (identifier=%s)", propertyName, identifierName)); throw new RuntimeException(String.format("Unknown block property: %s (identifier=%s)", propertyName, identifierName));
} }
if (BlockProperties.propertiesMapping.get(propertyName).get(propertiesJSON.get(propertyName).getAsString()) == null) { if (BlockProperties.PROPERTIES_MAPPING.get(propertyName).get(propertiesJSON.get(propertyName).getAsString()) == null) {
throw new RuntimeException(String.format("Unknown block property: %s -> %s (identifier=%s)", propertyName, propertiesJSON.get(propertyName).getAsString(), identifierName)); throw new RuntimeException(String.format("Unknown block property: %s -> %s (identifier=%s)", propertyName, propertiesJSON.get(propertyName).getAsString(), identifierName));
} }
properties.add(BlockProperties.propertiesMapping.get(propertyName).get(propertiesJSON.get(propertyName).getAsString())); properties.add(BlockProperties.PROPERTIES_MAPPING.get(propertyName).get(propertiesJSON.get(propertyName).getAsString()));
} }
block = new Block(mod, identifierName, properties, rotation); block = new Block(mod, identifierName, properties, rotation);

View File

@ -38,11 +38,11 @@ public class BlockCondition {
rotation = BlockRotations.NONE; rotation = BlockRotations.NONE;
for (Map.Entry<String, JsonElement> entry : json.entrySet()) { for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
String value = entry.getValue().getAsString(); String value = entry.getValue().getAsString();
if (BlockProperties.propertiesMapping.containsKey(entry.getKey())) { if (BlockProperties.PROPERTIES_MAPPING.containsKey(entry.getKey())) {
properties.add(BlockProperties.propertiesMapping.get(entry.getKey()).get(value)); properties.add(BlockProperties.PROPERTIES_MAPPING.get(entry.getKey()).get(value));
continue; continue;
} }
rotation = BlockRotations.rotationMapping.get(value); rotation = BlockRotations.ROTATION_MAPPING.get(value);
} }
} }

View File

@ -43,10 +43,10 @@ public class BlockModel implements BlockModelInterface {
HashSet<SubBlock> model = blockModels.get(state.get("model").getAsString()).stream().map(SubBlock::new).collect(Collectors.toCollection(HashSet::new)); HashSet<SubBlock> model = blockModels.get(state.get("model").getAsString()).stream().map(SubBlock::new).collect(Collectors.toCollection(HashSet::new));
HashSet<String> properties = new HashSet<>(); HashSet<String> properties = new HashSet<>();
for (Map.Entry<String, JsonElement> property : state.getAsJsonObject("properties").entrySet()) { for (Map.Entry<String, JsonElement> property : state.getAsJsonObject("properties").entrySet()) {
if (BlockProperties.propertiesMapping.containsKey(property.getKey())) { if (BlockProperties.PROPERTIES_MAPPING.containsKey(property.getKey())) {
properties.add(BlockProperties.propertiesMapping.get(property.getKey()).get(property.getValue().getAsString()).name()); properties.add(BlockProperties.PROPERTIES_MAPPING.get(property.getKey()).get(property.getValue().getAsString()).name());
} else if (BlockRotations.rotationMapping.containsKey(property.getValue().getAsString())) { } else if (BlockRotations.ROTATION_MAPPING.containsKey(property.getValue().getAsString())) {
properties.add(BlockRotations.rotationMapping.get(property.getValue().getAsString()).name()); properties.add(BlockRotations.ROTATION_MAPPING.get(property.getValue().getAsString()).name());
} }
} }
for (Axis axis : Axis.values()) { for (Axis axis : Axis.values()) {