From 6736577e1bd9aa85523cfebcbb7d709c378397b4 Mon Sep 17 00:00:00 2001 From: JozsefA Date: Mon, 8 Feb 2021 21:38:45 -0800 Subject: [PATCH] fix the rainbow debugger --- .../contraptions/base/KineticTileInstance.java | 3 ++- .../contraptions/components/fan/FanInstance.java | 3 ++- .../contraptions/relays/belt/BeltInstance.java | 2 +- .../relays/encased/SplitShaftInstance.java | 3 ++- .../relays/gearbox/GearboxInstance.java | 3 ++- .../foundation/render/FastRenderDispatcher.java | 5 +++++ .../contraption/ContraptionRenderDispatcher.java | 3 ++- .../render/instancing/KineticData.java | 16 ++++++++++++---- .../render/instancing/RenderMaterial.java | 3 ++- 9 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java index c3b2bf4c1..5b79e2e06 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileInstance.java @@ -19,7 +19,8 @@ public abstract class KineticTileInstance extends T protected final void updateRotation(InstanceKey key, Direction.Axis axis) { key.modifyInstance(data -> { - data.setRotationalSpeed(tile.getSpeed()) + data.setColor(tile.network) + .setRotationalSpeed(tile.getSpeed()) .setRotationOffset(getRotationOffset(axis)) .setRotationAxis(axis); }); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/FanInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/FanInstance.java index 8ad1f6d52..e7dfcb8b5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/FanInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/FanInstance.java @@ -82,7 +82,8 @@ public class FanInstance extends KineticTileInstance { updateRotation(shaft, axis); fan.modifyInstance(data -> { - data.setRotationalSpeed(getFanSpeed()) + data.setColor(tile.network) + .setRotationalSpeed(getFanSpeed()) .setRotationOffset(getRotationOffset(axis)) .setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector()); }); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstance.java index 6de68adfb..145e44920 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltInstance.java @@ -83,7 +83,7 @@ public class BeltInstance extends KineticTileInstance { @Override public void onUpdate() { for (InstanceKey key : keys) { - key.modifyInstance(data -> data.setRotationalSpeed(getScrollSpeed())); + key.modifyInstance(data -> data.setColor(tile.network).setRotationalSpeed(getScrollSpeed())); } if (pulleyKey != null) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftInstance.java index 5bb674062..dce5bac1c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftInstance.java @@ -77,7 +77,8 @@ public class SplitShaftInstance extends KineticTileInstance { Direction.Axis axis = dir.getAxis(); - data.setRotationalSpeed(tile.getSpeed() * tile.getRotationSpeedModifier(dir)) + data.setColor(tile.network) + .setRotationalSpeed(tile.getSpeed() * tile.getRotationSpeedModifier(dir)) .setRotationOffset(getRotationOffset(axis)) .setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector()); }); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java index ae6cfb934..2644bf25c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxInstance.java @@ -90,7 +90,8 @@ public class GearboxInstance extends KineticTileInstance { Direction direction = key.getKey(); Direction.Axis axis = direction.getAxis(); - data.setRotationalSpeed(getSpeed(direction)) + data.setColor(tile.network) + .setRotationalSpeed(getSpeed(direction)) .setRotationOffset(getRotationOffset(axis)) .setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector()); }); diff --git a/src/main/java/com/simibubi/create/foundation/render/FastRenderDispatcher.java b/src/main/java/com/simibubi/create/foundation/render/FastRenderDispatcher.java index f1265e932..4e0482a7d 100644 --- a/src/main/java/com/simibubi/create/foundation/render/FastRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/foundation/render/FastRenderDispatcher.java @@ -3,6 +3,7 @@ package com.simibubi.create.foundation.render; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.CreateClient; +import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.foundation.render.contraption.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.gl.backend.Backend; import com.simibubi.create.foundation.render.gl.backend.OptifineHandler; @@ -61,6 +62,10 @@ public class FastRenderDispatcher { return Backend.enabled; } + public static int getDebugMode() { + return KineticDebugger.isActive() ? 1 : 0; + } + public static void refresh() { RenderWork.enqueue(() -> { CreateClient.kineticRenderer.invalidate(); diff --git a/src/main/java/com/simibubi/create/foundation/render/contraption/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/foundation/render/contraption/ContraptionRenderDispatcher.java index ab6075114..b10d7ab85 100644 --- a/src/main/java/com/simibubi/create/foundation/render/contraption/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/foundation/render/contraption/ContraptionRenderDispatcher.java @@ -6,6 +6,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Abs import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionHandler; import com.simibubi.create.foundation.render.AllProgramSpecs; +import com.simibubi.create.foundation.render.FastRenderDispatcher; import com.simibubi.create.foundation.render.gl.backend.Backend; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.Minecraft; @@ -95,7 +96,7 @@ public class ContraptionRenderDispatcher { GL13.glActiveTexture(GL40.GL_TEXTURE4); // the shaders expect light volumes to be in texture 4 ContraptionProgram structureShader = Backend.getProgram(AllProgramSpecs.CONTRAPTION_STRUCTURE); - structureShader.bind(viewProjection, 0); + structureShader.bind(viewProjection, FastRenderDispatcher.getDebugMode()); for (RenderedContraption renderer : renderers.values()) { renderer.doRenderLayer(layer, structureShader); } diff --git a/src/main/java/com/simibubi/create/foundation/render/instancing/KineticData.java b/src/main/java/com/simibubi/create/foundation/render/instancing/KineticData.java index 99d33cf8c..b205596ac 100644 --- a/src/main/java/com/simibubi/create/foundation/render/instancing/KineticData.java +++ b/src/main/java/com/simibubi/create/foundation/render/instancing/KineticData.java @@ -64,11 +64,19 @@ public class KineticData> extends InstanceData { return (D) this; } - private void setColor(long l) { + public D setColor(Long l) { + if (l != null) + return setColor(l.longValue()); + else + return setColor(0xFF, 0xFF, 0xFF); + } + + private D setColor(long l) { int color = ColorHelper.colorFromLong(l); - r = (byte) ((color >> 16) & 0xFF); - g = (byte) ((color >> 8) & 0xFF); - b = (byte) (color & 0xFF); + byte r = (byte) ((color >> 16) & 0xFF); + byte g = (byte) ((color >> 8) & 0xFF); + byte b = (byte) (color & 0xFF); + return setColor(r, g, b); } public D setColor(int r, int g, int b) { diff --git a/src/main/java/com/simibubi/create/foundation/render/instancing/RenderMaterial.java b/src/main/java/com/simibubi/create/foundation/render/instancing/RenderMaterial.java index 4feaa3e8f..11e8aebae 100644 --- a/src/main/java/com/simibubi/create/foundation/render/instancing/RenderMaterial.java +++ b/src/main/java/com/simibubi/create/foundation/render/instancing/RenderMaterial.java @@ -6,6 +6,7 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.Compartment; +import com.simibubi.create.foundation.render.FastRenderDispatcher; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.render.gl.BasicProgram; import com.simibubi.create.foundation.render.gl.backend.Backend; @@ -64,7 +65,7 @@ public class RenderMaterial

setup) { P program = Backend.getProgram(programSpec); - program.bind(viewProjection, 0); + program.bind(viewProjection, FastRenderDispatcher.getDebugMode()); if (setup != null) setup.call(program);