mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix collide box and warn for >16 props
This commit is contained in:
parent
a8e60b6fbc
commit
880d8e528e
2 changed files with 12 additions and 7 deletions
|
@ -26,10 +26,10 @@
|
||||||
package org.geysermc.geyser.level.block;
|
package org.geysermc.geyser.level.block;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.*;
|
import it.unimi.dsi.fastutil.objects.*;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.geysermc.geyser.Constants;
|
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.CustomBlockData;
|
||||||
import org.geysermc.geyser.api.block.custom.CustomBlockPermutation;
|
import org.geysermc.geyser.api.block.custom.CustomBlockPermutation;
|
||||||
import org.geysermc.geyser.api.block.custom.CustomBlockState;
|
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));
|
this.properties = Object2ObjectMaps.unmodifiable(new Object2ObjectArrayMap<>(builder.properties));
|
||||||
Object2ObjectMap<String, Object> defaultProperties = new Object2ObjectOpenHashMap<>(this.properties.size());
|
Object2ObjectMap<String, Object> defaultProperties = new Object2ObjectOpenHashMap<>(this.properties.size());
|
||||||
for (CustomBlockProperty<?> property : properties.values()) {
|
for (CustomBlockProperty<?> property : properties.values()) {
|
||||||
if (property.values().isEmpty() || property.values().size() > 16) {
|
if (property.values().size() > 16) {
|
||||||
throw new IllegalStateException(property.name() + " must contain 1 to 16 values.");
|
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()) {
|
if (property.values().stream().distinct().count() != property.values().size()) {
|
||||||
throw new IllegalStateException(property.name() + " has duplicate values.");
|
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));
|
defaultProperties.put(property.name(), property.values().get(0));
|
||||||
}
|
}
|
||||||
this.defaultProperties = Object2ObjectMaps.unmodifiable(defaultProperties);
|
this.defaultProperties = Object2ObjectMaps.unmodifiable(defaultProperties);
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
package org.geysermc.geyser.registry.mappings.versions;
|
package org.geysermc.geyser.registry.mappings.versions;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.google.common.base.CharMatcher;
|
import com.google.common.base.CharMatcher;
|
||||||
|
|
||||||
|
@ -286,7 +285,10 @@ public class MappingsReader_v1 extends MappingsReader {
|
||||||
Set<String> booleanValuesSet = new HashSet<>();
|
Set<String> booleanValuesSet = new HashSet<>();
|
||||||
Map<String, Map<String, Boolean>> stateKeyBools = new HashMap<>();
|
Map<String, Map<String, Boolean>> stateKeyBools = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
for (String state : usedStateKeys) {
|
for (String state : usedStateKeys) {
|
||||||
|
if (!state.contains("[")) continue;
|
||||||
|
|
||||||
String[] pairs = splitStateString(state);
|
String[] pairs = splitStateString(state);
|
||||||
|
|
||||||
for (String pair : pairs) {
|
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 cornerY = clamp((float) boundingBox.getMiddleY() * 16 - offsetY, 0, 16);
|
||||||
float cornerZ = clamp((float) boundingBox.getMiddleZ() * 16 - 8 - offsetZ, -8, 8);
|
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 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);
|
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) {
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue