Skip to content

Commit

Permalink
optimized a brush
Browse files Browse the repository at this point in the history
  • Loading branch information
xzxADIxzx committed Mar 23, 2023
1 parent 101b1fa commit 4e1001e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mod.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ A mod that increases the schematic size limit to 512 blocks! Adds admins, render
",
author: "[#0096FF]xzxADIxzx",
minGameVersion: 142,
version: 2.7.48,
version: 2.7.49,
hidden: true,
main: scheme.Main
6 changes: 4 additions & 2 deletions src/java/scheme/tools/admins/Internal.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ private static void edit(Block floor, Block block, Block overlay, int x, int y)
Tile tile = world.tile(x, y);
if (tile == null) return;

tile.setFloorNet(floor == null ? tile.floor() : floor, overlay == null ? tile.overlay() : overlay);
if (block != null) tile.setNet(block);
if ((floor != null && tile.floor() != floor) || (overlay != null && tile.overlay() != overlay))
tile.setFloorNet(floor == null ? tile.floor() : floor, overlay == null ? tile.overlay() : overlay);

if (block != null && tile.block() != block) tile.setNet(block);
}
}
11 changes: 7 additions & 4 deletions src/java/scheme/tools/admins/SlashJs.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ public void fill(int sx, int sy, int ex, int ey) {
if (unusable()) return;
tile.select((floor, block, overlay) -> {
edit(floor, block, overlay);
send("for (var x = @; x <= @; x++) for (var y = @; y <= @; y++) todo(Vars.world.tiles.getc(x, y))", sx, ex, sy, ey);
send("for (var x = @; x <= @; x++) for (var y = @; y <= @; y++) todo(Vars.world.tile(x, y))", sx, ex, sy, ey);
});
}

public void brush(int x, int y, int radius) {
if (unusable()) return;
tile.select((floor, block, overlay) -> {
edit(floor, block, overlay);
send("Geometry.circle(@, @, @, (cx, cy) => todo(Vars.world.tiles.getc(cx, cy)))", x, y, radius);
send("Geometry.circle(@, @, @, (cx, cy) => todo(Vars.world.tile(cx, cy)))", x, y, radius);
});
}

Expand Down Expand Up @@ -151,7 +151,10 @@ private static String getBlock(Block block) {
}

private static void edit(Block floor, Block block, Block overlay) {
send("var floor = @; var block = @; var over = @", getBlock(floor), getBlock(block), getBlock(overlay));
send("var todo = tile => { tile.setFloorNet(floor==null?tile.floor():floor,over==null?tile.overlay():over); if (block!=null) tile.setNet(block) }");
boolean fo = floor != null || overlay != null;

send("f = @; b = @; o = @", getBlock(floor), getBlock(block), getBlock(overlay));
send("todo = tile => { if(tile!=null){" + (fo ? "sflr(tile);" : "") + (block != null ? "if(tile.block()!=b)tile.setNet(b)" : "") + "} }");
if (fo) send("sflr = tile => { if(tile.floor()!=f||tile.overlay()!=o)tile.setFloorNet(f==null?tile.floor():f,o==null?tile.overlay():o) }");
}
}

0 comments on commit 4e1001e

Please sign in to comment.