From 6d2aab7716afca89a60f33bc7f25c188d577a1f4 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Mon, 20 Jan 2025 13:58:51 -0600 Subject: [PATCH] Vanillinization - Move all text visual related things into vanillin --- .../flywheel/lib/instance/InstanceTypes.java | 21 ------------ .../flywheel/lib/internal/FlwLibLink.java | 10 ------ .../flywheel/impl/FlwLibLinkImpl.java | 21 ------------ .../main/resources/flywheel.impl.mixins.json | 6 ---- .../engine_room/vanillin}/GlyphInstance.java | 11 ++++--- .../engine_room/vanillin/VanillaVisuals.java | 4 +++ .../vanillin/VanillinInstanceTypes.java | 32 +++++++++++++++++++ .../vanillin}/mixin/text/BakedGlyphMixin.java | 4 +-- .../mixin/text/CodePointMapMixin.java | 2 +- .../vanillin}/mixin/text/FontAccessor.java | 2 +- .../vanillin}/mixin/text/FontSetMixin.java | 4 +-- .../mixin/text/FontTexture$NodeAccessor.java | 2 +- .../mixin/text/FontTextureMixin.java | 8 ++--- .../vanillin/text}/BakedGlyphExtension.java | 2 +- .../vanillin/text}/FontTextureExtension.java | 2 +- .../vanillin/text}/FontTextureUpload.java | 2 +- .../vanillin}/text/SimpleTextLayer.java | 2 +- .../engine_room/vanillin}/text/TextLayer.java | 2 +- .../vanillin}/text/TextLayers.java | 2 +- .../engine_room/vanillin/text/TextUtil.java | 21 ++++++++++++ .../vanillin}/text/TextVisual.java | 29 ++++++++--------- .../vanillin/visuals/SignVisual.java | 12 +++---- .../flywheel/instance/cull/glyph.glsl | 0 .../vanillin}/flywheel/instance/glyph.vert | 0 .../vanillin/resources/vanillin.mixins.json | 18 +++++++++++ forge/build.gradle.kts | 3 -- .../src/main/resources/fabric.mod.json | 1 + vanillinForge/build.gradle.kts | 7 ++++ 28 files changed, 126 insertions(+), 104 deletions(-) rename common/src/{lib/java/dev/engine_room/flywheel/lib/instance => vanillin/java/dev/engine_room/vanillin}/GlyphInstance.java (85%) create mode 100644 common/src/vanillin/java/dev/engine_room/vanillin/VanillinInstanceTypes.java rename common/src/{main/java/dev/engine_room/flywheel/impl => vanillin/java/dev/engine_room/vanillin}/mixin/text/BakedGlyphMixin.java (92%) rename common/src/{main/java/dev/engine_room/flywheel/impl => vanillin/java/dev/engine_room/vanillin}/mixin/text/CodePointMapMixin.java (97%) rename common/src/{main/java/dev/engine_room/flywheel/impl => vanillin/java/dev/engine_room/vanillin}/mixin/text/FontAccessor.java (90%) rename common/src/{main/java/dev/engine_room/flywheel/impl => vanillin/java/dev/engine_room/vanillin}/mixin/text/FontSetMixin.java (90%) rename common/src/{main/java/dev/engine_room/flywheel/impl => vanillin/java/dev/engine_room/vanillin}/mixin/text/FontTexture$NodeAccessor.java (84%) rename common/src/{main/java/dev/engine_room/flywheel/impl => vanillin/java/dev/engine_room/vanillin}/mixin/text/FontTextureMixin.java (95%) rename common/src/{lib/java/dev/engine_room/flywheel/lib/internal => vanillin/java/dev/engine_room/vanillin/text}/BakedGlyphExtension.java (88%) rename common/src/{main/java/dev/engine_room/flywheel/impl/extension => vanillin/java/dev/engine_room/vanillin/text}/FontTextureExtension.java (74%) rename common/src/{main/java/dev/engine_room/flywheel/impl => vanillin/java/dev/engine_room/vanillin/text}/FontTextureUpload.java (87%) rename common/src/{lib/java/dev/engine_room/flywheel/lib/visual => vanillin/java/dev/engine_room/vanillin}/text/SimpleTextLayer.java (96%) rename common/src/{lib/java/dev/engine_room/flywheel/lib/visual => vanillin/java/dev/engine_room/vanillin}/text/TextLayer.java (99%) rename common/src/{lib/java/dev/engine_room/flywheel/lib/visual => vanillin/java/dev/engine_room/vanillin}/text/TextLayers.java (96%) create mode 100644 common/src/vanillin/java/dev/engine_room/vanillin/text/TextUtil.java rename common/src/{lib/java/dev/engine_room/flywheel/lib/visual => vanillin/java/dev/engine_room/vanillin}/text/TextVisual.java (90%) rename common/src/{lib/resources/assets/flywheel => vanillin/resources/assets/vanillin}/flywheel/instance/cull/glyph.glsl (100%) rename common/src/{lib/resources/assets/flywheel => vanillin/resources/assets/vanillin}/flywheel/instance/glyph.vert (100%) create mode 100644 common/src/vanillin/resources/vanillin.mixins.json diff --git a/common/src/lib/java/dev/engine_room/flywheel/lib/instance/InstanceTypes.java b/common/src/lib/java/dev/engine_room/flywheel/lib/instance/InstanceTypes.java index c47cfadcb..da093b634 100644 --- a/common/src/lib/java/dev/engine_room/flywheel/lib/instance/InstanceTypes.java +++ b/common/src/lib/java/dev/engine_room/flywheel/lib/instance/InstanceTypes.java @@ -103,27 +103,6 @@ public final class InstanceTypes { .cullShader(Flywheel.rl("instance/cull/shadow.glsl")) .build(); - public static final InstanceType GLYPH = SimpleInstanceType.builder(GlyphInstance::new) - .layout(LayoutBuilder.create() - .matrix("pose", FloatRepr.FLOAT, 4) - .vector("u0u1v0v1", FloatRepr.NORMALIZED_UNSIGNED_SHORT, 4) - .vector("color", FloatRepr.NORMALIZED_UNSIGNED_BYTE, 4) - .vector("light", FloatRepr.UNSIGNED_SHORT, 2) - .build()) - .writer((ptr, instance) -> { - ExtraMemoryOps.putMatrix4f(ptr, instance.pose); - ExtraMemoryOps.put2x16(ptr + 64, instance.packedUs); - ExtraMemoryOps.put2x16(ptr + 68, instance.packedVs); - MemoryUtil.memPutByte(ptr + 72, instance.red); - MemoryUtil.memPutByte(ptr + 73, instance.green); - MemoryUtil.memPutByte(ptr + 74, instance.blue); - MemoryUtil.memPutByte(ptr + 75, instance.alpha); - ExtraMemoryOps.put2x16(ptr + 76, instance.light); - }) - .vertexShader(Flywheel.rl("instance/glyph.vert")) - .cullShader(Flywheel.rl("instance/cull/glyph.glsl")) - .build(); - private InstanceTypes() { } } diff --git a/common/src/lib/java/dev/engine_room/flywheel/lib/internal/FlwLibLink.java b/common/src/lib/java/dev/engine_room/flywheel/lib/internal/FlwLibLink.java index 1e8bfec64..c33ae35c1 100644 --- a/common/src/lib/java/dev/engine_room/flywheel/lib/internal/FlwLibLink.java +++ b/common/src/lib/java/dev/engine_room/flywheel/lib/internal/FlwLibLink.java @@ -10,11 +10,7 @@ import com.mojang.blaze3d.vertex.VertexConsumer; import dev.engine_room.flywheel.api.internal.DependencyInjection; import dev.engine_room.flywheel.lib.transform.PoseTransformStack; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.font.FontSet; -import net.minecraft.client.gui.font.glyphs.BakedGlyph; import net.minecraft.client.model.geom.ModelPart; -import net.minecraft.resources.ResourceLocation; public interface FlwLibLink { FlwLibLink INSTANCE = DependencyInjection.load(FlwLibLink.class, "dev.engine_room.flywheel.impl.FlwLibLinkImpl"); @@ -36,10 +32,4 @@ public interface FlwLibLink { boolean isShaderPackInUse(); boolean isRenderingShadowPass(); - - FontSet getFontSet(Font font, ResourceLocation loc); - - boolean getFilterFishyGlyphs(Font font); - - BakedGlyphExtension getBakedGlyphExtension(BakedGlyph glyph); } diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/FlwLibLinkImpl.java b/common/src/main/java/dev/engine_room/flywheel/impl/FlwLibLinkImpl.java index 280f62d10..1b1e19c2e 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/FlwLibLinkImpl.java +++ b/common/src/main/java/dev/engine_room/flywheel/impl/FlwLibLinkImpl.java @@ -13,15 +13,9 @@ import dev.engine_room.flywheel.impl.compat.OptifineCompat; import dev.engine_room.flywheel.impl.extension.PoseStackExtension; import dev.engine_room.flywheel.impl.mixin.ModelPartAccessor; import dev.engine_room.flywheel.impl.mixin.PoseStackAccessor; -import dev.engine_room.flywheel.impl.mixin.text.FontAccessor; -import dev.engine_room.flywheel.lib.internal.BakedGlyphExtension; import dev.engine_room.flywheel.lib.internal.FlwLibLink; import dev.engine_room.flywheel.lib.transform.PoseTransformStack; -import net.minecraft.client.gui.Font; -import net.minecraft.client.gui.font.FontSet; -import net.minecraft.client.gui.font.glyphs.BakedGlyph; import net.minecraft.client.model.geom.ModelPart; -import net.minecraft.resources.ResourceLocation; public class FlwLibLinkImpl implements FlwLibLink { @Override @@ -80,19 +74,4 @@ public class FlwLibLinkImpl implements FlwLibLink { return false; } } - - @Override - public FontSet getFontSet(Font font, ResourceLocation loc) { - return ((FontAccessor) font).flywheel$getFontSet(loc); - } - - @Override - public boolean getFilterFishyGlyphs(Font font) { - return ((FontAccessor) font).flywheel$getFilterFishyGlyphs(); - } - - @Override - public BakedGlyphExtension getBakedGlyphExtension(BakedGlyph glyph) { - return (BakedGlyphExtension) glyph; - } } diff --git a/common/src/main/resources/flywheel.impl.mixins.json b/common/src/main/resources/flywheel.impl.mixins.json index 3d4bdb723..a1953a127 100644 --- a/common/src/main/resources/flywheel.impl.mixins.json +++ b/common/src/main/resources/flywheel.impl.mixins.json @@ -16,12 +16,6 @@ "PoseStackMixin", "fix.FixFabulousDepthMixin", "fix.FixNormalScalingMixin", - "text.BakedGlyphMixin", - "text.CodePointMapMixin", - "text.FontAccessor", - "text.FontSetMixin", - "text.FontTexture$NodeAccessor", - "text.FontTextureMixin", "visualmanage.BlockEntityMixin", "visualmanage.LevelChunkMixin", "visualmanage.LevelRendererMixin", diff --git a/common/src/lib/java/dev/engine_room/flywheel/lib/instance/GlyphInstance.java b/common/src/vanillin/java/dev/engine_room/vanillin/GlyphInstance.java similarity index 85% rename from common/src/lib/java/dev/engine_room/flywheel/lib/instance/GlyphInstance.java rename to common/src/vanillin/java/dev/engine_room/vanillin/GlyphInstance.java index 4278913a7..1356e25a7 100644 --- a/common/src/lib/java/dev/engine_room/flywheel/lib/instance/GlyphInstance.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/GlyphInstance.java @@ -1,13 +1,14 @@ -package dev.engine_room.flywheel.lib.instance; +package dev.engine_room.vanillin; import org.joml.Matrix4f; import org.joml.Matrix4fc; import dev.engine_room.flywheel.api.instance.InstanceHandle; import dev.engine_room.flywheel.api.instance.InstanceType; -import dev.engine_room.flywheel.lib.internal.BakedGlyphExtension; -import dev.engine_room.flywheel.lib.internal.FlwLibLink; +import dev.engine_room.flywheel.lib.instance.ColoredLitInstance; import dev.engine_room.flywheel.lib.math.DataPacker; +import dev.engine_room.vanillin.text.BakedGlyphExtension; +import dev.engine_room.vanillin.text.TextUtil; import net.minecraft.client.gui.font.glyphs.BakedGlyph; public class GlyphInstance extends ColoredLitInstance { @@ -25,7 +26,7 @@ public class GlyphInstance extends ColoredLitInstance { } public GlyphInstance setGlyph(BakedGlyph glyph, Matrix4fc initialPose, float x, float y, boolean italic) { - var glyphExtension = FlwLibLink.INSTANCE.getBakedGlyphExtension(glyph); + var glyphExtension = TextUtil.getBakedGlyphExtension(glyph); setUvs(glyphExtension); float left = glyphExtension.flywheel$left(); @@ -44,7 +45,7 @@ public class GlyphInstance extends ColoredLitInstance { } public GlyphInstance setEffect(BakedGlyph glyph, Matrix4fc initialPose, float x0, float y0, float x1, float y1, float depth) { - var glyphExtension = FlwLibLink.INSTANCE.getBakedGlyphExtension(glyph); + var glyphExtension = TextUtil.getBakedGlyphExtension(glyph); setUvs(glyphExtension); pose.set(initialPose); diff --git a/common/src/vanillin/java/dev/engine_room/vanillin/VanillaVisuals.java b/common/src/vanillin/java/dev/engine_room/vanillin/VanillaVisuals.java index 93c98ef8b..a24f19843 100644 --- a/common/src/vanillin/java/dev/engine_room/vanillin/VanillaVisuals.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/VanillaVisuals.java @@ -4,6 +4,7 @@ import dev.engine_room.vanillin.visuals.BellVisual; import dev.engine_room.vanillin.visuals.ChestVisual; import dev.engine_room.vanillin.visuals.MinecartVisual; import dev.engine_room.vanillin.visuals.ShulkerBoxVisual; +import dev.engine_room.vanillin.visuals.SignVisual; import dev.engine_room.vanillin.visuals.TntMinecartVisual; import net.minecraft.client.model.geom.ModelLayers; import net.minecraft.world.entity.Entity; @@ -33,6 +34,9 @@ public class VanillaVisuals { .factory(ShulkerBoxVisual::new) .apply(true); + builder(BlockEntityType.SIGN).factory(SignVisual::new) + .apply(false); + builder(EntityType.CHEST_MINECART) .factory((ctx, entity, partialTick) -> new MinecartVisual<>(ctx, entity, partialTick, ModelLayers.CHEST_MINECART)) .skipVanillaRender(MinecartVisual::shouldSkipRender) diff --git a/common/src/vanillin/java/dev/engine_room/vanillin/VanillinInstanceTypes.java b/common/src/vanillin/java/dev/engine_room/vanillin/VanillinInstanceTypes.java new file mode 100644 index 000000000..b89fcfb48 --- /dev/null +++ b/common/src/vanillin/java/dev/engine_room/vanillin/VanillinInstanceTypes.java @@ -0,0 +1,32 @@ +package dev.engine_room.vanillin; + +import org.lwjgl.system.MemoryUtil; + +import dev.engine_room.flywheel.api.instance.InstanceType; +import dev.engine_room.flywheel.api.layout.FloatRepr; +import dev.engine_room.flywheel.api.layout.LayoutBuilder; +import dev.engine_room.flywheel.lib.instance.SimpleInstanceType; +import dev.engine_room.flywheel.lib.util.ExtraMemoryOps; + +public class VanillinInstanceTypes { + public static final InstanceType GLYPH = SimpleInstanceType.builder(GlyphInstance::new) + .layout(LayoutBuilder.create() + .matrix("pose", FloatRepr.FLOAT, 4) + .vector("u0u1v0v1", FloatRepr.NORMALIZED_UNSIGNED_SHORT, 4) + .vector("color", FloatRepr.NORMALIZED_UNSIGNED_BYTE, 4) + .vector("light", FloatRepr.UNSIGNED_SHORT, 2) + .build()) + .writer((ptr, instance) -> { + ExtraMemoryOps.putMatrix4f(ptr, instance.pose); + ExtraMemoryOps.put2x16(ptr + 64, instance.packedUs); + ExtraMemoryOps.put2x16(ptr + 68, instance.packedVs); + MemoryUtil.memPutByte(ptr + 72, instance.red); + MemoryUtil.memPutByte(ptr + 73, instance.green); + MemoryUtil.memPutByte(ptr + 74, instance.blue); + MemoryUtil.memPutByte(ptr + 75, instance.alpha); + ExtraMemoryOps.put2x16(ptr + 76, instance.light); + }) + .vertexShader(Vanillin.rl("instance/glyph.vert")) + .cullShader(Vanillin.rl("instance/cull/glyph.glsl")) + .build(); +} diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/BakedGlyphMixin.java b/common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/BakedGlyphMixin.java similarity index 92% rename from common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/BakedGlyphMixin.java rename to common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/BakedGlyphMixin.java index e18ffb5c5..90d5ab0d4 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/BakedGlyphMixin.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/BakedGlyphMixin.java @@ -1,11 +1,11 @@ -package dev.engine_room.flywheel.impl.mixin.text; +package dev.engine_room.vanillin.mixin.text; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; -import dev.engine_room.flywheel.lib.internal.BakedGlyphExtension; +import dev.engine_room.vanillin.text.BakedGlyphExtension; import net.minecraft.client.gui.font.glyphs.BakedGlyph; import net.minecraft.resources.ResourceLocation; diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/CodePointMapMixin.java b/common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/CodePointMapMixin.java similarity index 97% rename from common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/CodePointMapMixin.java rename to common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/CodePointMapMixin.java index 5c9f245bc..e73f87c7f 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/CodePointMapMixin.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/CodePointMapMixin.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.impl.mixin.text; +package dev.engine_room.vanillin.mixin.text; import java.util.function.IntFunction; diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/FontAccessor.java b/common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/FontAccessor.java similarity index 90% rename from common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/FontAccessor.java rename to common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/FontAccessor.java index bb37a7212..70bec9f17 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/FontAccessor.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/FontAccessor.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.impl.mixin.text; +package dev.engine_room.vanillin.mixin.text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/FontSetMixin.java b/common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/FontSetMixin.java similarity index 90% rename from common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/FontSetMixin.java rename to common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/FontSetMixin.java index 8970ae216..9ee7ea82d 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/FontSetMixin.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/FontSetMixin.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.impl.mixin.text; +package dev.engine_room.vanillin.mixin.text; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.At; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; -import dev.engine_room.flywheel.impl.extension.FontTextureExtension; +import dev.engine_room.vanillin.text.FontTextureExtension; import net.minecraft.client.gui.font.FontSet; import net.minecraft.client.gui.font.FontTexture; import net.minecraft.resources.ResourceLocation; diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/FontTexture$NodeAccessor.java b/common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/FontTexture$NodeAccessor.java similarity index 84% rename from common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/FontTexture$NodeAccessor.java rename to common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/FontTexture$NodeAccessor.java index d2723f645..638e753bb 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/FontTexture$NodeAccessor.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/FontTexture$NodeAccessor.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.impl.mixin.text; +package dev.engine_room.vanillin.mixin.text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/FontTextureMixin.java b/common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/FontTextureMixin.java similarity index 95% rename from common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/FontTextureMixin.java rename to common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/FontTextureMixin.java index bd00aac1c..e6e01749a 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/text/FontTextureMixin.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/mixin/text/FontTextureMixin.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.impl.mixin.text; +package dev.engine_room.vanillin.mixin.text; import java.util.ArrayList; import java.util.List; @@ -20,9 +20,9 @@ import com.mojang.blaze3d.font.SheetGlyphInfo; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.systems.RenderSystem; -import dev.engine_room.flywheel.impl.FontTextureUpload; -import dev.engine_room.flywheel.impl.extension.FontTextureExtension; -import dev.engine_room.flywheel.lib.internal.BakedGlyphExtension; +import dev.engine_room.vanillin.text.BakedGlyphExtension; +import dev.engine_room.vanillin.text.FontTextureExtension; +import dev.engine_room.vanillin.text.FontTextureUpload; import net.minecraft.client.gui.font.FontTexture; import net.minecraft.client.gui.font.glyphs.BakedGlyph; import net.minecraft.client.renderer.texture.AbstractTexture; diff --git a/common/src/lib/java/dev/engine_room/flywheel/lib/internal/BakedGlyphExtension.java b/common/src/vanillin/java/dev/engine_room/vanillin/text/BakedGlyphExtension.java similarity index 88% rename from common/src/lib/java/dev/engine_room/flywheel/lib/internal/BakedGlyphExtension.java rename to common/src/vanillin/java/dev/engine_room/vanillin/text/BakedGlyphExtension.java index 5cfa0e45e..ceea95bb3 100644 --- a/common/src/lib/java/dev/engine_room/flywheel/lib/internal/BakedGlyphExtension.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/text/BakedGlyphExtension.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.lib.internal; +package dev.engine_room.vanillin.text; import net.minecraft.resources.ResourceLocation; diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/extension/FontTextureExtension.java b/common/src/vanillin/java/dev/engine_room/vanillin/text/FontTextureExtension.java similarity index 74% rename from common/src/main/java/dev/engine_room/flywheel/impl/extension/FontTextureExtension.java rename to common/src/vanillin/java/dev/engine_room/vanillin/text/FontTextureExtension.java index 2db5e5462..4075c2753 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/extension/FontTextureExtension.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/text/FontTextureExtension.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.impl.extension; +package dev.engine_room.vanillin.text; import net.minecraft.resources.ResourceLocation; diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/FontTextureUpload.java b/common/src/vanillin/java/dev/engine_room/vanillin/text/FontTextureUpload.java similarity index 87% rename from common/src/main/java/dev/engine_room/flywheel/impl/FontTextureUpload.java rename to common/src/vanillin/java/dev/engine_room/vanillin/text/FontTextureUpload.java index eb1c15ee2..4af88c5db 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/FontTextureUpload.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/text/FontTextureUpload.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.impl; +package dev.engine_room.vanillin.text; import com.mojang.blaze3d.font.SheetGlyphInfo; diff --git a/common/src/lib/java/dev/engine_room/flywheel/lib/visual/text/SimpleTextLayer.java b/common/src/vanillin/java/dev/engine_room/vanillin/text/SimpleTextLayer.java similarity index 96% rename from common/src/lib/java/dev/engine_room/flywheel/lib/visual/text/SimpleTextLayer.java rename to common/src/vanillin/java/dev/engine_room/vanillin/text/SimpleTextLayer.java index 39bdd1dd5..ab81ba7f0 100644 --- a/common/src/lib/java/dev/engine_room/flywheel/lib/visual/text/SimpleTextLayer.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/text/SimpleTextLayer.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.lib.visual.text; +package dev.engine_room.vanillin.text; import java.util.Objects; diff --git a/common/src/lib/java/dev/engine_room/flywheel/lib/visual/text/TextLayer.java b/common/src/vanillin/java/dev/engine_room/vanillin/text/TextLayer.java similarity index 99% rename from common/src/lib/java/dev/engine_room/flywheel/lib/visual/text/TextLayer.java rename to common/src/vanillin/java/dev/engine_room/vanillin/text/TextLayer.java index 35151c5d2..2bf0c8cc4 100644 --- a/common/src/lib/java/dev/engine_room/flywheel/lib/visual/text/TextLayer.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/text/TextLayer.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.lib.visual.text; +package dev.engine_room.vanillin.text; import java.util.function.Consumer; diff --git a/common/src/lib/java/dev/engine_room/flywheel/lib/visual/text/TextLayers.java b/common/src/vanillin/java/dev/engine_room/vanillin/text/TextLayers.java similarity index 96% rename from common/src/lib/java/dev/engine_room/flywheel/lib/visual/text/TextLayers.java rename to common/src/vanillin/java/dev/engine_room/vanillin/text/TextLayers.java index 57701ce76..247dc86f9 100644 --- a/common/src/lib/java/dev/engine_room/flywheel/lib/visual/text/TextLayers.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/text/TextLayers.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.lib.visual.text; +package dev.engine_room.vanillin.text; import net.minecraft.client.gui.Font; diff --git a/common/src/vanillin/java/dev/engine_room/vanillin/text/TextUtil.java b/common/src/vanillin/java/dev/engine_room/vanillin/text/TextUtil.java new file mode 100644 index 000000000..6ca2fb345 --- /dev/null +++ b/common/src/vanillin/java/dev/engine_room/vanillin/text/TextUtil.java @@ -0,0 +1,21 @@ +package dev.engine_room.vanillin.text; + +import dev.engine_room.vanillin.mixin.text.FontAccessor; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.font.FontSet; +import net.minecraft.client.gui.font.glyphs.BakedGlyph; +import net.minecraft.resources.ResourceLocation; + +public class TextUtil { + public static FontSet getFontSet(Font font, ResourceLocation loc) { + return ((FontAccessor) font).flywheel$getFontSet(loc); + } + + public static boolean getFilterFishyGlyphs(Font font) { + return ((FontAccessor) font).flywheel$getFilterFishyGlyphs(); + } + + public static BakedGlyphExtension getBakedGlyphExtension(BakedGlyph glyph) { + return (BakedGlyphExtension) glyph; + } +} diff --git a/common/src/lib/java/dev/engine_room/flywheel/lib/visual/text/TextVisual.java b/common/src/vanillin/java/dev/engine_room/vanillin/text/TextVisual.java similarity index 90% rename from common/src/lib/java/dev/engine_room/flywheel/lib/visual/text/TextVisual.java rename to common/src/vanillin/java/dev/engine_room/vanillin/text/TextVisual.java index cac40b934..df2ff0fee 100644 --- a/common/src/lib/java/dev/engine_room/flywheel/lib/visual/text/TextVisual.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/text/TextVisual.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.lib.visual.text; +package dev.engine_room.vanillin.text; import java.util.ArrayList; import java.util.List; @@ -17,13 +17,12 @@ import dev.engine_room.flywheel.api.instance.InstancerProvider; import dev.engine_room.flywheel.api.model.Mesh; import dev.engine_room.flywheel.api.model.Model; import dev.engine_room.flywheel.api.vertex.MutableVertexList; -import dev.engine_room.flywheel.lib.instance.GlyphInstance; -import dev.engine_room.flywheel.lib.instance.InstanceTypes; -import dev.engine_room.flywheel.lib.internal.FlwLibLink; import dev.engine_room.flywheel.lib.model.QuadMesh; import dev.engine_room.flywheel.lib.model.SingleMeshModel; -import dev.engine_room.flywheel.lib.util.ResourceReloadCache; +import dev.engine_room.flywheel.lib.util.RendererReloadCache; import dev.engine_room.flywheel.lib.visual.util.SmartRecycler; +import dev.engine_room.vanillin.GlyphInstance; +import dev.engine_room.vanillin.VanillinInstanceTypes; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.font.FontSet; @@ -42,8 +41,8 @@ import net.minecraft.util.Mth; public final class TextVisual { private static final Font FONT = Minecraft.getInstance().font; - private static final ResourceReloadCache GLYPH_MESH_CACHE = new ResourceReloadCache<>(GlyphMeshKey::into); - private static final ResourceReloadCache GLYPH_MODEL_CACHE = new ResourceReloadCache<>(GlyphModelKey::into); + private static final RendererReloadCache GLYPH_MESH_CACHE = new RendererReloadCache<>(GlyphMeshKey::into); + private static final RendererReloadCache GLYPH_MODEL_CACHE = new RendererReloadCache<>(GlyphModelKey::into); private static final ThreadLocal SINKS = ThreadLocal.withInitial(Sink::new); @@ -56,7 +55,7 @@ public final class TextVisual { private int light; public TextVisual(InstancerProvider provider) { - recycler = new SmartRecycler<>(key -> provider.instancer(InstanceTypes.GLYPH, GLYPH_MODEL_CACHE.get(key.modelKey), key.bias) + recycler = new SmartRecycler<>(key -> provider.instancer(VanillinInstanceTypes.GLYPH, GLYPH_MODEL_CACHE.get(key.modelKey), key.bias) .createInstance()); } @@ -179,8 +178,8 @@ public final class TextVisual { @Override public boolean accept(int index, Style style, int codePoint) { - FontSet fontSet = FlwLibLink.INSTANCE.getFontSet(FONT, style.getFont()); - GlyphInfo glyphInfo = fontSet.getGlyphInfo(codePoint, FlwLibLink.INSTANCE.getFilterFishyGlyphs(FONT)); + FontSet fontSet = TextUtil.getFontSet(FONT, style.getFont()); + GlyphInfo glyphInfo = fontSet.getGlyphInfo(codePoint, TextUtil.getFilterFishyGlyphs(FONT)); BakedGlyph glyph = style.isObfuscated() && codePoint != ' ' ? fontSet.getRandomGlyph(glyphInfo) : fontSet.getGlyph(codePoint); boolean bold = style.isBold(); @@ -218,10 +217,10 @@ public final class TextVisual { public void addBackground(int backgroundColor, float startX, float endX) { if (backgroundColor != 0) { - BakedGlyph glyph = FlwLibLink.INSTANCE.getFontSet(FONT, Style.DEFAULT_FONT) + BakedGlyph glyph = TextUtil.getFontSet(FONT, Style.DEFAULT_FONT) .whiteGlyph(); - var glyphExtension = FlwLibLink.INSTANCE.getBakedGlyphExtension(glyph); + var glyphExtension = TextUtil.getBakedGlyphExtension(glyph); GlyphInstance instance = recycler.get(effectKey(glyphExtension.flywheel$texture(), TextLayer.GlyphMaterial.SEE_THROUGH, 0)); instance.setEffect(glyph, pose, startX - 1.0f, 9.0f, endX + 1.0f, 1.0f, 0.01f); @@ -232,7 +231,7 @@ public final class TextVisual { } private void addEffect(TextLayer layer, float x0, float y0, float x1, float y1, float depth, int colorArgb) { - BakedGlyph glyph = FlwLibLink.INSTANCE.getFontSet(FONT, Style.DEFAULT_FONT) + BakedGlyph glyph = TextUtil.getFontSet(FONT, Style.DEFAULT_FONT) .whiteGlyph(); GlyphInstance instance = recycler.get(effectKey(glyph, layer)); @@ -243,7 +242,7 @@ public final class TextVisual { } private static GlyphInstanceKey key(TextLayer layer, GlyphInfo glyphInfo, BakedGlyph glyph, boolean bold) { - var glyphExtension = FlwLibLink.INSTANCE.getBakedGlyphExtension(glyph); + var glyphExtension = TextUtil.getBakedGlyphExtension(glyph); float glyphWidth = glyphExtension.flywheel$right() - glyphExtension.flywheel$left(); float glyphHeight = glyphExtension.flywheel$down() - glyphExtension.flywheel$up(); @@ -257,7 +256,7 @@ public final class TextVisual { } private static GlyphInstanceKey effectKey(BakedGlyph glyph, TextLayer layer) { - var glyphExtension = FlwLibLink.INSTANCE.getBakedGlyphExtension(glyph); + var glyphExtension = TextUtil.getBakedGlyphExtension(glyph); return effectKey(glyphExtension.flywheel$texture(), layer.material(), layer.bias()); } diff --git a/common/src/vanillin/java/dev/engine_room/vanillin/visuals/SignVisual.java b/common/src/vanillin/java/dev/engine_room/vanillin/visuals/SignVisual.java index c772bb425..c121bbe1c 100644 --- a/common/src/vanillin/java/dev/engine_room/vanillin/visuals/SignVisual.java +++ b/common/src/vanillin/java/dev/engine_room/vanillin/visuals/SignVisual.java @@ -1,4 +1,4 @@ -package dev.engine_room.flywheel.vanilla; +package dev.engine_room.vanillin.visuals; import java.util.ArrayList; import java.util.List; @@ -15,12 +15,12 @@ import dev.engine_room.flywheel.lib.material.SimpleMaterial; import dev.engine_room.flywheel.lib.model.part.InstanceTree; import dev.engine_room.flywheel.lib.model.part.ModelTree; import dev.engine_room.flywheel.lib.model.part.ModelTrees; -import dev.engine_room.flywheel.lib.util.ResourceReloadCache; +import dev.engine_room.flywheel.lib.util.RendererReloadCache; import dev.engine_room.flywheel.lib.visual.AbstractBlockEntityVisual; import dev.engine_room.flywheel.lib.visual.SimpleDynamicVisual; -import dev.engine_room.flywheel.lib.visual.text.TextLayer; -import dev.engine_room.flywheel.lib.visual.text.TextLayers; -import dev.engine_room.flywheel.lib.visual.text.TextVisual; +import dev.engine_room.vanillin.text.TextLayer; +import dev.engine_room.vanillin.text.TextLayers; +import dev.engine_room.vanillin.text.TextVisual; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.model.geom.ModelLayers; @@ -41,7 +41,7 @@ public class SignVisual extends AbstractBlockEntityVisual imple private static final Vec3 TEXT_OFFSET = new Vec3(0.0, 0.3333333432674408, 0.046666666865348816); private static final Font FONT = Minecraft.getInstance().font; - private static final ResourceReloadCache SIGN_MODELS = new ResourceReloadCache<>(SignVisual::createSignModel); + private static final RendererReloadCache SIGN_MODELS = new RendererReloadCache<>(SignVisual::createSignModel); private static final Material MATERIAL = SimpleMaterial.builder() .cutout(CutoutShaders.ONE_TENTH) diff --git a/common/src/lib/resources/assets/flywheel/flywheel/instance/cull/glyph.glsl b/common/src/vanillin/resources/assets/vanillin/flywheel/instance/cull/glyph.glsl similarity index 100% rename from common/src/lib/resources/assets/flywheel/flywheel/instance/cull/glyph.glsl rename to common/src/vanillin/resources/assets/vanillin/flywheel/instance/cull/glyph.glsl diff --git a/common/src/lib/resources/assets/flywheel/flywheel/instance/glyph.vert b/common/src/vanillin/resources/assets/vanillin/flywheel/instance/glyph.vert similarity index 100% rename from common/src/lib/resources/assets/flywheel/flywheel/instance/glyph.vert rename to common/src/vanillin/resources/assets/vanillin/flywheel/instance/glyph.vert diff --git a/common/src/vanillin/resources/vanillin.mixins.json b/common/src/vanillin/resources/vanillin.mixins.json new file mode 100644 index 000000000..b7f3c9a42 --- /dev/null +++ b/common/src/vanillin/resources/vanillin.mixins.json @@ -0,0 +1,18 @@ +{ + "required" : true, + "minVersion" : "0.8", + "package" : "dev.engine_room.vanillin.mixin", + "compatibilityLevel" : "JAVA_17", + "refmap" : "vanillin.refmap.json", + "client" : [ + "text.BakedGlyphMixin", + "text.CodePointMapMixin", + "text.FontAccessor", + "text.FontSetMixin", + "text.FontTexture$NodeAccessor", + "text.FontTextureMixin" + ], + "injectors" : { + "defaultRequire" : 1 + } +} diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 69e530773..694d7fd08 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -113,9 +113,6 @@ dependencies { modCompileOnly("maven.modrinth:embeddium:${property("embeddium_version")}") - compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.4.1")!!) - implementation(include("io.github.llamalad7:mixinextras-forge:0.4.1")!!) - "forApi"(project(path = common, configuration = "apiClasses")) "forLib"(project(path = common, configuration = "libClasses")) "forBackend"(project(path = common, configuration = "backendClasses")) diff --git a/vanillinFabric/src/main/resources/fabric.mod.json b/vanillinFabric/src/main/resources/fabric.mod.json index 3dd5c0342..38337a4ad 100644 --- a/vanillinFabric/src/main/resources/fabric.mod.json +++ b/vanillinFabric/src/main/resources/fabric.mod.json @@ -22,6 +22,7 @@ ] }, "mixins" : [ + "vanillin.mixins.json" ], "depends" : { "minecraft" : "${minecraft_semver_version_range}", diff --git a/vanillinForge/build.gradle.kts b/vanillinForge/build.gradle.kts index 12df3ba6a..012db41ca 100644 --- a/vanillinForge/build.gradle.kts +++ b/vanillinForge/build.gradle.kts @@ -42,6 +42,10 @@ loom { add(main, "vanillin.refmap.json") } + forge { + mixinConfig("vanillin.mixins.json") + } + runs { configureEach { property("forge.logging.markers", "") @@ -58,6 +62,9 @@ dependencies { compileOnly(project(path = common, configuration = "vanillinClasses")) compileOnly(project(path = common, configuration = "vanillinResources")) + compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.4.1")!!) + implementation(include("io.github.llamalad7:mixinextras-forge:0.4.1")!!) + // JiJ flywheel proper include(project(path = platform, configuration = "flywheelRemap")) runtimeOnly(project(path = platform, configuration = "flywheelDev"))