From 0183451a060daadeaa8e9a5154e257a84df98290 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Thu, 29 Jul 2021 18:50:47 -0700 Subject: [PATCH] Fix issue with missing banner pattern textures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #12 What the heck CrumblingRenderer gets classloaded early because of its event listener. CrumblingRenderer had an innocent static reference to a member of ModelBakery. This caused ModelBakery to classload before additional enums could be injected into BannerPattern. ¯\_(ツ)_/¯ --- .../flywheel/core/crumbling/CrumblingRenderer.java | 7 +++---- src/main/java/com/jozufozu/flywheel/util/Lazy.java | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingRenderer.java b/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingRenderer.java index caca38784..5415512dc 100644 --- a/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingRenderer.java @@ -53,8 +53,6 @@ public class CrumblingRenderer { INVALIDATOR = state.getSecond(); } - private static final RenderType crumblingLayer = ModelBakery.DESTROY_TYPES.get(0); - public static void renderBreaking(ClientWorld world, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) { if (!Backend.getInstance() .canUseInstancing(world)) return; @@ -64,6 +62,7 @@ public class CrumblingRenderer { if (activeStages.isEmpty()) return; State state = STATE.get(); + RenderType layer = ModelBakery.DESTROY_TYPES.get(0); InstanceManager renderer = state.instanceManager; @@ -71,7 +70,7 @@ public class CrumblingRenderer { ActiveRenderInfo info = Minecraft.getInstance().gameRenderer.getMainCamera(); MaterialManager materials = state.materialManager; - crumblingLayer.setupRenderState(); + layer.setupRenderState(); for (Int2ObjectMap.Entry> stage : activeStages.int2ObjectEntrySet()) { int i = stage.getIntKey(); @@ -92,7 +91,7 @@ public class CrumblingRenderer { } - crumblingLayer.clearRenderState(); + layer.clearRenderState(); GlTextureUnit.T0.makeActive(); Texture breaking = textureManager.getTexture(ModelBakery.BREAKING_LOCATIONS.get(0)); diff --git a/src/main/java/com/jozufozu/flywheel/util/Lazy.java b/src/main/java/com/jozufozu/flywheel/util/Lazy.java index 344a07976..6bcbd9d23 100644 --- a/src/main/java/com/jozufozu/flywheel/util/Lazy.java +++ b/src/main/java/com/jozufozu/flywheel/util/Lazy.java @@ -36,6 +36,10 @@ public class Lazy { return Pair.of(lazy, killSwitch); } + public static Lazy of(NonNullSupplier factory) { + return new Lazy<>(factory); + } + public static class KillSwitch { private final Lazy lazy;