From dca2ba760557bcac0c8e35069d5299d1c74db0a1 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Tue, 19 Jul 2022 10:59:29 -0700 Subject: [PATCH] Small tidying - Move RenderTypeExtension to util - Avoid creating unnecessary material objects in Shuklers - Remove vestigial classes --- .../flywheel/backend/FlywheelDebug.java | 32 ------------------- .../instancing/BatchDrawingTracker.java | 1 + .../backend/instancing/Renderable.java | 6 ---- .../flywheel/mixin/RenderTypeMixin.java | 2 +- .../RenderTypeExtension.java | 4 ++- .../flywheel/vanilla/ShulkerBoxInstance.java | 5 +-- 6 files changed, 8 insertions(+), 42 deletions(-) delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/FlywheelDebug.java delete mode 100644 src/main/java/com/jozufozu/flywheel/backend/instancing/Renderable.java rename src/main/java/com/jozufozu/flywheel/{backend/instancing => util}/RenderTypeExtension.java (86%) diff --git a/src/main/java/com/jozufozu/flywheel/backend/FlywheelDebug.java b/src/main/java/com/jozufozu/flywheel/backend/FlywheelDebug.java deleted file mode 100644 index 48caf3cb9..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/FlywheelDebug.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.jozufozu.flywheel.backend; - -import org.lwjgl.opengl.GL43; -import org.lwjgl.opengl.GLDebugMessageCallback; - -import com.mojang.blaze3d.platform.GlDebug; - -public class FlywheelDebug { -// -// public static void setup() { -// GLDebugMessageCallback.create() -// GL43.glDebugMessageCallback(); -// } -// -// private static void printDebugLog(int p_84039_, int p_84040_, int p_84041_, int p_84042_, int p_84043_, long p_84044_, long p_84045_) { -// String s = GLDebugMessageCallback.getMessage(p_84043_, p_84044_); -// GlDebug.LogEntry gldebug$logentry; -// synchronized(MESSAGE_BUFFER) { -// gldebug$logentry = lastEntry; -// if (gldebug$logentry != null && gldebug$logentry.isSame(p_84039_, p_84040_, p_84041_, p_84042_, s)) { -// ++gldebug$logentry.count; -// } else { -// gldebug$logentry = new GlDebug.LogEntry(p_84039_, p_84040_, p_84041_, p_84042_, s); -// MESSAGE_BUFFER.add(gldebug$logentry); -// lastEntry = gldebug$logentry; -// } -// } -// -// LOGGER.info("OpenGL debug message: {}", (Object)gldebug$logentry); -// } - -} diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/BatchDrawingTracker.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/BatchDrawingTracker.java index ee1bee295..e3de27024 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/BatchDrawingTracker.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/BatchDrawingTracker.java @@ -5,6 +5,7 @@ import java.util.Set; import com.jozufozu.flywheel.backend.model.BufferBuilderExtension; import com.jozufozu.flywheel.backend.model.DirectVertexConsumer; +import com.jozufozu.flywheel.util.RenderTypeExtension; import com.mojang.blaze3d.vertex.BufferBuilder; import net.minecraft.client.renderer.RenderType; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/Renderable.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/Renderable.java deleted file mode 100644 index 6678847e3..000000000 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/Renderable.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.jozufozu.flywheel.backend.instancing; - -@FunctionalInterface -public interface Renderable { - void draw(); -} diff --git a/src/main/java/com/jozufozu/flywheel/mixin/RenderTypeMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/RenderTypeMixin.java index 99d208b50..beb94487c 100644 --- a/src/main/java/com/jozufozu/flywheel/mixin/RenderTypeMixin.java +++ b/src/main/java/com/jozufozu/flywheel/mixin/RenderTypeMixin.java @@ -5,7 +5,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import com.jozufozu.flywheel.backend.instancing.DrawBuffer; -import com.jozufozu.flywheel.backend.instancing.RenderTypeExtension; +import com.jozufozu.flywheel.util.RenderTypeExtension; import net.minecraft.client.renderer.RenderType; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderTypeExtension.java b/src/main/java/com/jozufozu/flywheel/util/RenderTypeExtension.java similarity index 86% rename from src/main/java/com/jozufozu/flywheel/backend/instancing/RenderTypeExtension.java rename to src/main/java/com/jozufozu/flywheel/util/RenderTypeExtension.java index d95ea68c1..1de72d651 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/RenderTypeExtension.java +++ b/src/main/java/com/jozufozu/flywheel/util/RenderTypeExtension.java @@ -1,4 +1,6 @@ -package com.jozufozu.flywheel.backend.instancing; +package com.jozufozu.flywheel.util; + +import com.jozufozu.flywheel.backend.instancing.DrawBuffer; import net.minecraft.client.renderer.RenderType; diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java index 3674ef0b6..e02349d79 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java @@ -31,8 +31,9 @@ import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity; public class ShulkerBoxInstance extends BlockEntityInstance implements DynamicInstance { - private static final Function BASE = Util.memoize(it -> new BasicModelSupplier(() -> makeBaseModel(it), new Material(RenderType.entityCutoutNoCull(Sheets.SHULKER_SHEET), MaterialShaders.SHADED_VERTEX, MaterialShaders.DEFAULT_FRAGMENT))); - private static final Function LID = Util.memoize(it -> new BasicModelSupplier(() -> makeLidModel(it), new Material(RenderType.entityCutoutNoCull(Sheets.SHULKER_SHEET), MaterialShaders.SHADED_VERTEX, MaterialShaders.DEFAULT_FRAGMENT))); + private static final Material SHULKER_BOX_MATERIAL = new Material(RenderType.entityCutoutNoCull(Sheets.SHULKER_SHEET), MaterialShaders.SHADED_VERTEX, MaterialShaders.DEFAULT_FRAGMENT); + private static final Function BASE = Util.memoize(it -> new BasicModelSupplier(() -> makeBaseModel(it), SHULKER_BOX_MATERIAL)); + private static final Function LID = Util.memoize(it -> new BasicModelSupplier(() -> makeLidModel(it), SHULKER_BOX_MATERIAL)); private final TextureAtlasSprite texture;