From 15175a6f8a47f2e904f333104dfc447c80b41959 Mon Sep 17 00:00:00 2001 From: buthed010203 Date: Tue, 14 Nov 2023 16:33:55 -0500 Subject: [PATCH] Fix block placement warnings --- .../mindustry/world/blocks/ConstructBlock.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/core/src/mindustry/world/blocks/ConstructBlock.java b/core/src/mindustry/world/blocks/ConstructBlock.java index dffa545ad0..2841f1ae7f 100644 --- a/core/src/mindustry/world/blocks/ConstructBlock.java +++ b/core/src/mindustry/world/blocks/ConstructBlock.java @@ -527,23 +527,17 @@ public void read(Reads read, byte revision){ buildCost = current.buildCost * state.rules.buildCostMultiplier; } - public boolean shouldDisplayWarning(){ - return wasConstructing && closestCore() != null && lastBuilder != null - && player != null && team == player.team() && progress != lastProgress - && lastBuilder != player.unit(); - } - /** Returns the smallest distance to the core and/or its connected vaults.*/ public int distanceToGreaterCore(){ - int lowestDistance = Integer.MAX_VALUE; - //Loop through the core and all connected storage - // BALA WARNING: I dont know whether replacing .and with .add was the correct move but I hope it is - for(Building building : closestCore().proximity.copy().add(closestCore())) { + float lowestDistance = Integer.MAX_VALUE; + for(Building building : closestCore().proximity) { if (building instanceof StorageBlock.StorageBuild || building instanceof CoreBuild) { - lowestDistance = Math.min(World.toTile(building.tile.dst2(this.tile)), lowestDistance); + lowestDistance = Math.min(building.tile.dst2(this.tile), lowestDistance); } } - return (int)Math.sqrt(lowestDistance); + lowestDistance = Math.min(closestCore().tile.dst2(this.tile), lowestDistance); // Check the core itself as well + + return World.toTile(Mathf.sqrt(lowestDistance)); } public void handleBlockWarning() {