mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 12:07:42 +01:00
Instance#refreshBlockId optimization
This commit is contained in:
parent
93f1b240da
commit
2473a1bbe6
@ -182,6 +182,15 @@ public class Chunk implements Viewable {
|
|||||||
this.customBlocksId[blockIndex] = customId;
|
this.customBlocksId[blockIndex] = customId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void refreshBlockId(int x, int y, int z, short blockId) {
|
||||||
|
int blockIndex = getBlockIndex(x, y, z);
|
||||||
|
if (blockIndex < 0 || blockIndex >= blocksId.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.blocksId[blockIndex] = blockId;
|
||||||
|
}
|
||||||
|
|
||||||
protected void refreshBlockValue(int x, int y, int z, short blockId) {
|
protected void refreshBlockValue(int x, int y, int z, short blockId) {
|
||||||
CustomBlock customBlock = getCustomBlock(x, y, z);
|
CustomBlock customBlock = getCustomBlock(x, y, z);
|
||||||
short customBlockId = customBlock == null ? 0 : customBlock.getCustomBlockId();
|
short customBlockId = customBlock == null ? 0 : customBlock.getCustomBlockId();
|
||||||
|
@ -97,7 +97,7 @@ public class InstanceContainer extends Instance {
|
|||||||
public void refreshBlockId(BlockPosition blockPosition, short blockId) {
|
public void refreshBlockId(BlockPosition blockPosition, short blockId) {
|
||||||
Chunk chunk = getChunkAt(blockPosition.getX(), blockPosition.getZ());
|
Chunk chunk = getChunkAt(blockPosition.getX(), blockPosition.getZ());
|
||||||
synchronized (chunk) {
|
synchronized (chunk) {
|
||||||
chunk.refreshBlockValue(blockPosition.getX(), blockPosition.getY(),
|
chunk.refreshBlockId(blockPosition.getX(), blockPosition.getY(),
|
||||||
blockPosition.getZ(), blockId);
|
blockPosition.getZ(), blockId);
|
||||||
|
|
||||||
sendBlockChange(chunk, blockPosition, blockId);
|
sendBlockChange(chunk, blockPosition, blockId);
|
||||||
|
Loading…
Reference in New Issue
Block a user