stonnecutter

This commit is contained in:
2026-01-25 18:23:55 +01:00
parent 85af209c28
commit a578afaf1c
9 changed files with 137 additions and 15 deletions

View File

@@ -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 {

View File

@@ -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
fabric_api_version=0.83.0+1.20
modmenu_version=7.0.1

View File

@@ -4,7 +4,23 @@ pluginManagement {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'KikuGie'
url = 'https://maven.kikugie.dev/releases'
}
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id 'dev.kikugie.stonecutter' version '0.8.3'
}
stonecutter {
shared {
versions '1.20'
}
create rootProject
}

View File

@@ -1,7 +1,7 @@
{
"required": true,
"package": "com.straice.mixin.client",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"client": [
"ExampleClientMixin"
],

View File

@@ -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<InteractionResult> 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);
}
}

View File

@@ -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"
}
}

View File

@@ -1,8 +1,9 @@
{
"required": true,
"package": "com.straice.mixin",
"compatibilityLevel": "JAVA_21",
"compatibilityLevel": "JAVA_17",
"mixins": [
"DoorBlockMixin",
"ExampleMixin"
],
"injectors": {

4
stonecutter.gradle.kts Normal file
View File

@@ -0,0 +1,4 @@
plugins {
id("dev.kikugie.stonecutter")
}
stonecutter active "1.20"

View File

@@ -0,0 +1,2 @@
minecraft_version=1.20
fabric_api_version=0.83.0+1.20