From 0ca33477d8646ed2b223073295c309f1015516c1 Mon Sep 17 00:00:00 2001 From: FlippingPotatoes <75582921+FlippingPotatoes@users.noreply.github.com> Date: Thu, 13 Oct 2022 10:13:17 -0400 Subject: [PATCH] Expand getBlock functionality (#7702) * Update LExecutor.java * Update LUnitControl.java * Update LExecutor.java * Update LExecutor.java * Update LExecutor.java * Update LExecutor.java * Update bundle.properties * Update bundle.properties * Update bundle.properties * Update LExecutor.java --- core/assets/bundles/bundle.properties | 2 +- core/src/mindustry/logic/LExecutor.java | 17 +++++++++++++---- core/src/mindustry/logic/LUnitControl.java | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index da6d2fd02f..75791d8488 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -2321,7 +2321,7 @@ lenum.payenter = Enter/land on the payload block the unit is on. lenum.flag = Numeric unit flag. lenum.mine = Mine at a position. lenum.build = Build a structure. -lenum.getblock = Fetch a building and type at coordinates.\nUnit must be in range of position.\nSolid non-buildings will have the type [accent]@solid[]. +lenum.getblock = Fetch a building, floor and type at coordinates.\nUnit must be in range of position.\nSolid non-buildings will have the type [accent]@solid[]. lenum.within = Check if unit is near a position. lenum.boost = Start/stop boosting. diff --git a/core/src/mindustry/logic/LExecutor.java b/core/src/mindustry/logic/LExecutor.java index 87ec7ddda5..a4cbe5171f 100644 --- a/core/src/mindustry/logic/LExecutor.java +++ b/core/src/mindustry/logic/LExecutor.java @@ -510,12 +510,21 @@ public class LExecutor{ if(!unit.within(x1, y1, range)){ exec.setobj(p3, null); exec.setobj(p4, null); + exec.setobj(p5, null); }else{ Tile tile = world.tileWorld(x1, y1); - //any environmental solid block is returned as StoneWall, aka "@solid" - Block block = tile == null ? null : !tile.synthetic() ? (tile.solid() ? Blocks.stoneWall : Blocks.air) : tile.block(); - exec.setobj(p3, block); - exec.setobj(p4, tile != null && tile.build != null ? tile.build : null); + if(tile == null){ + exec.setobj(p3, null); + exec.setobj(p4, null); + exec.setobj(p5, null); + }else{ + //any environmental solid block is returned as StoneWall, aka "@solid" + Block block = !tile.synthetic() ? (tile.solid() ? Blocks.stoneWall : Blocks.air) : tile.block(); + exec.setobj(p3, block); + exec.setobj(p4, tile.build != null ? tile.build : null); + //Allows reading of ore tiles if they are present (overlay is not air) otherwise returns the floor + exec.setobj(p5, tile.overlay() == Blocks.air ? tile.floor() : tile.overlay()); + } } } case itemDrop -> { diff --git a/core/src/mindustry/logic/LUnitControl.java b/core/src/mindustry/logic/LUnitControl.java index fd7606e104..1ff56c2a44 100644 --- a/core/src/mindustry/logic/LUnitControl.java +++ b/core/src/mindustry/logic/LUnitControl.java @@ -16,7 +16,7 @@ public enum LUnitControl{ mine("x", "y"), flag("value"), build("x", "y", "block", "rotation", "config"), - getBlock("x", "y", "type", "building"), + getBlock("x", "y", "type", "building", "floor"), within("x", "y", "radius", "result"), unbind;