From f33b08d99627302871793cd06e90876c1856ec36 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Sat, 15 May 2021 12:15:06 -0700 Subject: [PATCH] Minor fixes - Fix holder refresh - Fix SuperByteBuffer light calculation - Remove unused import --- .../actors/SawMovementBehaviour.java | 1 - .../render/ContraptionRenderDispatcher.java | 7 ++++--- .../foundation/render/SuperByteBuffer.java | 20 +++++++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java index 1ae52e6c7..494b8c183 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java @@ -1,6 +1,5 @@ package com.simibubi.create.content.contraptions.components.actors; -import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.saw.SawBlock; import com.simibubi.create.content.contraptions.components.saw.SawRenderer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index e0d475f9d..9c5d2665a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -58,7 +58,7 @@ import net.minecraftforge.client.model.data.EmptyModelData; public class ContraptionRenderDispatcher { private static final BlockModelRenderer MODEL_RENDERER = new BlockModelRenderer(Minecraft.getInstance().getBlockColors()); private static final BlockModelShapes BLOCK_MODELS = Minecraft.getInstance().getModelManager().getBlockModelShapes(); - private static int ticksUntilHolderRefresh; + private static int worldHolderRefreshCounter; public static final Int2ObjectMap RENDERERS = new Int2ObjectOpenHashMap<>(); public static final Int2ObjectMap WORLD_HOLDERS = new Int2ObjectOpenHashMap<>(); @@ -73,9 +73,10 @@ public class ContraptionRenderDispatcher { contraption.kinetics.tick(); } - if (ticksUntilHolderRefresh <= 0) { + worldHolderRefreshCounter++; + if (worldHolderRefreshCounter >= 20) { removeDeadHolders(); - ticksUntilHolderRefresh = 20; + worldHolderRefreshCounter = 0; } } diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java index b8c422172..1a6c81b39 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java @@ -150,10 +150,9 @@ public class SuperByteBuffer extends TemplateBuffer { lightPos.transform(lightTransform); int worldLight = getLight(Minecraft.getInstance().world, lightPos); - if (light >= 0) { - light = maxLight(worldLight, light); - } + light = maxLight(worldLight, light); } + if (hybridLight) builder.light(maxLight(light, getLight(buffer, i))); else @@ -165,12 +164,22 @@ public class SuperByteBuffer extends TemplateBuffer { .endVertex(); } - transforms = new MatrixStack(); + reset(); + } + public SuperByteBuffer reset() { + transforms = new MatrixStack(); spriteShiftFunc = null; - shouldColor = false; shouldLight = false; hybridLight = false; + packedLightCoords = 0; + lightTransform = null; + shouldColor = false; + r = 0; + g = 0; + b = 0; + a = 0; + return this; } public MatrixStacker matrixStacker() { @@ -263,7 +272,6 @@ public class SuperByteBuffer extends TemplateBuffer { public SuperByteBuffer light(int packedLightCoords) { shouldLight = true; - lightTransform = null; this.packedLightCoords = packedLightCoords; return this; }