diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index b1ac613..85024d9 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -39,14 +39,19 @@ jobs: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} - - name: Upload artifacts to Modrinth and GitHub - uses: Kir-Antipov/mc-publish@v3 + - name: Upload artifacts to Modrinth, Curseforge and GitHub + uses: Kir-Antipov/mc-publish@v3.1 with: modrinth-id: 5AgJnN8I modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + curseforge-id: 564870 + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} files: build/libs/!(*-sources).jar - loaders: fabric quilt + loaders: | + fabric + quilt diff --git a/build.gradle b/build.gradle index bf22eb2..1985b7c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { alias(libs.plugins.fabric.loom) + alias(libs.plugins.loom.quiltflower) alias(libs.plugins.grgit) id "maven-publish" } @@ -9,6 +10,14 @@ version = "${project.mod_version}${getMetadata()}" group = project.maven_group repositories { + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + content { + includeGroup "maven.modrinth" + } + } + maven { name = "Quilt" url = "https://maven.quiltmc.org/repository/release" @@ -21,6 +30,7 @@ dependencies { modImplementation libs.fabric.loader modImplementation libs.fabric.api + modCompileOnly libs.sodium } loom { @@ -96,7 +106,7 @@ def getMetadata() { id += "-dirty" } - metadata += "+git.${id}" + metadata += "+${id}" } return metadata diff --git a/gradle.properties b/gradle.properties index aa96e3d..1971b31 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ # Gradle Properties -org.gradle.jvmargs=-Xmx2G -org.gradle.parallel=true +org.gradle.jvmargs = -Xmx1G +org.gradle.parallel = true # Mod Properties -mod_version=1.0.12 +mod_version=1.0.8 maven_group=me.tibinonest.mods archives_base_name=cauldron-dyeing diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 455bab0..5430e70 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,12 +1,10 @@ [versions] -minecraft = "1.20.3" -quilt_mappings = "1.20.3+build.3" -fabric_loader = "0.15.3" +minecraft = "1.19.3" +quilt_mappings = "1.19.3+build.23" +fabric_loader = "0.14.14" -fabric_api = "0.91.1+1.20.3" - -fabric_loom = "1.4.+" -grgit = "5.2.+" +fabric_api = "0.73.2+1.19.3" +sodium = "mc1.19.3-0.4.9" [libraries] minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } @@ -14,7 +12,9 @@ quilt_mappings = { module = "org.quiltmc:quilt-mappings", version.ref = "quilt_m fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric_loader" } fabric_api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric_api" } +sodium = { module = "maven.modrinth:sodium", version.ref = "sodium" } [plugins] -fabric_loom = { id = "fabric-loom", version.ref = "fabric_loom" } -grgit = { id = "org.ajoberstar.grgit", version.ref = "grgit" } +fabric_loom = { id = "fabric-loom", version = "1.1.+" } +loom_quiltflower = { id = "io.github.juuxel.loom-quiltflower", version = "1.8.+" } +grgit = { id = "org.ajoberstar.grgit", version = "5.+" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd49..249e583 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e09..070cb70 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip -networkTimeout=10000 -validateDistributionUrl=true +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1aa94a4..a69d9cb 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,11 +80,13 @@ do esac done -# This is normally unused -# shellcheck disable=SC2034 +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -131,29 +133,22 @@ location of your Java installation." fi else JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." - fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -198,15 +193,11 @@ if "$cygwin" || "$msys" ; then done fi - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..f127cfd 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,7 +26,6 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/src/main/java/me/tibinonest/mods/cauldron_dyeing/CauldronDyeing.java b/src/main/java/me/tibinonest/mods/cauldron_dyeing/CauldronDyeing.java index a466188..e25b773 100644 --- a/src/main/java/me/tibinonest/mods/cauldron_dyeing/CauldronDyeing.java +++ b/src/main/java/me/tibinonest/mods/cauldron_dyeing/CauldronDyeing.java @@ -8,12 +8,10 @@ import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityT import net.minecraft.block.Blocks; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.color.world.BiomeColors; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockRenderView; public class CauldronDyeing implements ModInitializer { public static final String MOD_ID = "cauldron_dyeing"; @@ -25,16 +23,6 @@ public class CauldronDyeing implements ModInitializer { Registry.register(Registries.BLOCK_ENTITY_TYPE, new Identifier(MOD_ID, "water_cauldron_entity"), WATER_CAULDRON_BLOCK_ENTITY); } - @Environment(EnvType.CLIENT) - public static int getColor(BlockRenderView world, BlockPos pos) { - var blockEntity = world.getBlockEntity(pos); - if (blockEntity instanceof WaterCauldronBlockEntity waterCauldron && waterCauldron.getColor() != -1) { - return waterCauldron.getColor(); - } - - return BiomeColors.getWaterColor(world, pos); - } - @Environment(EnvType.CLIENT) public static void rebuildBlock(BlockPos pos) { MinecraftClient.getInstance().worldRenderer.scheduleBlockRenders(pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ()); diff --git a/src/main/java/me/tibinonest/mods/cauldron_dyeing/block/WaterCauldronBlockEntity.java b/src/main/java/me/tibinonest/mods/cauldron_dyeing/block/WaterCauldronBlockEntity.java index 5e6678f..49d7017 100644 --- a/src/main/java/me/tibinonest/mods/cauldron_dyeing/block/WaterCauldronBlockEntity.java +++ b/src/main/java/me/tibinonest/mods/cauldron_dyeing/block/WaterCauldronBlockEntity.java @@ -5,8 +5,8 @@ import me.tibinonest.mods.cauldron_dyeing.CauldronDyeing; import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.nbt.NbtCompound; +import net.minecraft.network.Packet; import net.minecraft.network.listener.ClientPlayPacketListener; -import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.DyeColor; @@ -16,7 +16,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Arrays; public class WaterCauldronBlockEntity extends BlockEntity { - private static final int[] NULL_COLOR = new int[] {-1, -1, -1}; + private final int[] NULL_COLOR = new int[] {-1, -1, -1}; private int[] color = NULL_COLOR; public WaterCauldronBlockEntity(BlockPos pos, BlockState state) { diff --git a/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/AbstractCauldronBlockMixin.java b/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/AbstractCauldronBlockMixin.java index 47faca6..e9d1349 100644 --- a/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/AbstractCauldronBlockMixin.java +++ b/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/AbstractCauldronBlockMixin.java @@ -1,9 +1,9 @@ package me.tibinonest.mods.cauldron_dyeing.mixin; import me.tibinonest.mods.cauldron_dyeing.block.WaterCauldronBlockEntity; +import net.minecraft.block.AbstractCauldronBlock; import net.minecraft.block.BlockEntityProvider; import net.minecraft.block.BlockState; -import net.minecraft.block.cauldron.AbstractCauldronBlock; import net.minecraft.block.entity.BlockEntity; import net.minecraft.fluid.Fluids; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/BiomeColorsMixin.java b/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/BiomeColorsMixin.java new file mode 100644 index 0000000..175709f --- /dev/null +++ b/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/BiomeColorsMixin.java @@ -0,0 +1,22 @@ +package me.tibinonest.mods.cauldron_dyeing.mixin; + +import me.tibinonest.mods.cauldron_dyeing.block.WaterCauldronBlockEntity; +import net.minecraft.client.color.world.BiomeColors; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.BlockRenderView; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(BiomeColors.class) +public class BiomeColorsMixin { + @Inject(method = "getWaterColor", at = @At("HEAD"), cancellable = true) + private static void cauldron_dyeing$modifyWaterColor(BlockRenderView world, BlockPos pos, CallbackInfoReturnable cir) { + var blockEntity = world.getBlockEntity(pos); + + if (blockEntity instanceof WaterCauldronBlockEntity waterCauldron && waterCauldron.getColor() != -1) { + cir.setReturnValue(waterCauldron.getColor()); + } + } +} diff --git a/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/BlockColorsMixin.java b/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/BlockColorsMixin.java deleted file mode 100644 index 9e98780..0000000 --- a/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/BlockColorsMixin.java +++ /dev/null @@ -1,18 +0,0 @@ -package me.tibinonest.mods.cauldron_dyeing.mixin; - -import me.tibinonest.mods.cauldron_dyeing.CauldronDyeing; -import net.minecraft.block.Blocks; -import net.minecraft.client.color.block.BlockColors; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -@Mixin(BlockColors.class) -public class BlockColorsMixin { - @Inject(method = "create", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD) - private static void cauldron_dyeing$modifyCreate(CallbackInfoReturnable cir, BlockColors blockColors) { - blockColors.registerColorProvider((state, world, pos, tintIndex) -> world != null && pos != null ? CauldronDyeing.getColor(world, pos) : -1, Blocks.WATER_CAULDRON); - } -} diff --git a/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/CauldronBehaviorMixin.java b/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/CauldronBehaviorMixin.java index aff0684..78e570c 100644 --- a/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/CauldronBehaviorMixin.java +++ b/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/CauldronBehaviorMixin.java @@ -3,8 +3,8 @@ package me.tibinonest.mods.cauldron_dyeing.mixin; import me.tibinonest.mods.cauldron_dyeing.block.CauldronBehaviorExtended; import me.tibinonest.mods.cauldron_dyeing.block.WaterCauldronBlockEntity; import net.minecraft.block.BlockState; +import net.minecraft.block.LeveledCauldronBlock; import net.minecraft.block.cauldron.CauldronBehavior; -import net.minecraft.block.cauldron.LeveledCauldronBlock; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.DyeItem; import net.minecraft.item.DyeableItem; @@ -26,7 +26,7 @@ import java.util.Map; @Mixin(CauldronBehavior.class) public interface CauldronBehaviorMixin { @SuppressWarnings("target") - @Inject(method = "method_32209", at = @At("HEAD"), cancellable = true) + @Inject(method = "m_ducbhfos(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/util/ActionResult;", at = @At("HEAD"), cancellable = true) private static void cauldron_dyeing$injectCleanDyeableItem(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, ItemStack stack, CallbackInfoReturnable cir) { var blockEntity = world.getBlockEntity(pos); var item = stack.getItem(); @@ -43,7 +43,7 @@ public interface CauldronBehaviorMixin { } @SuppressWarnings("target") - @Inject(method = "method_32217", at = @At("TAIL")) + @Inject(method = "m_xrdlazrh(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/util/ActionResult;", at = @At(value = "TAIL")) private static void cauldron_dyeing$injectFillWithWater(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, ItemStack stack, CallbackInfoReturnable cir) { var blockEntity = world.getBlockEntity(pos); if (blockEntity instanceof WaterCauldronBlockEntity waterCauldron) { @@ -54,7 +54,7 @@ public interface CauldronBehaviorMixin { @Inject(method = "registerBehavior", at = @At("TAIL")) private static void cauldron_dyeing$injectRegisterBehavior(CallbackInfo ci) { for (Map.Entry dyeItem : DyeItem.DYES.entrySet()) { - CauldronBehavior.WATER_CAULDRON_BEHAVIOR.map().put(dyeItem.getValue(), CauldronBehaviorExtended.DYE_WATER); + CauldronBehavior.WATER_CAULDRON_BEHAVIOR.put(dyeItem.getValue(), CauldronBehaviorExtended.DYE_WATER); } } } diff --git a/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/sodium/SodiumBlockRendererMixin.java b/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/sodium/SodiumBlockRendererMixin.java new file mode 100644 index 0000000..9d45b0f --- /dev/null +++ b/src/main/java/me/tibinonest/mods/cauldron_dyeing/mixin/sodium/SodiumBlockRendererMixin.java @@ -0,0 +1,27 @@ +package me.tibinonest.mods.cauldron_dyeing.mixin.sodium; + +import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView; +import me.jellysquid.mods.sodium.client.model.quad.blender.ColorBlender; +import me.jellysquid.mods.sodium.client.model.quad.blender.ColorSampler; +import me.jellysquid.mods.sodium.client.model.quad.blender.FlatColorBlender; +import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; +import me.tibinonest.mods.cauldron_dyeing.block.WaterCauldronBlockEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.BlockRenderView; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(BlockRenderer.class) +public class SodiumBlockRendererMixin { + @Redirect(method = "renderQuadList", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/model/quad/blender/ColorBlender;getColors(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/util/math/BlockPos;Lme/jellysquid/mods/sodium/client/model/quad/ModelQuadView;Lme/jellysquid/mods/sodium/client/model/quad/blender/ColorSampler;Ljava/lang/Object;)[I")) + private int[] cauldron_dyeing$redirectGetColors(ColorBlender instance, BlockRenderView world, BlockPos pos, ModelQuadView quad, ColorSampler sampler, T state) { + var blockEntity = world.getBlockEntity(pos); + + if (blockEntity instanceof WaterCauldronBlockEntity) { + return new FlatColorBlender().getColors(world, pos, quad, sampler, state); + } + + return instance.getColors(world, pos, quad, sampler, state); + } +} diff --git a/src/main/resources/cauldron-dyeing.accesswidener b/src/main/resources/cauldron-dyeing.accesswidener index d48d1c3..babbc75 100644 --- a/src/main/resources/cauldron-dyeing.accesswidener +++ b/src/main/resources/cauldron-dyeing.accesswidener @@ -1,5 +1,5 @@ accessWidener v1 named -accessible method net/minecraft/block/cauldron/AbstractCauldronBlock canBeFilledByDripstone (Lnet/minecraft/fluid/Fluid;)Z +accessible method net/minecraft/block/AbstractCauldronBlock canBeFilledByDripstone (Lnet/minecraft/fluid/Fluid;)Z accessible field net/minecraft/item/DyeItem DYES Ljava/util/Map; diff --git a/src/main/resources/cauldron-dyeing.mixins.json b/src/main/resources/cauldron-dyeing.mixins.json index b424eb0..8e1946a 100644 --- a/src/main/resources/cauldron-dyeing.mixins.json +++ b/src/main/resources/cauldron-dyeing.mixins.json @@ -7,7 +7,8 @@ "CauldronBehaviorMixin" ], "client": [ - "BlockColorsMixin" + "BiomeColorsMixin", + "sodium.SodiumBlockRendererMixin" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2f7e512..3d11930 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -24,8 +24,11 @@ "cauldron-dyeing.mixins.json" ], "depends": { - "minecraft": ">=1.20.3", + "minecraft": ">=1.19.3", "fabricloader": ">=0.12.0", "fabric-object-builder-api-v1": ">=0.1" + }, + "breaks": { + "sodium": "<0.4.9" } }