fix small possiblity of a race condition (so small is stupid yet it happened)

This commit is contained in:
mcrcortex
2025-12-17 23:05:31 +10:00
parent 0428153cf5
commit ef1a296998

View File

@@ -185,8 +185,8 @@ public class Mapper {
} }
entry = new StateEntry(this.blockId2stateEntry.size(), state); entry = new StateEntry(this.blockId2stateEntry.size(), state);
this.block2stateEntry.put(state, entry);
this.blockId2stateEntry.add(entry); this.blockId2stateEntry.add(entry);
this.block2stateEntry.put(state, entry);
this.blockLock.unlock(); this.blockLock.unlock();
byte[] serialized = entry.serialize(); byte[] serialized = entry.serialize();
@@ -208,8 +208,8 @@ public class Mapper {
return entry; return entry;
} }
entry = new BiomeEntry(this.biomeId2biomeEntry.size(), biome); entry = new BiomeEntry(this.biomeId2biomeEntry.size(), biome);
this.biome2biomeEntry.put(biome, entry);
this.biomeId2biomeEntry.add(entry); this.biomeId2biomeEntry.add(entry);
this.biome2biomeEntry.put(biome, entry);
this.biomeLock.unlock(); this.biomeLock.unlock();
byte[] serialized = entry.serialize(); byte[] serialized = entry.serialize();
@@ -234,7 +234,6 @@ public class Mapper {
return this.blockId2stateEntry.get(blockId).state; return this.blockId2stateEntry.get(blockId).state;
} }
//TODO: replace lambda with a class cached lambda ref (cause doing this:: still does a lambda allocation)
public int getIdForBlockState(BlockState state) { public int getIdForBlockState(BlockState state) {
if (state.isAir()) { if (state.isAir()) {
return 0; return 0;