Open satoshinm opened 7 years ago
--- a/src/main/java/io/github/satoshinm/WebSandboxMC/bridge/BlockBridge.java
+++ b/src/main/java/io/github/satoshinm/WebSandboxMC/bridge/BlockBridge.java
@@ -201,11 +201,9 @@ public class BlockBridge {
if (!withinSandboxRange(location)) {
webSocketServerThread.log(Level.FINEST, "client tried to modify outside of sandbox! "+location); // not severe, since not prevented client-side
webSocketServerThread.sendLine(ctx.channel(), "T,You cannot build at ("+x+","+y+","+z+")");
- // TODO: Clear the block, fix this (set to air)
- /*
- webSocketServerThread.sendLine(ctx.channel(), "B,0,0,"+ox+","+oy+","+oz+",0");
+ // Clear the block
+ webSocketServerThread.sendLine(ctx.channel(), "B,0,0,"+x+","+y+","+z+",0");
webSocketServerThread.sendLine(ctx.channel(), "R,0,0");
- */
return;
}
has no apparent affect, of course, because the blocks are probably not in the sandbox (chunk 0,0).
Would need to calculate the correct chunk, and update and refresh it. Something like this (but not quite right):
diff --git a/src/main/java/io/github/satoshinm/WebSandboxMC/bridge/BlockBridge.java b/src/main/java/io/github/satoshinm/WebSandboxMC/bridge/BlockBridge.java
index 27d84dd..b24e6f7 100644
--- a/src/main/java/io/github/satoshinm/WebSandboxMC/bridge/BlockBridge.java
+++ b/src/main/java/io/github/satoshinm/WebSandboxMC/bridge/BlockBridge.java
@@ -201,11 +201,13 @@ public class BlockBridge {
if (!withinSandboxRange(location)) {
webSocketServerThread.log(Level.FINEST, "client tried to modify outside of sandbox! "+location); // not severe, since not prevented client-side
webSocketServerThread.sendLine(ctx.channel(), "T,You cannot build at ("+x+","+y+","+z+")");
- // TODO: Clear the block, fix this (set to air)
- /*
- webSocketServerThread.sendLine(ctx.channel(), "B,0,0,"+ox+","+oy+","+oz+",0");
- webSocketServerThread.sendLine(ctx.channel(), "R,0,0");
- */
+ // Clear the block
+ int cx = x / 16;
+ int cz = z / 16;
+ x %= 16;
+ z %= 16;
+ webSocketServerThread.sendLine(ctx.channel(), "B,"+cx+","+cz+","+x+","+y+","+z+",0");
+ webSocketServerThread.sendLine(ctx.channel(), "R,"+cx+","+cz);
return;
}
This could revert place, but what about break? Server doesn't know the original type since it is all on the client. A client-side revert command?
Also consider: permissions plugins denying the block break
This may be less necessary if https://github.com/satoshinm/WebSandboxMC/issues/63 Teleport web clients who exit the sandbox back to within it -and/or- https://github.com/satoshinm/WebSandboxMC/issues/58 Remove generation of local terrain, only show web sandbox. If there is no local terrain, then would only need to revert out-of-bounds block placements to air.
Unbreakable block types within the sandbox area revert (https://github.com/satoshinm/WebSandboxMC/issues/46), but not elsewhere