From 4771a7ae5a62610fe8d50e422fd80d8ca49db167 Mon Sep 17 00:00:00 2001 From: 3TUSK Date: Mon, 19 Jun 2023 14:55:19 -0700 Subject: [PATCH] GH-33: SlideRenderType is now a CompositeRenderType --- build.gradle | 10 ++- gradle/teacon-forge.gradle | 6 ++ .../java/org/teacon/slides/ModRegistries.java | 2 +- .../slides/renderer/SlideRenderType.java | 90 +++++++++++++++---- .../resources/META-INF/accesstransformer.cfg | 3 + 5 files changed, 91 insertions(+), 20 deletions(-) create mode 100644 src/main/resources/META-INF/accesstransformer.cfg diff --git a/build.gradle b/build.gradle index 754fd67..59e020c 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(17) teacon { modId = 'slide_show' modVersion = '0.8.0' - modLicense = 'BSD-3-Clause' + modLicense = 'LGPL-3.0-only' modGitHubRepo = 'teaconmc/SlideShow' modAuthors = ['BloCamLimb', '3TUSK', 'ustc-zzzz'] modDescription = 'Minecraft mod, adding a projector that can display online images.' @@ -24,7 +24,7 @@ teacon { // uncomment these lines if you need modName = 'Slide Show' // default to repo name // modGitHubBranch = 1.18-forge // for referring the license - // modifyMemberAccess = true // for access transformer + modifyMemberAccess = true // for access transformer // useDataGeneration = true // for data generation publishTask = shadowJar // for shadow jar or other usages lazyTokens = ['minecraft_classpath': { (project.configurations.shadow - project.configurations.minecraft).asPath }] // for runtime tokens @@ -39,6 +39,10 @@ configurations { repositories { maven { url 'https://jitpack.io' } + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + } } dependencies { @@ -46,6 +50,8 @@ dependencies { shadow 'net.objecthunter:exp4j:0.4.8' shadow 'com.machinezoo.noexception:noexception:1.7.1' shadow 'org.apache.httpcomponents:httpclient-cache:4.5.13' + + runtimeOnly fg.deobf("maven.modrinth:oculus:HxUtDCCe") // 1.20-1.6.4 } shadowJar { diff --git a/gradle/teacon-forge.gradle b/gradle/teacon-forge.gradle index ecb23c2..6b4242b 100644 --- a/gradle/teacon-forge.gradle +++ b/gradle/teacon-forge.gradle @@ -88,6 +88,8 @@ gradle.afterProject { Project current -> // noinspection GroovyAssignabilityCheck create(modId) { it.source sourceSets.main } } + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" // noinspection GroovyAssignabilityCheck runtimeLazyTokens.each { k, v -> lazyToken(k, v) } } @@ -101,6 +103,8 @@ gradle.afterProject { Project current -> // noinspection GroovyAssignabilityCheck create(modId) { it.source sourceSets.main } } + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" // noinspection GroovyAssignabilityCheck runtimeLazyTokens.each { k, v -> lazyToken(k, v) } } @@ -114,6 +118,8 @@ gradle.afterProject { Project current -> // noinspection GroovyAssignabilityCheck create(modId) { it.source sourceSets.main } } + property 'mixin.env.remapRefMap', 'true' + property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" // noinspection GroovyAssignabilityCheck runtimeLazyTokens.each { k, v -> lazyToken(k, v) } } diff --git a/src/main/java/org/teacon/slides/ModRegistries.java b/src/main/java/org/teacon/slides/ModRegistries.java index d20fc28..75f8c13 100644 --- a/src/main/java/org/teacon/slides/ModRegistries.java +++ b/src/main/java/org/teacon/slides/ModRegistries.java @@ -33,7 +33,7 @@ @FieldsAreNonnullByDefault @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = SlideShow.ID) public final class ModRegistries { /** * The networking channel version. Since we follow SemVer, this is diff --git a/src/main/java/org/teacon/slides/renderer/SlideRenderType.java b/src/main/java/org/teacon/slides/renderer/SlideRenderType.java index c3095ab..fce3758 100644 --- a/src/main/java/org/teacon/slides/renderer/SlideRenderType.java +++ b/src/main/java/org/teacon/slides/renderer/SlideRenderType.java @@ -11,7 +11,7 @@ /** * @author BloCamLimb */ -public final class SlideRenderType extends RenderType { +public final class SlideRenderType extends RenderType.CompositeRenderType { private static ShaderInstance sPaletteSlideShader; private static final ShaderStateShard @@ -52,32 +52,88 @@ public final class SlideRenderType extends RenderType { public SlideRenderType(int texture) { super(SlideShow.ID, DefaultVertexFormat.BLOCK, VertexFormat.Mode.QUADS, 256, false, true, - () -> { - GENERAL_STATES.forEach(RenderStateShard::setupRenderState); - RenderSystem.setShaderTexture(0, texture); - }, - () -> GENERAL_STATES.forEach(RenderStateShard::clearRenderState)); + CompositeState.builder() + .setShaderState(RENDERTYPE_TEXT_SEE_THROUGH_SHADER) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setDepthTestState(LEQUAL_DEPTH_TEST) + .setCullState(CULL) + .setLightmapState(LIGHTMAP) + .setOverlayState(NO_OVERLAY) + .setLayeringState(NO_LAYERING) + .setOutputState(MAIN_TARGET) + .setTexturingState(DEFAULT_TEXTURING) + .setWriteMaskState(COLOR_DEPTH_WRITE) + .setLineState(DEFAULT_LINE) + .createCompositeState(true) + ); + var baseSetup = this.setupState; + this.setupState = () -> { + baseSetup.run(); + RenderSystem.setShaderTexture(0, texture); + }; +// () -> { +// GENERAL_STATES.forEach(RenderStateShard::setupRenderState); +// RenderSystem.setShaderTexture(0, texture); +// }, +// () -> GENERAL_STATES.forEach(RenderStateShard::clearRenderState)); } public SlideRenderType(int imageTexture, int paletteTexture) { super(SlideShow.ID + "_palette", DefaultVertexFormat.BLOCK, VertexFormat.Mode.QUADS, 256, false, true, - () -> { - PALETTE_STATES.forEach(RenderStateShard::setupRenderState); - RenderSystem.setShaderTexture(0, imageTexture); - RenderSystem.setShaderTexture(3, paletteTexture); - }, - () -> GENERAL_STATES.forEach(RenderStateShard::clearRenderState)); + CompositeState.builder() + .setShaderState(RENDERTYPE_PALETTE_SLIDE) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setDepthTestState(LEQUAL_DEPTH_TEST) + .setCullState(CULL) + .setLightmapState(LIGHTMAP) + .setOverlayState(NO_OVERLAY) + .setLayeringState(NO_LAYERING) + .setOutputState(MAIN_TARGET) + .setTexturingState(DEFAULT_TEXTURING) + .setWriteMaskState(COLOR_DEPTH_WRITE) + .setLineState(DEFAULT_LINE) + .createCompositeState(true)); + var baseSetup = this.setupState; + this.setupState = () -> { + baseSetup.run(); + RenderSystem.setShaderTexture(0, imageTexture); + RenderSystem.setShaderTexture(3, paletteTexture); + }; +// () -> { +// PALETTE_STATES.forEach(RenderStateShard::setupRenderState); +// RenderSystem.setShaderTexture(0, imageTexture); +// RenderSystem.setShaderTexture(3, paletteTexture); +// }, +// () -> GENERAL_STATES.forEach(RenderStateShard::clearRenderState)); } public SlideRenderType(ResourceLocation texture) { super(SlideShow.ID + "_icon", DefaultVertexFormat.BLOCK, VertexFormat.Mode.QUADS, 256, false, true, - () -> { - GENERAL_STATES.forEach(RenderStateShard::setupRenderState); - RenderSystem.setShaderTexture(0, texture); - }, - () -> GENERAL_STATES.forEach(RenderStateShard::clearRenderState)); + CompositeState.builder() + .setShaderState(RENDERTYPE_TEXT_SEE_THROUGH_SHADER) + .setTransparencyState(TRANSLUCENT_TRANSPARENCY) + .setDepthTestState(LEQUAL_DEPTH_TEST) + .setCullState(CULL) + .setLightmapState(LIGHTMAP) + .setOverlayState(NO_OVERLAY) + .setLayeringState(NO_LAYERING) + .setOutputState(MAIN_TARGET) + .setTexturingState(DEFAULT_TEXTURING) + .setWriteMaskState(COLOR_DEPTH_WRITE) + .setLineState(DEFAULT_LINE) + .createCompositeState(true)); + var baseSetup = this.setupState; + this.setupState = () -> { + baseSetup.run(); + RenderSystem.setShaderTexture(0, texture); + }; +// () -> { +// GENERAL_STATES.forEach(RenderStateShard::setupRenderState); +// RenderSystem.setShaderTexture(0, texture); +// }, +// () -> GENERAL_STATES.forEach(RenderStateShard::clearRenderState)); } @Override diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..5de0823 --- /dev/null +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1,3 @@ +public-f net.minecraft.client.renderer.RenderType$CompositeRenderType + +protected net.minecraft.client.renderer.RenderType$CompositeRenderType (Ljava/lang/String;Lcom/mojang/blaze3d/vertex/VertexFormat;Lcom/mojang/blaze3d/vertex/VertexFormat$Mode;IZZLnet/minecraft/client/renderer/RenderType$CompositeState;)V \ No newline at end of file