Correct team display on maps
This commit is contained in:
@@ -79,12 +79,8 @@ public class MapIO{
|
||||
CachedTile tile = new CachedTile(){
|
||||
@Override
|
||||
public void setBlock(Block type){
|
||||
//previous state.
|
||||
if(build != null && build.block instanceof CoreBlock){
|
||||
map.teams.add(build.team.id);
|
||||
}
|
||||
|
||||
super.setBlock(type);
|
||||
|
||||
int c = colorFor(block(), Blocks.air, Blocks.air, team());
|
||||
if(c != black){
|
||||
walls.draw(x, floors.getHeight() - 1 - y, c);
|
||||
@@ -104,6 +100,27 @@ public class MapIO{
|
||||
world.setGenerating(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReadBuilding(){
|
||||
//read team colors
|
||||
if(tile.build != null){
|
||||
int c = tile.build.team.color.rgba8888();
|
||||
int size = tile.block().size;
|
||||
int offsetx = -(size - 1) / 2;
|
||||
int offsety = -(size - 1) / 2;
|
||||
for(int dx = 0; dx < size; dx++){
|
||||
for(int dy = 0; dy < size; dy++){
|
||||
int drawx = tile.x + dx + offsetx, drawy = tile.y + dy + offsety;
|
||||
walls.draw(drawx, floors.getHeight() - 1 - drawy, c);
|
||||
}
|
||||
}
|
||||
|
||||
if(tile.build.block instanceof CoreBlock){
|
||||
map.teams.add(tile.build.team.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tile tile(int index){
|
||||
tile.x = (short)(index % map.width);
|
||||
|
||||
@@ -263,6 +263,8 @@ public abstract class SaveVersion extends SaveFileReader{
|
||||
//skip the entity region, as the entity and its IO code are now gone
|
||||
skipChunk(stream, true);
|
||||
}
|
||||
|
||||
context.onReadBuilding();
|
||||
}
|
||||
}else if(hadData){
|
||||
tile.setBlock(block);
|
||||
|
||||
@@ -85,6 +85,8 @@ public abstract class LegacySaveVersion extends SaveVersion{
|
||||
}catch(Throwable e){
|
||||
throw new IOException("Failed to read tile entity of block: " + block, e);
|
||||
}
|
||||
|
||||
context.onReadBuilding();
|
||||
}else{
|
||||
int consecutives = stream.readUnsignedByte();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user