Skip to content

Commit ab8a0f4

Browse files
committed
Switch to official-like and build on all versions
1 parent 9862816 commit ab8a0f4

File tree

10 files changed

+116
-81
lines changed

10 files changed

+116
-81
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ plugins {
1717

1818
toolkitLoomHelper {
1919
useOneConfig {
20-
version = "1.0.0-alpha.163"
21-
loaderVersion = "1.1.0-alpha.49"
20+
version = "1.0.0-alpha.177"
21+
loaderVersion = "1.1.0-alpha.53"
2222

2323
usePolyMixin = true
2424
polyMixinVersion = "0.8.4+build.7"

gradle.properties

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
1-
# Gradle Configuration -- DO NOT TOUCH THESE VALUES.
2-
polyfrost.defaults.loom=3
3-
org.gradle.daemon=true
4-
org.gradle.parallel=true
5-
org.gradle.configureoncommand=true
6-
org.gradle.parallel.threads=4
7-
org.gradle.jvmargs=-Xmx2G
8-
loom.ignoreDependencyLoomVersionValidation=true
9-
1+
### Mod Properties ###
2+
# The name used to produce your mod's JAR file, also appearing in Bloom processed files and the mod's metadata.
103
mod.name=ColorSaturation
4+
# Your mod's ID, which is used in the mod's metadata and for identifying the mod in the game. Must be unique from other mods.
115
mod.id=colorsaturation
6+
# The version of your mod, which is used in the mod's metadata and for version checks.
127
mod.version=1.1.0-alpha.1
13-
mod.group=org.polyfrost
8+
# The Maven group ID for your mod, which is used in the mod's metadata and for dependency management.
9+
mod.group=org.polyfrost
10+
######################
11+
12+
### DGT Configuration ###
13+
# Switches the mappings for all our versions to use MCP and mojmap.
14+
dgt.loom.mappings=official-like
15+
# Sets the DGT automatic Minecraft dependency list to revision 3. Update this to latest if you want to use the latest recommended versions of libraries.
16+
dgt.minecraft.revision=3
17+
#########################
18+
19+
#####################################################################################
20+
### DO NOT EDIT THE PROPERTIES BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ###
21+
#####################################################################################
22+
23+
### Gradle Configuration ###
24+
# Sets JVM arguments for Gradle to improve performance and stability.
25+
# Adjust memory settings as needed based on your system's capabilities.
26+
# If you're supporting the template's full version range, do not reduce these values any further, they're already quite low.
27+
org.gradle.jvmargs=-Xmx6144m -Dfile.encoding=UTF-8
28+
############################
29+
30+
### Loom Configuration ###
31+
# Allows us to use dependencies built with newer Loom by ignoring that it was built against a differing Loom version.
32+
# This is absolutely necessary because we use an older fork of Loom to enable Legacy Forge support.
33+
# As far as can be seen, there are absolutely no negative side effects to doing this. If you encounter any,
34+
# feel free to report them to the template's issue tracker and comment this line out to see if it resolves them.
35+
# You won't be able to use any dependencies built by newer Loom without this line, however.
36+
loom.ignoreDependencyLoomVersionValidation=true
37+
##########################

src/main/java/org/polyfrost/colorsaturation/mixin/client/Mixin_EntityRenderer_SaturationHandler.java renamed to src/main/java/org/polyfrost/colorsaturation/mixin/client/Mixin_ApplySaturation.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1313

1414
//#if MC >= 1.21.2
15+
//$$ import com.mojang.blaze3d.resource.CrossFrameResourcePool;
1516
//$$ import com.mojang.blaze3d.systems.RenderSystem;
1617
//$$ import dev.deftu.omnicore.api.client.OmniClient;
17-
//$$ import net.minecraft.client.MinecraftClient;
18-
//$$ import net.minecraft.client.util.Pool;
18+
//$$ import net.minecraft.client.Minecraft;
1919
//$$ import org.spongepowered.asm.mixin.Final;
2020
//$$ import org.spongepowered.asm.mixin.Shadow;
2121
//#else
@@ -27,20 +27,18 @@
2727
//#endif
2828

2929
@Mixin(EntityRenderer.class)
30-
public class Mixin_EntityRenderer_SaturationHandler {
30+
public class Mixin_ApplySaturation {
3131
//#if MC >= 1.21.2
32-
//$$ @Shadow private MinecraftClient client;
33-
//$$ @Shadow @Final private Pool pool;
32+
//$$ @Shadow private Minecraft minecraft;
33+
//$$ @Shadow @Final private CrossFrameResourcePool resourcePool;
3434
//#endif
3535

3636
//#if MC < 1.16.5
3737
@Inject(method = "isShaderActive", at = @At("HEAD"), cancellable = true)
3838
private void colorsaturation$cancelShaderActive(CallbackInfoReturnable<Boolean> cir) {
39-
if (!SaturationHandler.isActive()) {
40-
return;
39+
if (SaturationHandler.isActive()) {
40+
cir.setReturnValue(true);
4141
}
42-
43-
cir.setReturnValue(true);
4442
}
4543
//#endif
4644

@@ -54,7 +52,7 @@ public class Mixin_EntityRenderer_SaturationHandler {
5452
//#if MC >= 1.21.2
5553
//$$ at = @At(
5654
//$$ value = "INVOKE",
57-
//$$ target = "Lnet/minecraft/client/render/WorldRenderer;drawEntityOutlinesFramebuffer()V"
55+
//$$ target = "Lnet/minecraft/client/renderer/LevelRenderer;doEntityOutline()V"
5856
//$$ )
5957
//#else
6058
at = @At(
@@ -80,15 +78,15 @@ public class Mixin_EntityRenderer_SaturationHandler {
8078
}
8179

8280
//#if MC >= 1.21.2
83-
//$$ if (!OmniClient.get().isFinishedLoading() || OmniClient.getWorld() == null) {
81+
//$$ if (!OmniClient.get().isGameLoadFinished() || OmniClient.getWorld() == null) {
8482
//$$ return;
8583
//$$ }
8684
//#endif
8785

8886
OmniClientProfiler.withProfiler(OmniClient.get(), "colorsaturation_applier", () -> {
8987
//#if MC >= 1.21.2
9088
//$$ RenderSystem.resetTextureMatrix();
91-
//$$ SaturationHandler.render(this.client.getFramebuffer(), this.pool);
89+
//$$ SaturationHandler.render(this.minecraft.getMainRenderTarget(), this.resourcePool);
9290
//#else
9391
SaturationHandler.update();
9492
float trueTickDelta = OmniRenderTicks.get();

src/main/kotlin/org/polyfrost/colorsaturation/client/SaturationHandler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ package org.polyfrost.colorsaturation.client
33
import dev.deftu.omnicore.api.DEFAULT_NAMESPACE
44
import dev.deftu.omnicore.api.client.client
55
import dev.deftu.omnicore.api.client.render.GlCapabilities
6-
import dev.deftu.omnicore.api.identifierOrThrow
6+
import dev.deftu.omnicore.api.locationOrThrow
77
import net.minecraft.client.shader.ShaderGroup
88
import org.apache.logging.log4j.LogManager
99
import org.polyfrost.oneconfig.internal.mixin.Mixin_ShaderListAccessor
1010

1111
object SaturationHandler {
1212
private val LOGGER = LogManager.getLogger(SaturationHandler::class.java)
1313

14-
private val LOCATION by lazy { identifierOrThrow(DEFAULT_NAMESPACE, "shaders/post/color_saturation.json") }
14+
private val LOCATION by lazy { locationOrThrow(DEFAULT_NAMESPACE, "shaders/post/color_saturation.json") }
1515

1616
private var shader: ShaderGroup? = null
1717
private var prevWidth = 0

src/main/resources/mixins.colorsaturation.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"client.compat.BlurHandlerMixin",
1111
"client.compat.BlurModMixin",
1212
"client.compat.OptifineConfigMixin",
13-
14-
"client.Mixin_EntityRenderer_SaturationHandler"
13+
"client.Mixin_ApplySaturation"
1514
],
1615
"verbose": true
1716
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package org.polyfrost.colorsaturation.client
2+
3+
import com.google.gson.JsonSyntaxException
4+
import com.mojang.blaze3d.framegraph.FrameGraphBuilder
5+
import com.mojang.blaze3d.pipeline.RenderTarget
6+
import com.mojang.blaze3d.resource.CrossFrameResourcePool
7+
import dev.deftu.omnicore.api.client.client
8+
import dev.deftu.omnicore.api.locationOrThrow
9+
import net.minecraft.client.renderer.LevelTargetBundle
10+
import net.minecraft.client.renderer.PostChain
11+
import org.apache.logging.log4j.LogManager
12+
import org.polyfrost.colorsaturation.ColorSaturationConstants
13+
14+
//#if MC >= 1.21.5
15+
//$$ import com.mojang.blaze3d.systems.RenderPass
16+
//$$ import java.util.function.Consumer
17+
//#endif
18+
19+
object SaturationHandler {
20+
private val LOGGER = LogManager.getLogger(SaturationHandler::class.java)
21+
22+
private val LOCATION by lazy { locationOrThrow(ColorSaturationConstants.ID, "color_saturation") }
23+
24+
@JvmStatic
25+
val isActive: Boolean
26+
get() = ColorSaturationConfig.isEnabled
27+
28+
@JvmStatic
29+
fun render(renderTarget: RenderTarget, resourcePool: CrossFrameResourcePool) {
30+
if (!isActive) {
31+
return
32+
}
33+
34+
val shader = try {
35+
client.shaderManager.getPostChain(LOCATION, LevelTargetBundle.MAIN_TARGETS)
36+
} catch (e: JsonSyntaxException) {
37+
LOGGER.error("Could not load motion blur: ", e)
38+
null
39+
}
40+
41+
//#if MC >= 1.21.5
42+
//$$ val consumer = Consumer { renderPass: RenderPass ->
43+
//$$ renderPass.setUniform("Saturation", ColorSaturationConfig.strength)
44+
//$$ }
45+
//#else
46+
shader?.setUniform("Saturation", ColorSaturationConfig.strength)
47+
//#endif
48+
49+
val builder = FrameGraphBuilder()
50+
shader?.addToFrame(
51+
builder,
52+
renderTarget.viewWidth, renderTarget.viewHeight,
53+
PostChain.TargetBundle.of(
54+
PostChain.MAIN_TARGET_ID,
55+
builder.importExternal("main", renderTarget)
56+
),
57+
//#if MC >= 1.21.5
58+
//$$ consumer,
59+
//#endif
60+
)
61+
62+
builder.execute(resourcePool)
63+
}
64+
}

versions/1.21.5-fabric/src/main/resources/assets/colorsaturation/post_effect/color_saturation.json renamed to versions/1.21.4-neoforge/src/main/resources/assets/colorsaturation/post_effect/color_saturation.json

File renamed without changes.

versions/1.21.5-fabric/src/main/resources/assets/colorsaturation/shaders/post/color_saturation.fsh renamed to versions/1.21.4-neoforge/src/main/resources/assets/colorsaturation/shaders/post/color_saturation.fsh

File renamed without changes.

versions/1.21.5-fabric/src/main/kotlin/org/polyfrost/colorsaturation/client/SaturationHandler.kt

Lines changed: 0 additions & 50 deletions
This file was deleted.

versions/1.21.8-neoforge/src/main/kotlin/org/polyfrost/colorsaturation/client/SaturationHandler.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ import com.mojang.blaze3d.shaders.UniformType
99
import com.mojang.blaze3d.systems.RenderSystem
1010
import com.mojang.blaze3d.vertex.DefaultVertexFormat
1111
import com.mojang.blaze3d.vertex.VertexFormat
12-
import dev.deftu.omnicore.api.identifierOrThrow
12+
import dev.deftu.omnicore.api.locationOrThrow
1313
import org.polyfrost.colorsaturation.ColorSaturationConstants
1414
import java.util.OptionalInt
1515
import kotlin.use
1616

1717
object SaturationHandler {
1818
private val pipeline by lazy {
1919
RenderPipeline.builder()
20-
.withLocation(identifierOrThrow(ColorSaturationConstants.ID, "saturation_pipeline"))
20+
.withLocation(locationOrThrow(ColorSaturationConstants.ID, "saturation_pipeline"))
2121
.withVertexShader("core/blit_screen")
22-
.withFragmentShader(identifierOrThrow(ColorSaturationConstants.ID, "post/color_saturation"))
22+
.withFragmentShader(locationOrThrow(ColorSaturationConstants.ID, "post/color_saturation"))
2323
.withVertexFormat(DefaultVertexFormat.POSITION, VertexFormat.Mode.QUADS)
2424
.withDepthWrite(false)
2525
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)

0 commit comments

Comments
 (0)