Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 00:00:41 +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:
Ursprung
36f540f401
Commit
d00886e12a
@ -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
|
||||
|
@ -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();
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren