Fixed #6039
This commit is contained in:
@@ -117,10 +117,30 @@ public class BlockRenderer{
|
||||
lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated
|
||||
}
|
||||
|
||||
invalidateTile(event.tile);
|
||||
recordIndex(event.tile);
|
||||
});
|
||||
}
|
||||
|
||||
public void invalidateTile(Tile tile){
|
||||
int avgx = (int)(camera.position.x / tilesize);
|
||||
int avgy = (int)(camera.position.y / tilesize);
|
||||
int rangex = (int)(camera.width / tilesize / 2) + 3;
|
||||
int rangey = (int)(camera.height / tilesize / 2) + 3;
|
||||
|
||||
if(Math.abs(avgx - tile.x) <= rangex && Math.abs(avgy - tile.y) <= rangey){
|
||||
lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFloorIndex(Tile tile){
|
||||
if(indexFloor(tile)) floorTree.remove(tile);
|
||||
}
|
||||
|
||||
public void addFloorIndex(Tile tile){
|
||||
if(indexFloor(tile)) floorTree.insert(tile);
|
||||
}
|
||||
|
||||
boolean indexBlock(Tile tile){
|
||||
var block = tile.block();
|
||||
return tile.isCenter() && block != Blocks.air && block.cacheLayer == CacheLayer.normal;
|
||||
|
||||
@@ -269,6 +269,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
this.floor = type;
|
||||
this.overlay = (Floor)Blocks.air;
|
||||
|
||||
if(!headless && !world.isGenerating()){
|
||||
renderer.blocks.removeFloorIndex(this);
|
||||
}
|
||||
|
||||
recache();
|
||||
if(build != null){
|
||||
build.onProximityUpdate();
|
||||
@@ -305,6 +309,8 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
if(!headless && !world.isGenerating()){
|
||||
renderer.blocks.floor.recacheTile(this);
|
||||
renderer.minimap.update(this);
|
||||
renderer.blocks.invalidateTile(this);
|
||||
renderer.blocks.addFloorIndex(this);
|
||||
//update neighbor tiles as well
|
||||
for(int i = 0; i < 8; i++){
|
||||
Tile other = world.tile(x + Geometry.d8[i].x, y + Geometry.d8[i].y);
|
||||
|
||||
Reference in New Issue
Block a user