Fixing bugs introduced in previous commit

- Fixed AbstractContextRO.isSubcontexting()
- Fixed push(...) overrides in FilterServerContext
- Fixed DefaultChunkLogic.tmp_generateTickLists()
- Debug screen now also lists visible and loaded chunks
- AbstractContextRO.Frame now has a toString()
This commit is contained in:
OLEGSHA 2021-08-11 13:02:18 +03:00
parent 0a45613e45
commit a03c783fc9
Signed by: OLEGSHA
GPG Key ID: E57A4B08D64AFF7A
8 changed files with 71 additions and 35 deletions

View File

@ -40,6 +40,12 @@ public abstract class AbstractContextRO<
public RelFace face;
public int layer;
@Override
public String toString() {
return "Frame [x=" + location.x + ", y=" + location.y + ", z=" + location.z + ", face=" + face + ", layer="
+ layer + "]";
}
}
protected Frame frame = null;
@ -89,7 +95,7 @@ public abstract class AbstractContextRO<
}
public boolean isSubcontexting() {
return frameStack.isEmpty();
return !frameStack.isEmpty();
}
}

View File

@ -109,7 +109,7 @@ public class Server {
*/
public ServerWorldContext createContext() {
return new ReportingServerContext(DefaultServerContext.empty().inRealWorldOf(this).build()).withListener(worldAccessor);
return new ReportingServerContext(DefaultServerContext.empty().inRealWorldOf(this).build()).withListener(worldAccessor).setPassToParent(false);
}

View File

@ -235,8 +235,10 @@ public class DefaultChunkLogic implements ChunkLogic {
BlockLogic block = blockContext.logic().getBlock();
Coordinates.convertInWorldToInChunk(location, blockInChunk);
if (!(block instanceof TickableBlock))
if (!(block instanceof TickableBlock)) {
blockContext.pop();
return;
}
if (((TickableBlock) block).getTickingPolicy(blockContext) == TickingPolicy.REGULAR) {
tickingBlocks.add(blockInChunk);
@ -248,11 +250,12 @@ public class DefaultChunkLogic implements ChunkLogic {
for (int i = 0; i < stack.size(); ++i) {
ServerTileContextRO tileContext = blockContext.push(face, i);
TileLogic tile = stack.get(i);
if (!(tile instanceof TickableTile))
return;
if (!(tile instanceof TickableTile)) {
tileContext.pop();
continue;
}
if (((TickableTile) tile).getTickingPolicy(tileContext) == TickingPolicy.REGULAR) {
tickingTiles.add(stack.getData().getReference(i));

View File

@ -109,7 +109,7 @@ class DefaultServerContextImpl extends DefaultServerContext
*/
public boolean requireContextRole(Role role) throws IllegalStateException {
boolean ok = !isBuilder && getRole().compareTo(role) <= 0;
boolean ok = !isBuilder && getRole().compareTo(role) >= 0;
if (!ok) {
complainAboutIllegalState(role, false);
}

View File

@ -179,17 +179,20 @@ public abstract class FilterServerContext implements ServerTileContext {
@Override
public ServerBlockContext push(Vec3i location) {
return parent.push(location);
parent.push(location);
return this;
}
@Override
public ServerTileStackContext push(Vec3i location, RelFace face) {
return parent.push(location, face);
parent.push(location, face);
return this;
}
@Override
public ServerTileContext push(Vec3i location, RelFace face, int layer) {
return parent.push(location, face, layer);
parent.push(location, face, layer);
return this;
}
@Override

View File

@ -35,6 +35,7 @@ import ru.windcorp.progressia.client.graphics.gui.layout.LayoutVertical;
import ru.windcorp.progressia.client.localization.Localizer;
import ru.windcorp.progressia.client.localization.MutableString;
import ru.windcorp.progressia.client.localization.MutableStringLocalized;
import ru.windcorp.progressia.client.world.WorldRender;
import ru.windcorp.progressia.common.Units;
import ru.windcorp.progressia.common.util.dynstr.DynamicStrings;
import ru.windcorp.progressia.server.Server;
@ -131,11 +132,34 @@ public class LayerTestGUI extends GUILayer {
group.addChild(
new DynamicLabel(
"ChunkUpdatesDisplay",
"ChunkStatsDisplay",
font,
DynamicStrings.builder()
.addDyn(new MutableStringLocalized("LayerTestGUI.ChunkUpdatesDisplay"))
.addDyn(ClientState.getInstance().getWorld()::getPendingChunkUpdates)
.addDyn(new MutableStringLocalized("LayerTestGUI.ChunkStatsDisplay"))
.addDyn(() -> {
if (ClientState.getInstance() == null) {
return -1;
} else {
WorldRender world = ClientState.getInstance().getWorld();
return world.getChunks().size() - world.getPendingChunkUpdates();
}
}, 4)
.add('/')
.addDyn(() -> {
if (ClientState.getInstance() == null) {
return -1;
} else {
return ClientState.getInstance().getWorld().getPendingChunkUpdates();
}
}, 4)
.add('/')
.addDyn(() -> {
if (ServerState.getInstance() == null) {
return -1;
} else {
return ServerState.getInstance().getWorld().getChunks().size();
}
}, 4)
.buildSupplier(),
128
)

View File

@ -11,7 +11,7 @@ LayerTestGUI.LanguageDisplay = Language: %5s (L)
LayerTestGUI.FPSDisplay = FPS:
LayerTestGUI.TPSDisplay = TPS:
LayerTestGUI.TPSDisplay.NA = TPS: n/a
LayerTestGUI.ChunkUpdatesDisplay = Pending updates:
LayerTestGUI.ChunkStatsDisplay = Chunks vis/pnd/load:
LayerTestGUI.PosDisplay = Pos:
LayerTestGUI.PosDisplay.NA.Client = Pos: client n/a
LayerTestGUI.PosDisplay.NA.Entity = Pos: entity n/a

View File

@ -11,7 +11,7 @@ LayerTestGUI.LanguageDisplay = Язык: %5s (L)
LayerTestGUI.FPSDisplay = FPS:
LayerTestGUI.TPSDisplay = TPS:
LayerTestGUI.TPSDisplay.NA = TPS: н/д
LayerTestGUI.ChunkUpdatesDisplay = Обновления в очереди:
LayerTestGUI.ChunkStatsDisplay = Чанки вид/очр/загр:
LayerTestGUI.PosDisplay = Поз:
LayerTestGUI.PosDisplay.NA.Client = Поз: клиент н/д
LayerTestGUI.PosDisplay.NA.Entity = Поз: сущность н/д