From a578afaf1cd45d76a2f260f9005eacc07459d20d Mon Sep 17 00:00:00 2001 From: DekinDev Date: Sun, 25 Jan 2026 18:23:55 +0100 Subject: [PATCH] stonnecutter --- build.gradle | 32 +++++++- gradle.properties | 5 +- settings.gradle | 18 ++++- .../resources/template-mod.client.mixins.json | 4 +- .../com/straice/mixin/DoorBlockMixin.java | 73 +++++++++++++++++++ src/main/resources/fabric.mod.json | 9 ++- src/main/resources/template-mod.mixins.json | 5 +- stonecutter.gradle.kts | 4 + versions/1.20/gradle.properties | 2 + 9 files changed, 137 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/straice/mixin/DoorBlockMixin.java create mode 100644 stonecutter.gradle.kts create mode 100644 versions/1.20/gradle.properties diff --git a/build.gradle b/build.gradle index 62156fd..849d5a6 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,10 @@ repositories { // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. // See https://docs.gradle.org/current/userguide/declaring_repositories.html // for more information about repositories. + maven { + name = "TerraformersMC" + url = "https://maven.terraformersmc.com/releases/" + } } loom { @@ -38,6 +42,7 @@ dependencies { // Fabric API. This is technically optional, but you probably want it anyway. modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" + modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}" } @@ -50,7 +55,7 @@ processResources { } tasks.withType(JavaCompile).configureEach { - it.options.release = 21 + it.options.release = 17 } java { @@ -59,8 +64,8 @@ java { // If you remove this line, sources will not be generated. withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } jar { @@ -71,6 +76,25 @@ jar { } } +def modrinthModsDir = providers.environmentVariable("APPDATA") + .map { new File(it, "ModrinthApp/profiles/${project.minecraft_version}/mods") } + +tasks.register("copyRemappedJarToModrinth", Copy) { + dependsOn tasks.named("remapJar") + from(tasks.named("remapJar").flatMap { it.archiveFile }) + into(modrinthModsDir) + + doFirst { + if (!modrinthModsDir.isPresent()) { + throw new GradleException("APPDATA no esta disponible; no se puede resolver la ruta de Modrinth.") + } + } +} + +tasks.named("remapJar") { + finalizedBy(tasks.named("copyRemappedJarToModrinth")) +} + // configure the maven publication publishing { publications { @@ -87,4 +111,4 @@ publishing { // The repositories here will be used for publishing your artifact, not for // retrieving dependencies. } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 190cc96..32fabe1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ org.gradle.configuration-cache=false # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.21.11 +minecraft_version=1.20 loader_version=0.18.4 loom_version=1.14-SNAPSHOT @@ -17,4 +17,5 @@ maven_group=com.straice archives_base_name=template-mod # Dependencies -fabric_api_version=0.141.1+1.21.11 \ No newline at end of file +fabric_api_version=0.83.0+1.20 +modmenu_version=7.0.1 diff --git a/settings.gradle b/settings.gradle index 75c4d72..7109bac 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,7 +4,23 @@ pluginManagement { name = 'Fabric' url = 'https://maven.fabricmc.net/' } + maven { + name = 'KikuGie' + url = 'https://maven.kikugie.dev/releases' + } mavenCentral() gradlePluginPortal() } -} \ No newline at end of file +} + +plugins { + id 'dev.kikugie.stonecutter' version '0.8.3' +} + +stonecutter { + shared { + versions '1.20' + } + + create rootProject +} diff --git a/src/client/resources/template-mod.client.mixins.json b/src/client/resources/template-mod.client.mixins.json index e232005..26d75db 100644 --- a/src/client/resources/template-mod.client.mixins.json +++ b/src/client/resources/template-mod.client.mixins.json @@ -1,11 +1,11 @@ { "required": true, "package": "com.straice.mixin.client", - "compatibilityLevel": "JAVA_21", + "compatibilityLevel": "JAVA_17", "client": [ "ExampleClientMixin" ], "injectors": { "defaultRequire": 1 } -} \ No newline at end of file +} diff --git a/src/main/java/com/straice/mixin/DoorBlockMixin.java b/src/main/java/com/straice/mixin/DoorBlockMixin.java new file mode 100644 index 0000000..d039576 --- /dev/null +++ b/src/main/java/com/straice/mixin/DoorBlockMixin.java @@ -0,0 +1,73 @@ +package com.straice.mixin; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.DoorBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.phys.BlockHitResult; +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(DoorBlock.class) +public class DoorBlockMixin { + @Inject(method = "use", at = @At("RETURN")) + private void smoothdoors$openAdjacentDoor( + BlockState state, + Level level, + BlockPos pos, + Player player, + InteractionHand hand, + BlockHitResult hit, + CallbackInfoReturnable cir + ) { + if (level.isClientSide) { + return; + } + if (!cir.getReturnValue().consumesAction()) { + return; + } + + BlockPos basePos = state.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? pos : pos.below(); + BlockState baseState = level.getBlockState(basePos); + if (!(baseState.getBlock() instanceof DoorBlock)) { + return; + } + + boolean open = baseState.getValue(DoorBlock.OPEN); + Direction facing = baseState.getValue(DoorBlock.FACING); + + openNeighborDoor(level, basePos.relative(facing.getCounterClockWise()), baseState, open, player); + openNeighborDoor(level, basePos.relative(facing.getClockWise()), baseState, open, player); + } + + private static void openNeighborDoor( + Level level, + BlockPos neighborPos, + BlockState baseState, + boolean open, + Player player + ) { + BlockState neighborState = level.getBlockState(neighborPos); + if (neighborState.getBlock() != baseState.getBlock()) { + return; + } + if (neighborState.getValue(DoorBlock.HALF) != DoubleBlockHalf.LOWER) { + return; + } + if (neighborState.getValue(DoorBlock.FACING) != baseState.getValue(DoorBlock.FACING)) { + return; + } + if (neighborState.getValue(DoorBlock.OPEN) == open) { + return; + } + + ((DoorBlock) neighborState.getBlock()).setOpen(player, level, neighborState, neighborPos, open); + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index cc5139b..47119ea 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -31,8 +31,9 @@ ], "depends": { "fabricloader": ">=0.18.4", - "minecraft": "~1.21.11", - "java": ">=21", - "fabric-api": "*" + "minecraft": "~1.20", + "java": ">=17", + "fabric-api": "*", + "modmenu": ">=7.0.1" } -} \ No newline at end of file +} diff --git a/src/main/resources/template-mod.mixins.json b/src/main/resources/template-mod.mixins.json index 63ee472..4e5c87e 100644 --- a/src/main/resources/template-mod.mixins.json +++ b/src/main/resources/template-mod.mixins.json @@ -1,8 +1,9 @@ { "required": true, "package": "com.straice.mixin", - "compatibilityLevel": "JAVA_21", + "compatibilityLevel": "JAVA_17", "mixins": [ + "DoorBlockMixin", "ExampleMixin" ], "injectors": { @@ -11,4 +12,4 @@ "overwrites": { "requireAnnotations": true } -} \ No newline at end of file +} diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts new file mode 100644 index 0000000..a023ece --- /dev/null +++ b/stonecutter.gradle.kts @@ -0,0 +1,4 @@ +plugins { + id("dev.kikugie.stonecutter") +} +stonecutter active "1.20" \ No newline at end of file diff --git a/versions/1.20/gradle.properties b/versions/1.20/gradle.properties new file mode 100644 index 0000000..9fcd909 --- /dev/null +++ b/versions/1.20/gradle.properties @@ -0,0 +1,2 @@ +minecraft_version=1.20 +fabric_api_version=0.83.0+1.20