From 0a2d8576fd0e82a85578ccd90813992c040d8531 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 27 Jul 2025 23:52:19 -0400 Subject: [PATCH] Fixed rendering of liquids under floors --- core/src/mindustry/editor/EditorTool.java | 3 +- .../world/blocks/environment/Floor.java | 47 ++++++++++++------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/core/src/mindustry/editor/EditorTool.java b/core/src/mindustry/editor/EditorTool.java index 753d227fe9..d3b47efb65 100644 --- a/core/src/mindustry/editor/EditorTool.java +++ b/core/src/mindustry/editor/EditorTool.java @@ -10,6 +10,7 @@ import mindustry.content.*; import mindustry.game.*; import mindustry.gen.*; import mindustry.world.*; +import mindustry.world.blocks.environment.*; import static mindustry.Vars.*; @@ -67,7 +68,7 @@ public enum EditorTool{ }else if(mode == 2){ //draw teams editor.drawCircle(x, y, tile -> tile.setTeam(editor.drawTeam)); - }else if(mode == 3){ + }else if(mode == 3 && !(editor.drawBlock instanceof Floor f && f.isLiquid)){ editor.drawBlocks(x, y, false, true, tile -> tile.floor().isLiquid); } diff --git a/core/src/mindustry/world/blocks/environment/Floor.java b/core/src/mindustry/world/blocks/environment/Floor.java index 06f087a30b..dbd97cafe7 100644 --- a/core/src/mindustry/world/blocks/environment/Floor.java +++ b/core/src/mindustry/world/blocks/environment/Floor.java @@ -233,6 +233,21 @@ public class Floor extends Block{ @Override public void drawBase(Tile tile){ + drawMain(tile); + + if(drawEdgeIn){ + drawEdges(tile); + } + drawOverlay(tile); + + if(tile.overlay() != Blocks.air && tile.floor() == this && isLiquid){ + Draw.alpha(1f - overlayAlpha); + drawMain(tile); + Draw.color(); + } + } + + public void drawMain(Tile tile){ if(tilingVariants > 0){ int index = Mathf.randomSeed(Point2.pack(tile.x / tilingSize, tile.y / tilingSize), 0, tilingVariants - 1); TextureRegion[][] regions = tilingRegions[index]; @@ -258,10 +273,6 @@ public class Floor extends Block{ } Draw.alpha(1f); - if(drawEdgeIn){ - drawEdges(tile); - } - drawOverlay(tile); } public boolean checkAutotileSame(Tile tile, @Nullable Tile other){ @@ -279,13 +290,7 @@ public class Floor extends Block{ public void drawOverlay(Tile tile){ Floor floor = tile.overlay(); if(floor != Blocks.air && floor != this){ - if(isLiquid){ - Draw.alpha(overlayAlpha); - } floor.drawBase(tile); - if(isLiquid){ - Draw.alpha(1f); - } } } @@ -351,11 +356,15 @@ public class Floor extends Block{ Point2 point = Geometry.d8[i]; Tile other = tile.nearby(point); - if(other != null && other.floor().drawEdgeOut && doEdge(tile, other, other.floor()) && other.floor().cacheLayer == realCache && other.floor().edges(tile.x, tile.y) != null){ - if(!blended.getAndSet(other.floor().id)){ - blenders.add(other.floor()); + if(other == null) continue; + + Floor ob = (this == tile.floor() || other.overlay() == Blocks.air ? other.floor() : other.overlay()); + + if(ob.drawEdgeOut && doEdge(tile, other, ob) && other.floor().cacheLayer == realCache && ob.edges(tile.x, tile.y) != null){ + if(!blended.getAndSet(ob.id)){ + blenders.add(ob); } - dirs[i] = other.floorID(); + dirs[i] = ob.id; } } @@ -363,13 +372,19 @@ public class Floor extends Block{ } protected void drawBlended(Tile tile, boolean checkId){ - blenders.sort(a -> a.id); + //prioritize the "actual" floor over other floors to fix weird square corners + blenders.sort(a -> a.id + (tile.floor() != this && a == tile.floor() ? 99999 : 0)); for(Floor block : blenders){ for(int i = 0; i < 8; i++){ Point2 point = Geometry.d8[i]; Tile other = tile.nearby(point); - if(other != null && other.floor() == block && (!checkId || dirs[i] == block.id)){ + + if(other == null) continue; + + Floor ob = (this == tile.floor() || other.overlay() == Blocks.air ? other.floor() : other.overlay()); + + if(ob == block && (!checkId || dirs[i] == block.id)){ TextureRegion region = block.edge(tile.x, tile.y, 1 - point.x, 1 - point.y); Draw.rect(region, tile.worldx(), tile.worldy()); }