diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3050cb..e0107c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,14 +4,36 @@ on: [ push, pull_request ] jobs: build: - uses: constellation-mc/actions/.github/workflows/gradle-build.yml@main - with: - java: 21 - gradle_tasks: spotbugs - reviewdog: | - cat ./build/reports/spotbugs/main/spotbugs.sarif | reviewdog -name="spotbugs" -f=sarif -reporter=github-check -level=warning - - run_tests: - uses: constellation-mc/actions/.github/workflows/mc-tests.yml@main - with: - java: 21 \ No newline at end of file + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: gradle/actions/wrapper-validation@v5.0.0 + - name: Setup Java + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: temurin + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v5.0.0 + - name: Build project + run: ./gradlew buildAndCollect + - name: Find jars + id: find_jars + run: | + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) + echo "jars<<$EOF" >> $GITHUB_OUTPUT + find ./build/libs/ -type f -name "*.jar" ! -name "*-sources.jar" >> $GITHUB_OUTPUT + echo "$EOF" >> $GITHUB_OUTPUT + - name: Get MC version and mod version + uses: christian-draeger/read-properties@1.1.1 + id: read_properties + with: + path: gradle.properties + properties: 'mod_version' + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: linkart-refabricated-${{ steps.read_properties.outputs.mod_version }}+build.${{ github.run_number }} + path: ${{ steps.find_jars.outputs.jars }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 31aa8cd..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,23 +0,0 @@ - -name: publish -on: - workflow_dispatch: - inputs: - version_type: - description: "The type of this version. e.g alpha" - type: choice - default: BETA - options: - - STABLE - - BETA - - ALPHA - - NONE - required: false - -jobs: - publish: - uses: constellation-mc/actions/.github/workflows/mc-publish.yml@main - with: - java: 21 - version_type: ${{ inputs.version_type }} - secrets: inherit \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c2b24f6..7272a72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed +- Added support for 1.21.6-1.21.10 +- Updated Stonecutter to 0.7.10 + ## [6.1.1] - 2025-5-18 ### Changed diff --git a/build.gradle b/build.gradle index ddbc0c2..1dd00e5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,6 @@ -import com.github.spotbugs.snom.SpotBugsTask - plugins { - id 'fabric-loom' version '1.10-SNAPSHOT' + id 'fabric-loom' version '1.12-SNAPSHOT' id 'maven-publish' - id 'io.freefair.lombok' version '8.6' - id 'com.github.spotbugs-base' version '6.0.14' - //id 'com.diffplug.spotless' version '6.25.0' id 'me.modmuss50.mod-publish-plugin' version "0.5.1" } @@ -37,36 +32,6 @@ base { archivesName = "linkart-refabricated" } -tasks.register("spotbugs", SpotBugsTask) { task -> - sourceSets.each { - task.sourceDirs.from(task.sourceDirs.files, it.allSource.sourceDirectories) - task.classDirs.from(task.classDirs.files, it.output) - task.auxClassPaths.from(task.auxClassPaths.files, it.compileClasspath) - } - excludeFilter = rootProject.file("spotbugs.xml") - ignoreFailures = true - reports { - html { - required = true - outputLocation = rootProject.file("${rootProject.buildDir}/reports/spotbugs/main/spotbugs.html") - stylesheet = 'fancy-hist.xsl' - } - sarif { - required = true - outputLocation = rootProject.file("${rootProject.buildDir}/reports/spotbugs/main/spotbugs.sarif") - } - } -} - -/*spotless { - java { - removeUnusedImports() - trimTrailingWhitespace() - formatAnnotations() - importOrder('', 'java|javax', '\\#') - } -}*/ - processResources { inputs.property "minecraft", mcVersion inputs.property "version", mod_version @@ -88,6 +53,8 @@ loom { ideConfigGenerated true // Run configurations are not created for subprojects by default runDir "../../run" // Use a shared run folder and create separate worlds } + + fabricModJsonPath = rootProject.file("src/main/resources/fabric.mod.json") } def targetJavaVersion = 17 @@ -110,77 +77,18 @@ java { withSourcesJar() } -jar { - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}" } - } -} - -sourcesJar { - exclude { - sourceSets.main.allSource.contains it.file - } - from delombok -} +tasks.register('buildAndCollect', Copy) { + group = 'build' -/* -// configure the maven publication -publishing { - publications { - mavenJava(MavenPublication) { - artifactId 'linkart' - from components.java - } - } + from(tasks.named('remapJar').flatMap { it.archiveFile }) + from(tasks.named('remapSourcesJar').flatMap { it.archiveFile }) + into rootProject.layout.buildDirectory.dir("libs/${project.mod_version}").get().asFile - repositories { - maven { - name = "GitHubPackages" - url = "https://maven.pkg.github.com/constellation-mc/Linkart" - credentials { - username = System.getenv("GITHUB_ACTOR") - password = System.getenv("GITHUB_TOKEN") - } - } - } + dependsOn 'build' } -publishMods { - file = remapJar.archiveFile - additionalFiles.from(remapSourcesJar.archiveFile) - - changelog = file("CHANGELOG.md").text - type = ReleaseType.valueOf(providers.environmentVariable("VERSION_TYPE").getOrElse("BETA")) - modLoaders.add("fabric") - - displayName = "${project.mod_version} (${project.minecraft_version})" - - modrinth { - projectId = "sc4Mu9Zu" - accessToken = providers.environmentVariable("MODRINTH_TOKEN") - minecraftVersions.add("${project.minecraft_version}") - minecraftVersions.add("1.21") - - requires("fabric-api") - embeds("midnightlib") - } - curseforge { - projectId = "622736" - accessToken = providers.environmentVariable("CURSEFORGE_TOKEN") - minecraftVersions.add("${project.minecraft_version}") - minecraftVersions.add("1.21") - - requires("fabric-api") - embeds("midnightlib") - } - github { - repository = "constellation-mc/Linkart" - accessToken = providers.environmentVariable("GITHUB_TOKEN") - commitish = providers.environmentVariable("GITHUB_SHA").getOrElse("${project.minecraft_version}-fabric") - - type = STABLE +jar { + from("LICENSE") { + rename { "${it}_${project.archivesBaseName}" } } - - dryRun = local -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 35c82a1..4f4097b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ # Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G +org.gradle.jvmargs=-Xmx3G # Fabric Properties # check these on https://fabricmc.net/versions.html minecraft_version=[VERSIONED] -fabric_loader=0.16.13 +fabric_loader=0.17.0 yarn_mappings=[VERSIONED] fabric_api=[VERSIONED] midnightlib_version =[VERSIONED] @@ -11,4 +11,3 @@ midnightlib_version =[VERSIONED] mod_version=6.1.1 maven_group=com.github.vini2003.linkart archives_base_name=linkart -; \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cea7a79..ca025c8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index c508c69..322f1e4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -9,12 +9,12 @@ pluginManagement { } plugins { - id "dev.kikugie.stonecutter" version "0.7.6" + id "dev.kikugie.stonecutter" version "0.7.10" } stonecutter { create(rootProject) { - versions "1.21.1", "1.21.4", "1.21.5", "1.21.6", "1.21.7", "1.21.8" + versions "1.21.1", "1.21.4", "1.21.5", "1.21.6", "1.21.7", "1.21.8", "1.21.9", "1.21.10" vcsVersion = "1.21.1" } } \ No newline at end of file diff --git a/src/main/java/com/github/vini2003/linkart/mixin/AbstractMinecartEntityMixin.java b/src/main/java/com/github/vini2003/linkart/mixin/AbstractMinecartEntityMixin.java index 4c33da1..e88f0d9 100644 --- a/src/main/java/com/github/vini2003/linkart/mixin/AbstractMinecartEntityMixin.java +++ b/src/main/java/com/github/vini2003/linkart/mixin/AbstractMinecartEntityMixin.java @@ -113,12 +113,13 @@ private Vec3d modifiedMovement(Vec3d movement) { @Inject(at = @At("HEAD"), method = "tick") private void linkart$tick(CallbackInfo ci) { - if (getWorld().isClient()) return; + World world = /*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/; + if (world.isClient()) return; AbstractMinecartEntity cast = (AbstractMinecartEntity) (Object) this; if (linkart$getFollowing() == null) return; - Vec3d pos = getPos(); - Vec3d pos2 = linkart$getFollowing().getPos(); + Vec3d pos = /*? if >=1.21.9 {*//*getEntityPos()*//*?} else {*/getPos()/*?}*/; + Vec3d pos2 = linkart$getFollowing()./*? if >=1.21.9 {*//*getEntityPos()*//*?} else {*/getPos()/*?}*/; double dist = Math.max(Math.abs(pos.distanceTo(pos2)) - LinkartConfiguration.distance, 0); Vec3d vec3d = pos.relativize(pos2); vec3d = vec3d.multiply(LinkartConfiguration.velocityMultiplier); @@ -153,10 +154,10 @@ private Vec3d modifiedMovement(Vec3d movement) { if (LinkartConfiguration.chunkloading) { if (linkart$getFollower() != null && !CartUtils.approximatelyZero(this.getVelocity().length())) { - ((ServerWorld) this.getWorld()).getChunkManager().addTicket(ChunkTicketType.PORTAL, this.getChunkPos(), LinkartConfiguration.chunkloadingRadius/*? if <1.21.5 {*/, this.getBlockPos()/*?}*/); - LoadingCarts.getOrCreate((ServerWorld) getWorld()).addCart(cast); + ((ServerWorld) world).getChunkManager().addTicket(ChunkTicketType.PORTAL, this.getChunkPos(), LinkartConfiguration.chunkloadingRadius/*? if <1.21.5 {*/, this.getBlockPos()/*?}*/); + LoadingCarts.getOrCreate((ServerWorld) world).addCart(cast); } else { - LoadingCarts.getOrCreate((ServerWorld) getWorld()).removeCart(cast); + LoadingCarts.getOrCreate((ServerWorld) world).removeCart(cast); } } } @@ -208,7 +209,7 @@ void onPushAway(Entity entity, CallbackInfo ci) { @Override public AbstractMinecartEntity linkart$getFollowing() { if (linkart$following == null && linkart$followingUUID != null) { - linkart$following = (AbstractMinecartEntity) ((ServerWorld) this.getWorld()).getEntity(linkart$followingUUID); + linkart$following = (AbstractMinecartEntity) ((ServerWorld) this./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/).getEntity(linkart$followingUUID); } return linkart$following; } @@ -222,7 +223,7 @@ void onPushAway(Entity entity, CallbackInfo ci) { @Override public AbstractMinecartEntity linkart$getFollower() { if (linkart$follower == null && linkart$followerUUID != null) { - linkart$follower = (AbstractMinecartEntity) ((ServerWorld) this.getWorld()).getEntity(linkart$followerUUID); + linkart$follower = (AbstractMinecartEntity) ((ServerWorld) this./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/).getEntity(linkart$followerUUID); } return linkart$follower; } diff --git a/src/main/java/com/github/vini2003/linkart/mixin/EntityMixin.java b/src/main/java/com/github/vini2003/linkart/mixin/EntityMixin.java index 8e3a977..bb2c0a7 100644 --- a/src/main/java/com/github/vini2003/linkart/mixin/EntityMixin.java +++ b/src/main/java/com/github/vini2003/linkart/mixin/EntityMixin.java @@ -20,7 +20,7 @@ public abstract class EntityMixin { @Inject(at = @At("HEAD"), method = "remove") void linkart$removeLink(CallbackInfo callbackInformation, @Local(argsOnly = true) Entity.RemovalReason reason) { - if ((Entity) (Object) this instanceof AbstractMinecartEntity minecart && !minecart.getWorld().isClient() && reason.shouldDestroy()) { + if ((Entity) (Object) this instanceof AbstractMinecartEntity minecart && !minecart./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/.isClient() && reason.shouldDestroy()) { CartUtils.unlinkFromParent(minecart); CartUtils.unlinkFromParent(minecart.linkart$getFollower()); } @@ -29,10 +29,10 @@ public abstract class EntityMixin { @Inject(at = @At("HEAD"), method = "adjustMovementForCollisions(Lnet/minecraft/util/math/Vec3d;)Lnet/minecraft/util/math/Vec3d;", cancellable = true) void linkart$onRecalculateVelocity(Vec3d movement, CallbackInfoReturnable cir) { if ((Object) this instanceof AbstractMinecartEntity minecart) { - List collisions = minecart.getWorld().getOtherEntities((Entity) (Object) this, minecart.getBoundingBox().stretch(movement)); + List collisions = minecart./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/.getOtherEntities((Entity) (Object) this, minecart.getBoundingBox().stretch(movement)); for (Entity entity : collisions) { - if (!CollisionUtils.shouldCollide(minecart, entity) && minecart.getWorld().getBlockState(minecart.getBlockPos()).getBlock() instanceof AbstractRailBlock) { + if (!CollisionUtils.shouldCollide(minecart, entity) && minecart./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/.getBlockState(minecart.getBlockPos()).getBlock() instanceof AbstractRailBlock) { cir.setReturnValue(movement); return; } diff --git a/src/main/java/com/github/vini2003/linkart/mixin/PlayerEntityMixin.java b/src/main/java/com/github/vini2003/linkart/mixin/PlayerEntityMixin.java index 66a6f8c..4de3f7f 100644 --- a/src/main/java/com/github/vini2003/linkart/mixin/PlayerEntityMixin.java +++ b/src/main/java/com/github/vini2003/linkart/mixin/PlayerEntityMixin.java @@ -31,7 +31,7 @@ protected PlayerEntityMixin(EntityType entityType, World @Inject(at = @At("HEAD"), method = "interact", cancellable = true) void onInteract(Entity entity, Hand hand, CallbackInfoReturnable cir) { if (entity instanceof AbstractMinecartEntity minecart) { - if (getWorld().isClient()) return; + if (/*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/.isClient()) return; PlayerEntity player = (PlayerEntity) (Object) this; ItemStack stack = player.getStackInHand(hand); @@ -59,10 +59,13 @@ void onInteract(Entity entity, Hand hand, CallbackInfoReturnable c } @Unique private void finishOperation(CallbackInfoReturnable cir, AbstractMinecartEntity minecart, ActionResult result) { + ServerWorld world = (ServerWorld) minecart./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/; + if (world.isClient()) return; + if (result.isAccepted()) { - ((ServerWorld) minecart.getWorld()).spawnParticles(ParticleTypes.HAPPY_VILLAGER, minecart.getX(), minecart.getY() + 0.2, minecart.getZ(), 10, 0.5, 0.5, 0.5, 0.5); + world.spawnParticles(ParticleTypes.HAPPY_VILLAGER, minecart.getX(), minecart.getY() + 0.2, minecart.getZ(), 10, 0.5, 0.5, 0.5, 0.5); } else { - ((ServerWorld) minecart.getWorld()).spawnParticles(ParticleTypes.ANGRY_VILLAGER, minecart.getX(), minecart.getY() + 0.2, minecart.getZ(), 10, 0.5, 0.5, 0.5, 0.5); + world.spawnParticles(ParticleTypes.ANGRY_VILLAGER, minecart.getX(), minecart.getY() + 0.2, minecart.getZ(), 10, 0.5, 0.5, 0.5, 0.5); } cir.setReturnValue(result); } diff --git a/src/main/java/com/github/vini2003/linkart/utility/CartUtils.java b/src/main/java/com/github/vini2003/linkart/utility/CartUtils.java index 6c43450..f6b9973 100644 --- a/src/main/java/com/github/vini2003/linkart/utility/CartUtils.java +++ b/src/main/java/com/github/vini2003/linkart/utility/CartUtils.java @@ -5,12 +5,14 @@ import net.minecraft.particle.ItemStackParticleEffect; import net.minecraft.particle.ParticleTypes; import net.minecraft.server.world.ServerWorld; +import net.minecraft.world.World; public class CartUtils { public static void spawnChainParticles(AbstractMinecartEntity entity) { - if (!entity.getWorld().isClient()) { - ((ServerWorld) entity.getWorld()).spawnParticles(new ItemStackParticleEffect(ParticleTypes.ITEM, entity.linkart$getLinkItem()), entity.getX(), entity.getY() + 0.3, entity.getZ(), 15, 0.2, 0.2, 0.2, 0.2); + World world = entity./*? if >=1.21.9 {*//*getEntityWorld()*//*?} else {*/getWorld()/*?}*/; + if (!world.isClient()) { + ((ServerWorld) world).spawnParticles(new ItemStackParticleEffect(ParticleTypes.ITEM, entity.linkart$getLinkItem()), entity.getX(), entity.getY() + 0.3, entity.getZ(), 15, 0.2, 0.2, 0.2, 0.2); } } @@ -29,10 +31,12 @@ public static void unlinkFromParent(AbstractMinecartEntity entity) { entity.setVelocity(0, 0, 0); if (!entity.linkart$getLinkItem().isEmpty()) { - //? if =1.21.1 + //? if >=1.21.9 { + /*entity.dropStack((ServerWorld) entity.getEntityWorld(), entity.linkart$getLinkItem()); + *///?} elif >=1.21.4 { + /*entity.dropStack((ServerWorld) entity.getWorld(), entity.linkart$getLinkItem()); + *///?} elif =1.21.1 entity.dropStack(entity.linkart$getLinkItem()); - //? if >=1.21.4 - /*entity.dropStack((ServerWorld) entity.getWorld(), entity.linkart$getLinkItem());*/ spawnChainParticles(entity); } diff --git a/src/main/java/com/github/vini2003/linkart/utility/LinkartCommand.java b/src/main/java/com/github/vini2003/linkart/utility/LinkartCommand.java index 3f00b1c..7b706fc 100644 --- a/src/main/java/com/github/vini2003/linkart/utility/LinkartCommand.java +++ b/src/main/java/com/github/vini2003/linkart/utility/LinkartCommand.java @@ -9,7 +9,7 @@ public class LinkartCommand { - private static final Supplier RELOADED = () -> TextUtil.literal("reloaded linkart config"); + private static final Supplier RELOADED = () -> Text.literal("reloaded linkart config"); public static void register(CommandDispatcher dispatcher) { dispatcher.register(CommandManager.literal("linkart") diff --git a/src/main/java/com/github/vini2003/linkart/utility/TextUtil.java b/src/main/java/com/github/vini2003/linkart/utility/TextUtil.java deleted file mode 100644 index b289359..0000000 --- a/src/main/java/com/github/vini2003/linkart/utility/TextUtil.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.github.vini2003.linkart.utility; - -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; -import net.minecraft.util.Formatting; -import net.minecraft.util.math.BlockPos; - -import java.io.Serializable; - -public class TextUtil { - public static MutableText literal(Serializable value, Formatting formatting) { - return literal(value.toString(), formatting); - } - - public static MutableText literal(String value, Formatting formatting) { - return Text.literal(value).formatted(formatting); - } - - public static MutableText literal(Serializable value) { - return Text.literal(value.toString()); - } - - public static String blockPosAsString(BlockPos pos) { - return pos.getX() + ", " + pos.getY() + ", " + pos.getZ(); - } - - public static MutableText translatable(String key) { - return Text.translatable(key); - } - - public static MutableText translatable(String key, Object... args) { - return Text.translatable(key, args); - } -} diff --git a/versions/1.21.1/gradle.properties b/versions/1.21.1/gradle.properties index 57e6819..75b8b51 100644 --- a/versions/1.21.1/gradle.properties +++ b/versions/1.21.1/gradle.properties @@ -1,3 +1,3 @@ yarn_mappings=1.21.1+build.3 fabric_api=0.114.0+1.21.1 -midnightlib_version=1.6.9+1.21-fabric \ No newline at end of file +midnightlib_version=1.7.5+1.21.1-fabric \ No newline at end of file diff --git a/versions/1.21.10/gradle.properties b/versions/1.21.10/gradle.properties new file mode 100644 index 0000000..a5b1dcd --- /dev/null +++ b/versions/1.21.10/gradle.properties @@ -0,0 +1,3 @@ +yarn_mappings=1.21.10+build.2 +fabric_api=0.136.0+1.21.10 +midnightlib_version=1.8.3+1.21.9-fabric \ No newline at end of file diff --git a/versions/1.21.9/gradle.properties b/versions/1.21.9/gradle.properties new file mode 100644 index 0000000..6350577 --- /dev/null +++ b/versions/1.21.9/gradle.properties @@ -0,0 +1,3 @@ +yarn_mappings=1.21.9+build.1 +fabric_api=0.134.0+1.21.9 +midnightlib_version=1.8.3+1.21.9-fabric \ No newline at end of file