Synchronized tile modification with updating

This commit is contained in:
Anuken
2018-02-17 16:04:09 -05:00
parent 30d0d7715a
commit a79dfe29ef
4 changed files with 25 additions and 22 deletions
@@ -106,17 +106,19 @@ public class TileEntity extends Entity{
@Override
public void update(){
if(health != 0 && health < tile.block().health && !(tile.block() instanceof Wall) &&
Mathf.chance(0.009f*Timers.delta()*(1f-health/tile.block().health))){
synchronized (tile) {
if (health != 0 && health < tile.block().health && !(tile.block() instanceof Wall) &&
Mathf.chance(0.009f * Timers.delta() * (1f - health / tile.block().health))) {
Effects.effect(Fx.smoke, x+Mathf.range(4), y+Mathf.range(4));
}
Effects.effect(Fx.smoke, x + Mathf.range(4), y + Mathf.range(4));
}
if(health <= 0){
onDeath();
if (health <= 0) {
onDeath();
}
tile.block().update(tile);
}
tile.block().update(tile);
}
public int totalItems(){