3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-05 09:20:07 +02:00

Set int array directly for BlockMappings and change naming

Dieser Commit ist enthalten in:
Redned 2021-09-04 12:45:32 -05:00 committet von RednedEpic
Ursprung 64b0788012
Commit 9f77d47f14
2 geänderte Dateien mit 6 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -30,8 +30,6 @@ import com.google.common.collect.ImmutableMap;
import com.nukkitx.nbt.*; import com.nukkitx.nbt.*;
import com.nukkitx.protocol.bedrock.v440.Bedrock_v440; import com.nukkitx.protocol.bedrock.v440.Bedrock_v440;
import com.nukkitx.protocol.bedrock.v448.Bedrock_v448; import com.nukkitx.protocol.bedrock.v448.Bedrock_v448;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
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;
@ -139,7 +137,7 @@ public class BlockRegistryPopulator {
BiFunction<String, NbtMapBuilder, String> stateMapper = STATE_MAPPER.getOrDefault(palette.getKey(), (i, s) -> null); BiFunction<String, NbtMapBuilder, String> stateMapper = STATE_MAPPER.getOrDefault(palette.getKey(), (i, s) -> null);
IntList javaToBedrockBlockMap = new IntArrayList(); int[] javaToBedrockBlocks = new int[BLOCKS_JSON.size()];
Map<String, NbtMap> flowerPotBlocks = new Object2ObjectOpenHashMap<>(); Map<String, NbtMap> flowerPotBlocks = new Object2ObjectOpenHashMap<>();
Object2IntMap<NbtMap> itemFrames = new Object2IntOpenHashMap<>(); Object2IntMap<NbtMap> itemFrames = new Object2IntOpenHashMap<>();
@ -193,7 +191,7 @@ public class BlockRegistryPopulator {
javaIdentifierToBedrockTag.put(cleanJavaIdentifier.intern(), blocksTag.get(bedrockRuntimeId)); javaIdentifierToBedrockTag.put(cleanJavaIdentifier.intern(), blocksTag.get(bedrockRuntimeId));
} }
javaToBedrockBlockMap.add(bedrockRuntimeId); javaToBedrockBlocks[javaRuntimeId] = bedrockRuntimeId;
} }
if (commandBlockRuntimeId == -1) { if (commandBlockRuntimeId == -1) {
@ -222,7 +220,7 @@ public class BlockRegistryPopulator {
BlockRegistries.BLOCKS.register(PALETTE_VERSIONS.getInt(palette.getKey()), builder.blockStateVersion(stateVersion) BlockRegistries.BLOCKS.register(PALETTE_VERSIONS.getInt(palette.getKey()), builder.blockStateVersion(stateVersion)
.emptyChunkSection(new ChunkSection(new BlockStorage[]{new BlockStorage(airRuntimeId)})) .emptyChunkSection(new ChunkSection(new BlockStorage[]{new BlockStorage(airRuntimeId)}))
.javaToBedrockBlockMap(javaToBedrockBlockMap.toIntArray()) .javaToBedrockBlocks(javaToBedrockBlocks)
.javaIdentifierToBedrockTag(javaIdentifierToBedrockTag) .javaIdentifierToBedrockTag(javaIdentifierToBedrockTag)
.itemFrames(itemFrames) .itemFrames(itemFrames)
.flowerPotBlocks(flowerPotBlocks) .flowerPotBlocks(flowerPotBlocks)

Datei anzeigen

@ -45,7 +45,7 @@ public class BlockMappings {
ChunkSection emptyChunkSection; ChunkSection emptyChunkSection;
int[] javaToBedrockBlockMap; int[] javaToBedrockBlocks;
NbtList<NbtMap> bedrockBlockStates; NbtList<NbtMap> bedrockBlockStates;
@ -63,10 +63,10 @@ public class BlockMappings {
IntSet jigsawStateIds; IntSet jigsawStateIds;
public int getBedrockBlockId(int state) { public int getBedrockBlockId(int state) {
if (state >= this.javaToBedrockBlockMap.length) { if (state >= this.javaToBedrockBlocks.length) {
return bedrockAirId; return bedrockAirId;
} }
return this.javaToBedrockBlockMap[state]; return this.javaToBedrockBlocks[state];
} }
public int getItemFrame(NbtMap tag) { public int getItemFrame(NbtMap tag) {