Skip to content

Commit 7d4aad1

Browse files
committed
Block - set type on correct world thread.
1 parent 7175586 commit 7d4aad1

File tree

1 file changed

+6
-1
lines changed
  • src/main/java/com/github/skriptdev/skript/api/hytale

1 file changed

+6
-1
lines changed

src/main/java/com/github/skriptdev/skript/api/hytale/Block.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ public Block(@NotNull Location location) {
4747
}
4848

4949
public void setType(@NotNull BlockType type, int settings) {
50-
this.world.setBlock(this.pos.getX(), this.pos.getY(), this.pos.getZ(), type.getId(), settings);
50+
Runnable r = () -> Block.this.world.setBlock(Block.this.pos.getX(), Block.this.pos.getY(), Block.this.pos.getZ(), type.getId(), settings);
51+
if (this.world.isInThread()) {
52+
r.run();
53+
} else {
54+
this.world.execute(r);
55+
}
5156
}
5257

5358
public byte getFluidLevel() {

0 commit comments

Comments
 (0)