From debf940973b7d37acbd71ebd05cfddb3b36f6b3b Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 11 May 2022 09:39:43 -0400 Subject: [PATCH] Fixed preview render crash --- core/src/mindustry/content/Blocks.java | 1 + core/src/mindustry/graphics/Drawf.java | 5 +++++ core/src/mindustry/world/blocks/power/PowerNode.java | 8 ++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index e779c52547..6ed5a9e566 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -4666,6 +4666,7 @@ public class Blocks{ privileged = true; memoryCapacity = 128; + forceDark = true; }}; //endregion diff --git a/core/src/mindustry/graphics/Drawf.java b/core/src/mindustry/graphics/Drawf.java index 01719c07b5..d20367cf0a 100644 --- a/core/src/mindustry/graphics/Drawf.java +++ b/core/src/mindustry/graphics/Drawf.java @@ -223,22 +223,27 @@ public class Drawf{ } public static void light(float x, float y, float radius, Color color, float opacity){ + if(renderer == null) return; renderer.lights.add(x, y, radius, color, opacity); } public static void light(Position pos, float radius, Color color, float opacity){ + if(renderer == null) return; light(pos.getX(), pos.getY(), radius, color, opacity); } public static void light(float x, float y, TextureRegion region, Color color, float opacity){ + if(renderer == null) return; renderer.lights.add(x, y, region, color, opacity); } public static void light(float x, float y, float x2, float y2){ + if(renderer == null) return; renderer.lights.line(x, y, x2, y2, 30, Color.orange, 0.3f); } public static void light(float x, float y, float x2, float y2, float stroke, Color tint, float alpha){ + if(renderer == null) return; renderer.lights.line(x, y, x2, y2, stroke, tint, alpha); } diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index 9e7ec4cc2a..a47599bb18 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -159,7 +159,7 @@ public class PowerNode extends PowerBlock{ getPotentialLinks(tile, player.team(), other -> { Draw.color(laserColor1, Renderer.laserOpacity * 0.5f); - drawLaser(tile.team(), x * tilesize + offset, y * tilesize + offset, other.x, other.y, size, other.block.size); + drawLaser(x * tilesize + offset, y * tilesize + offset, other.x, other.y, size, other.block.size); Drawf.square(other.x, other.y, other.block.size * tilesize / 2f + 2f, Pal.place); }); @@ -177,7 +177,7 @@ public class PowerNode extends PowerBlock{ Draw.alpha(Renderer.laserOpacity); } - public void drawLaser(Team team, float x1, float y1, float x2, float y2, int size1, int size2){ + public void drawLaser(float x1, float y1, float x2, float y2, int size1, int size2){ float angle1 = Angles.angle(x1, y1, x2, y2), vx = Mathf.cosDeg(angle1), vy = Mathf.sinDeg(angle1), len1 = size1 * tilesize / 2f - 1.5f, len2 = size2 * tilesize / 2f - 1.5f; @@ -325,7 +325,7 @@ public class PowerNode extends PowerBlock{ if(otherReq == null || otherReq.block == null) continue; - drawLaser(player == null ? Team.sharded : player.team(), plan.drawx(), plan.drawy(), otherReq.drawx(), otherReq.drawy(), size, otherReq.block.size); + drawLaser(plan.drawx(), plan.drawy(), otherReq.drawx(), otherReq.drawy(), size, otherReq.block.size); } Draw.color(); } @@ -472,7 +472,7 @@ public class PowerNode extends PowerBlock{ if(link.block instanceof PowerNode && link.id >= id) continue; - drawLaser(team, x, y, link.x, link.y, size, link.block.size); + drawLaser(x, y, link.x, link.y, size, link.block.size); } Draw.reset();