3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 06:50:09 +01:00

1.18 does not have its own block palette

Our logic to finding block palettes was just borked.
Dieser Commit ist enthalten in:
Camotoy 2021-11-28 11:03:45 -05:00
Ursprung a305c22665
Commit 9ba1efaa30
4 geänderte Dateien mit 12 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -65,7 +65,7 @@ import java.util.Set;
/** /**
* Holds all the common registries in Geyser. * Holds all the common registries in Geyser.
*/ */
public class Registries { public final class Registries {
/** /**
* A registry holding a CompoundTag of the known entity identifiers. * A registry holding a CompoundTag of the known entity identifiers.
*/ */

Datei anzeigen

@ -55,17 +55,21 @@ public class VersionedRegistry<V> extends AbstractMappedRegistry<Integer, V, Int
* @return the closest value for the specified version * @return the closest value for the specified version
*/ */
public V forVersion(int version) { public V forVersion(int version) {
V value = null; Int2ObjectMap.Entry<V> current = null;
for (Int2ObjectMap.Entry<V> entry : this.mappings.int2ObjectEntrySet()) { for (Int2ObjectMap.Entry<V> entry : this.mappings.int2ObjectEntrySet()) {
if (version < entry.getIntKey()) { int currentVersion = entry.getIntKey();
if (version < currentVersion) {
continue; continue;
} }
if (version == entry.getIntKey()) { if (version == currentVersion) {
return entry.getValue(); return entry.getValue();
} }
value = entry.getValue(); if (current == null || current.getIntKey() < currentVersion) {
// This version is newer and should be prioritized
current = entry;
} }
return value; }
return current == null ? null : current.getValue();
} }
/** /**

Datei anzeigen

@ -30,7 +30,6 @@ import com.google.common.collect.ImmutableMap;
import com.nukkitx.nbt.*; import com.nukkitx.nbt.*;
import com.nukkitx.protocol.bedrock.v465.Bedrock_v465; import com.nukkitx.protocol.bedrock.v465.Bedrock_v465;
import com.nukkitx.protocol.bedrock.v471.Bedrock_v471; import com.nukkitx.protocol.bedrock.v471.Bedrock_v471;
import com.nukkitx.protocol.bedrock.v475.Bedrock_v475;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet; import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMap;
@ -39,12 +38,12 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIntPair; import it.unimi.dsi.fastutil.objects.ObjectIntPair;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.level.block.BlockStateValues; import org.geysermc.geyser.level.block.BlockStateValues;
import org.geysermc.geyser.level.physics.PistonBehavior;
import org.geysermc.geyser.registry.BlockRegistries; import org.geysermc.geyser.registry.BlockRegistries;
import org.geysermc.geyser.registry.type.BlockMapping; import org.geysermc.geyser.registry.type.BlockMapping;
import org.geysermc.geyser.registry.type.BlockMappings; import org.geysermc.geyser.registry.type.BlockMappings;
import org.geysermc.geyser.util.BlockUtils; import org.geysermc.geyser.util.BlockUtils;
import org.geysermc.geyser.util.FileUtils; import org.geysermc.geyser.util.FileUtils;
import org.geysermc.geyser.level.physics.PistonBehavior;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.InputStream; import java.io.InputStream;
@ -65,8 +64,7 @@ public class BlockRegistryPopulator {
static { static {
ImmutableMap.Builder<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> stateMapperBuilder = ImmutableMap.<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>>builder() ImmutableMap.Builder<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> stateMapperBuilder = ImmutableMap.<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>>builder()
.put(ObjectIntPair.of("1_17_30", Bedrock_v465.V465_CODEC.getProtocolVersion()), EMPTY_MAPPER) .put(ObjectIntPair.of("1_17_30", Bedrock_v465.V465_CODEC.getProtocolVersion()), EMPTY_MAPPER)
.put(ObjectIntPair.of("1_17_40", Bedrock_v471.V471_CODEC.getProtocolVersion()), EMPTY_MAPPER) .put(ObjectIntPair.of("1_17_40", Bedrock_v471.V471_CODEC.getProtocolVersion()), EMPTY_MAPPER);
.put(ObjectIntPair.of("1_18_0", Bedrock_v475.V475_CODEC.getProtocolVersion()), EMPTY_MAPPER);
BLOCK_MAPPERS = stateMapperBuilder.build(); BLOCK_MAPPERS = stateMapperBuilder.build();
} }