mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-13 19:51:27 +01:00
Improve thread safety in Instance
This commit is contained in:
parent
7c5bb7126a
commit
d4f61eb152
@ -618,7 +618,9 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
public short getBlockStateId(int x, int y, int z) {
|
||||
final Chunk chunk = getChunkAt(x, z);
|
||||
Check.notNull(chunk, "The chunk at " + x + ":" + z + " is not loaded");
|
||||
return chunk.getBlockStateId(x, y, z);
|
||||
synchronized (chunk) {
|
||||
return chunk.getBlockStateId(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -655,7 +657,9 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
public CustomBlock getCustomBlock(int x, int y, int z) {
|
||||
final Chunk chunk = getChunkAt(x, z);
|
||||
Check.notNull(chunk, "The chunk at " + x + ":" + z + " is not loaded");
|
||||
return chunk.getCustomBlock(x, y, z);
|
||||
synchronized (chunk) {
|
||||
return chunk.getCustomBlock(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -705,7 +709,9 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
final Chunk chunk = getChunkAt(x, z);
|
||||
Check.notNull(chunk, "The chunk at " + x + ":" + z + " is not loaded");
|
||||
final int index = ChunkUtils.getBlockIndex(x, y, z);
|
||||
return chunk.getBlockData(index);
|
||||
synchronized (chunk) {
|
||||
return chunk.getBlockData(index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user