3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 14:30:17 +01:00

Fix collide box and warn for >16 props

Dieser Commit ist enthalten in:
Joshua Castle 2023-01-05 21:54:08 -08:00
Ursprung a8e60b6fbc
Commit 880d8e528e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: F674F38216C35D5D
2 geänderte Dateien mit 12 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -26,10 +26,10 @@
package org.geysermc.geyser.level.block;
import it.unimi.dsi.fastutil.objects.*;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.Constants;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.block.custom.CustomBlockData;
import org.geysermc.geyser.api.block.custom.CustomBlockPermutation;
import org.geysermc.geyser.api.block.custom.CustomBlockState;
@ -63,12 +63,15 @@ public class GeyserCustomBlockData implements CustomBlockData {
this.properties = Object2ObjectMaps.unmodifiable(new Object2ObjectArrayMap<>(builder.properties));
Object2ObjectMap<String, Object> defaultProperties = new Object2ObjectOpenHashMap<>(this.properties.size());
for (CustomBlockProperty<?> property : properties.values()) {
if (property.values().isEmpty() || property.values().size() > 16) {
throw new IllegalStateException(property.name() + " must contain 1 to 16 values.");
if (property.values().size() > 16) {
GeyserImpl.getInstance().getLogger().warning(property.name() + " contains more than 16 values, but BDS specifies it should not. This may break in future versions.");
}
if (property.values().stream().distinct().count() != property.values().size()) {
throw new IllegalStateException(property.name() + " has duplicate values.");
}
if (property.values().isEmpty()) {
throw new IllegalStateException(property.name() + " contains no values.");
}
defaultProperties.put(property.name(), property.values().get(0));
}
this.defaultProperties = Object2ObjectMaps.unmodifiable(defaultProperties);

Datei anzeigen

@ -26,7 +26,6 @@
package org.geysermc.geyser.registry.mappings.versions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.common.base.CharMatcher;
@ -286,7 +285,10 @@ public class MappingsReader_v1 extends MappingsReader {
Set<String> booleanValuesSet = new HashSet<>();
Map<String, Map<String, Boolean>> stateKeyBools = new HashMap<>();
for (String state : usedStateKeys) {
if (!state.contains("[")) continue;
String[] pairs = splitStateString(state);
for (String pair : pairs) {
@ -411,9 +413,9 @@ public class MappingsReader_v1 extends MappingsReader {
float cornerY = clamp((float) boundingBox.getMiddleY() * 16 - offsetY, 0, 16);
float cornerZ = clamp((float) boundingBox.getMiddleZ() * 16 - 8 - offsetZ, -8, 8);
float sizeX = clamp((float) boundingBox.getSizeX() * 16, -8, 8);
float sizeX = clamp((float) boundingBox.getSizeX() * 16, 0, 16);
float sizeY = clamp((float) boundingBox.getSizeY() * 16, 0, 16);
float sizeZ = clamp((float) boundingBox.getSizeZ() * 16, -8, 8);
float sizeZ = clamp((float) boundingBox.getSizeZ() * 16, 0, 16);
BoxComponent boxComponent = new BoxComponent(cornerX, cornerY, cornerZ, sizeX, sizeY, sizeZ);
@ -479,7 +481,7 @@ public class MappingsReader_v1 extends MappingsReader {
}
public float clamp(float value, float min, float max) {
return Math.max(min, Math.min(value, max));
return Math.max(min, Math.min(max, value));
}
}