3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 22:40:18 +01:00

Fix adding duplicate block states for custom blocks with 0 properties

Remove defaultBlockState CustomBlockState field from
GeyserCustomBlockData since it creates a circular reference
Dieser Commit ist enthalten in:
davchoo 2022-07-28 23:24:01 -04:00
Ursprung 36f540f401
Commit d00886e12a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A0168C8E45799B7D
2 geänderte Dateien mit 5 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -49,8 +49,7 @@ public class GeyserCustomBlockData implements CustomBlockData {
Map<String, CustomBlockProperty<?>> properties;
List<CustomBlockPermutation> permutations;
@EqualsAndHashCode.Exclude // Otherwise this will a StackOverflowError in hashCode/equals
CustomBlockState defaultBlockState;
Map<String, Object> defaultProperties;
private GeyserCustomBlockData(CustomBlockDataBuilder builder) {
this.name = builder.name;
@ -60,10 +59,9 @@ public class GeyserCustomBlockData implements CustomBlockData {
this.components = builder.components;
Object2ObjectMap<String, Object> defaultProperties;
if (!builder.properties.isEmpty()) {
this.properties = Object2ObjectMaps.unmodifiable(new Object2ObjectArrayMap<>(builder.properties));
defaultProperties = new Object2ObjectOpenHashMap<>(this.properties.size());
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.");
@ -73,10 +71,10 @@ public class GeyserCustomBlockData implements CustomBlockData {
}
defaultProperties.put(property.name(), property.values().get(0));
}
this.defaultBlockState = new GeyserCustomBlockState(this, Object2ObjectMaps.unmodifiable(defaultProperties));
this.defaultProperties = Object2ObjectMaps.unmodifiable(defaultProperties);
} else {
this.properties = Object2ObjectMaps.emptyMap();
this.defaultBlockState = new GeyserCustomBlockState(this, Object2ObjectMaps.emptyMap());
this.defaultProperties = Object2ObjectMaps.emptyMap();
}
if (!builder.permutations.isEmpty()) {
@ -113,7 +111,7 @@ public class GeyserCustomBlockData implements CustomBlockData {
@Override
public @NonNull CustomBlockState defaultBlockState() {
return defaultBlockState;
return new GeyserCustomBlockState(this, defaultProperties);
}
@Override

Datei anzeigen

@ -111,13 +111,6 @@ public class BlockRegistryPopulator {
}
private static void generateCustomBlockStates(CustomBlockData customBlock, List<NbtMap> blockStates, List<CustomBlockState> customExtBlockStates, int stateVersion) {
if (customBlock.properties().isEmpty()) {
blockStates.add(NbtMap.builder()
.putString("name", customBlock.identifier())
.putInt("version", stateVersion)
.putCompound("states", NbtMap.EMPTY)
.build());
}
int totalPermutations = 1;
for (CustomBlockProperty<?> property : customBlock.properties().values()) {
totalPermutations *= property.values().size();