From 908b4904afbee644e68069479093dd3a6ac1ff9b Mon Sep 17 00:00:00 2001 From: Lara <69314462+WearBlackAllDay@users.noreply.github.com> Date: Wed, 9 Jun 2021 13:09:04 +0200 Subject: [PATCH] update to j16 and mc17 --- .gitignore | 4 +- build.gradle | 88 +++++++++++-------- gradle.properties | 13 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- src/main/java/dimthread/util/CrashInfo.java | 31 ------- .../dimthread/DimThread.java | 12 +-- .../dimthread/gamerule/BoolRule.java | 3 +- .../dimthread/gamerule/GameRule.java | 4 +- .../dimthread/gamerule/IntRule.java | 2 +- .../dimthread/init/ModGameRules.java | 8 +- .../dimthread/mixin/EntityMixin.java | 4 +- .../dimthread/mixin/MinecraftServerMixin.java | 8 +- .../mixin/RedstoneWireBlockMixin.java | 2 +- .../mixin/ServerChunkManagerMixin.java | 6 +- .../dimthread/mixin/WorldMixin.java | 4 +- .../dimthread/thread/IMutableMainThread.java | 2 +- .../dimthread/util/CrashInfo.java | 14 +++ .../dimthread/util/ServerManager.java | 7 +- src/main/resources/dimthread.mixins.json | 4 +- src/main/resources/fabric.mod.json | 4 +- 20 files changed, 108 insertions(+), 114 deletions(-) delete mode 100644 src/main/java/dimthread/util/CrashInfo.java rename src/main/java/{ => wearblackallday}/dimthread/DimThread.java (83%) rename src/main/java/{ => wearblackallday}/dimthread/gamerule/BoolRule.java (96%) rename src/main/java/{ => wearblackallday}/dimthread/gamerule/GameRule.java (86%) rename src/main/java/{ => wearblackallday}/dimthread/gamerule/IntRule.java (97%) rename src/main/java/{ => wearblackallday}/dimthread/init/ModGameRules.java (74%) rename src/main/java/{ => wearblackallday}/dimthread/mixin/EntityMixin.java (93%) rename src/main/java/{ => wearblackallday}/dimthread/mixin/MinecraftServerMixin.java (94%) rename src/main/java/{ => wearblackallday}/dimthread/mixin/RedstoneWireBlockMixin.java (98%) rename src/main/java/{ => wearblackallday}/dimthread/mixin/ServerChunkManagerMixin.java (93%) rename src/main/java/{ => wearblackallday}/dimthread/mixin/WorldMixin.java (83%) rename src/main/java/{ => wearblackallday}/dimthread/thread/IMutableMainThread.java (71%) create mode 100644 src/main/java/wearblackallday/dimthread/util/CrashInfo.java rename src/main/java/{ => wearblackallday}/dimthread/util/ServerManager.java (90%) diff --git a/.gitignore b/.gitignore index 03f4640..5b89b33 100644 --- a/.gitignore +++ b/.gitignore @@ -119,4 +119,6 @@ run/ # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) !gradle-wrapper.jar -remappedSrc/dimthread/ +remappedSrc/** +src/test/** +logs/** diff --git a/build.gradle b/build.gradle index 8b6fc7e..347de81 100644 --- a/build.gradle +++ b/build.gradle @@ -1,70 +1,78 @@ plugins { - id 'fabric-loom' version '0.5-SNAPSHOT' + id 'fabric-loom' version '0.8-SNAPSHOT' id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_16 +targetCompatibility = JavaVersion.VERSION_16 archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group repositories { - maven { url 'https://jitpack.io' } -} - -minecraft { - accessWidener = file("src/main/resources/dimthread.accesswidener") + maven { + url "https://jitpack.io" + } + // Add repositories to retrieve artifacts from in here. + // You should only use this when depending on other mods because + // 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. } dependencies { - implementation 'com.github.WearBlackAllDay:JavaUtils:ab1e0ad736be1d2c2d74c68fa8e9e40e752f2d18' - include 'com.github.WearBlackAllDay:JavaUtils:ab1e0ad736be1d2c2d74c68fa8e9e40e752f2d18' - //to change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:1.16.5" - mappings "net.fabricmc:yarn:1.16.5+build.6:v2" - modImplementation "net.fabricmc:fabric-loader:0.11.3" + implementation "com.github.wearblackallday:JavaUtils:1b369d41cd" + include"com.github.wearblackallday:JavaUtils:1b369d41cd" + + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - //Fabric api - //modImplementation "net.fabricmc.fabric-api:fabric-api:0.32.5+1.16" - modCompile "net.fabricmc.fabric-api:fabric-game-rule-api-v1:${project.fabric_game_rule_v1_version}" + // Fabric API. This is technically optional, but you probably want it anyway. +// modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation"net.fabricmc.fabric-api:fabric-game-rule-api-v1:${project.fabric_game_rule_v1_version}" // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. // You may need to force-disable transitiveness on them. +} +minecraft { + accessWidener = file("src/main/resources/dimthread.accesswidener") + refmapName = "dimthread.refmap.json" } processResources { inputs.property "version", project.version - from(sourceSets.main.resources.srcDirs) { - include "fabric.mod.json" + filesMatching("fabric.mod.json") { expand "version": project.version } - - from(sourceSets.main.resources.srcDirs) { - exclude "fabric.mod.json" - } } -// ensure that the encoding is set to UTF-8, no matter what the system default is -// this fixes some edge cases with special characters not displaying correctly -// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" +tasks.withType(JavaCompile).configureEach { + // ensure that the encoding is set to UTF-8, no matter what the system default is + // this fixes some edge cases with special characters not displaying correctly + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html + // If Javadoc is generated, this must be specified in that task too. + it.options.encoding = "UTF-8" + + // Minecraft 1.17 (21w19a) upwards uses Java 16. + it.options.release = 16 } -// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task -// if it is present. -// If you remove this task, sources will not be generated. -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() } jar { - from "LICENSE" + from("LICENSE") { + rename { "${it}_${project.archivesBaseName}"} + } } // configure the maven publication @@ -81,9 +89,11 @@ publishing { } } - // select the repositories you want to publish to + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - // uncomment to publish to the local maven - // mavenLocal() + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // 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 00830de..345b6fc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,14 +2,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.16.5 -yarn_mappings=1.16.5+build.6 +minecraft_version=1.17 +yarn_mappings=1.17+build.5 loader_version=0.11.3 # Mod Properties -mod_version=1.2.3 -maven_group=DimThread +mod_version=1.2.4 +maven_group=wearblackallday archives_base_name=DimThread # Dependencies # check this on https://modmuss50.me/fabric.html -fabric_version=0.32.5+1.16 -fabric_game_rule_v1_version=1.0.2+f8ac1db295 +#fabric_version=0.34.9+1.17 +fabric_game_rule_v1_version=1.0.6+a02b4463d5 + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bb8b2fc..f371643 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/dimthread/util/CrashInfo.java b/src/main/java/dimthread/util/CrashInfo.java deleted file mode 100644 index ac2b31c..0000000 --- a/src/main/java/dimthread/util/CrashInfo.java +++ /dev/null @@ -1,31 +0,0 @@ -package dimthread.util; - -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.crash.CrashException; -import net.minecraft.util.crash.CrashReport; - -public class CrashInfo { - - private final ServerWorld world; - private final Throwable throwable; - - public CrashInfo(ServerWorld world, Throwable throwable) { - this.world = world; - this.throwable = throwable; - } - - public ServerWorld getWorld() { - return this.world; - } - - public Throwable getThrowable() { - return this.throwable; - } - - public void crash(String title) { - CrashReport report = CrashReport.create(this.getThrowable(), title); - this.getWorld().addDetailsToCrashReport(report); - throw new CrashException(report); - } - -} diff --git a/src/main/java/dimthread/DimThread.java b/src/main/java/wearblackallday/dimthread/DimThread.java similarity index 83% rename from src/main/java/dimthread/DimThread.java rename to src/main/java/wearblackallday/dimthread/DimThread.java index ab9b5c8..04698e4 100644 --- a/src/main/java/dimthread/DimThread.java +++ b/src/main/java/wearblackallday/dimthread/DimThread.java @@ -1,16 +1,16 @@ -package dimthread; +package wearblackallday.dimthread; -import dimthread.init.ModGameRules; -import dimthread.thread.IMutableMainThread; -import dimthread.util.ServerManager; import net.fabricmc.api.ModInitializer; import net.minecraft.server.MinecraftServer; import net.minecraft.server.world.ServerWorld; -import threading.ThreadPool; +import wearblackallday.dimthread.init.ModGameRules; +import wearblackallday.dimthread.thread.IMutableMainThread; +import wearblackallday.dimthread.util.ServerManager; +import wearblackallday.util.ThreadPool; public class DimThread implements ModInitializer { - public static final String MOD_ID = "dimthread"; + public static final String MOD_ID = "wearblackallday/dimthread"; public static final ServerManager MANAGER = new ServerManager(); @Override diff --git a/src/main/java/dimthread/gamerule/BoolRule.java b/src/main/java/wearblackallday/dimthread/gamerule/BoolRule.java similarity index 96% rename from src/main/java/dimthread/gamerule/BoolRule.java rename to src/main/java/wearblackallday/dimthread/gamerule/BoolRule.java index b9e6682..e4d638f 100644 --- a/src/main/java/dimthread/gamerule/BoolRule.java +++ b/src/main/java/wearblackallday/dimthread/gamerule/BoolRule.java @@ -1,4 +1,4 @@ -package dimthread.gamerule; +package wearblackallday.dimthread.gamerule; import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory; import net.minecraft.server.MinecraftServer; @@ -42,5 +42,4 @@ public BoolRule build() { return new BoolRule(this.name, this.category, GameRuleFactory.createBooleanRule(this.initialValue, this.callback)); } } - } diff --git a/src/main/java/dimthread/gamerule/GameRule.java b/src/main/java/wearblackallday/dimthread/gamerule/GameRule.java similarity index 86% rename from src/main/java/dimthread/gamerule/GameRule.java rename to src/main/java/wearblackallday/dimthread/gamerule/GameRule.java index eede72b..c3eb3e9 100644 --- a/src/main/java/dimthread/gamerule/GameRule.java +++ b/src/main/java/wearblackallday/dimthread/gamerule/GameRule.java @@ -1,6 +1,6 @@ -package dimthread.gamerule; +package wearblackallday.dimthread.gamerule; -import dimthread.DimThread; +import wearblackallday.dimthread.DimThread; import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry; import net.minecraft.world.GameRules; diff --git a/src/main/java/dimthread/gamerule/IntRule.java b/src/main/java/wearblackallday/dimthread/gamerule/IntRule.java similarity index 97% rename from src/main/java/dimthread/gamerule/IntRule.java rename to src/main/java/wearblackallday/dimthread/gamerule/IntRule.java index 9c75179..fed0b98 100644 --- a/src/main/java/dimthread/gamerule/IntRule.java +++ b/src/main/java/wearblackallday/dimthread/gamerule/IntRule.java @@ -1,4 +1,4 @@ -package dimthread.gamerule; +package wearblackallday.dimthread.gamerule; import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory; import net.minecraft.server.MinecraftServer; diff --git a/src/main/java/dimthread/init/ModGameRules.java b/src/main/java/wearblackallday/dimthread/init/ModGameRules.java similarity index 74% rename from src/main/java/dimthread/init/ModGameRules.java rename to src/main/java/wearblackallday/dimthread/init/ModGameRules.java index 3e9326a..969bc95 100644 --- a/src/main/java/dimthread/init/ModGameRules.java +++ b/src/main/java/wearblackallday/dimthread/init/ModGameRules.java @@ -1,8 +1,8 @@ -package dimthread.init; +package wearblackallday.dimthread.init; -import dimthread.DimThread; -import dimthread.gamerule.BoolRule; -import dimthread.gamerule.IntRule; +import wearblackallday.dimthread.DimThread; +import wearblackallday.dimthread.gamerule.BoolRule; +import wearblackallday.dimthread.gamerule.IntRule; import net.minecraft.world.GameRules; public class ModGameRules { diff --git a/src/main/java/dimthread/mixin/EntityMixin.java b/src/main/java/wearblackallday/dimthread/mixin/EntityMixin.java similarity index 93% rename from src/main/java/dimthread/mixin/EntityMixin.java rename to src/main/java/wearblackallday/dimthread/mixin/EntityMixin.java index 4ff2bab..1203f8f 100644 --- a/src/main/java/dimthread/mixin/EntityMixin.java +++ b/src/main/java/wearblackallday/dimthread/mixin/EntityMixin.java @@ -1,6 +1,6 @@ -package dimthread.mixin; +package wearblackallday.dimthread.mixin; -import dimthread.DimThread; +import wearblackallday.dimthread.DimThread; import net.minecraft.entity.Entity; import net.minecraft.server.world.ServerWorld; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/dimthread/mixin/MinecraftServerMixin.java b/src/main/java/wearblackallday/dimthread/mixin/MinecraftServerMixin.java similarity index 94% rename from src/main/java/dimthread/mixin/MinecraftServerMixin.java rename to src/main/java/wearblackallday/dimthread/mixin/MinecraftServerMixin.java index 0e1ee5d..7faeb4f 100644 --- a/src/main/java/dimthread/mixin/MinecraftServerMixin.java +++ b/src/main/java/wearblackallday/dimthread/mixin/MinecraftServerMixin.java @@ -1,7 +1,5 @@ -package dimthread.mixin; +package wearblackallday.dimthread.mixin; -import dimthread.DimThread; -import dimthread.util.CrashInfo; import net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket; import net.minecraft.server.MinecraftServer; import net.minecraft.server.PlayerManager; @@ -13,7 +11,9 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import threading.ThreadPool; +import wearblackallday.dimthread.DimThread; +import wearblackallday.dimthread.util.CrashInfo; +import wearblackallday.util.ThreadPool; import java.util.Collections; import java.util.Iterator; diff --git a/src/main/java/dimthread/mixin/RedstoneWireBlockMixin.java b/src/main/java/wearblackallday/dimthread/mixin/RedstoneWireBlockMixin.java similarity index 98% rename from src/main/java/dimthread/mixin/RedstoneWireBlockMixin.java rename to src/main/java/wearblackallday/dimthread/mixin/RedstoneWireBlockMixin.java index b3c8cd9..919c878 100644 --- a/src/main/java/dimthread/mixin/RedstoneWireBlockMixin.java +++ b/src/main/java/wearblackallday/dimthread/mixin/RedstoneWireBlockMixin.java @@ -1,4 +1,4 @@ -package dimthread.mixin; +package wearblackallday.dimthread.mixin; import net.minecraft.block.BlockState; import net.minecraft.block.RedstoneWireBlock; diff --git a/src/main/java/dimthread/mixin/ServerChunkManagerMixin.java b/src/main/java/wearblackallday/dimthread/mixin/ServerChunkManagerMixin.java similarity index 93% rename from src/main/java/dimthread/mixin/ServerChunkManagerMixin.java rename to src/main/java/wearblackallday/dimthread/mixin/ServerChunkManagerMixin.java index 43bf557..f9dc461 100644 --- a/src/main/java/dimthread/mixin/ServerChunkManagerMixin.java +++ b/src/main/java/wearblackallday/dimthread/mixin/ServerChunkManagerMixin.java @@ -1,7 +1,7 @@ -package dimthread.mixin; +package wearblackallday.dimthread.mixin; -import dimthread.DimThread; -import dimthread.thread.IMutableMainThread; +import wearblackallday.dimthread.DimThread; +import wearblackallday.dimthread.thread.IMutableMainThread; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.server.world.ServerChunkManager; import net.minecraft.server.world.ServerWorld; diff --git a/src/main/java/dimthread/mixin/WorldMixin.java b/src/main/java/wearblackallday/dimthread/mixin/WorldMixin.java similarity index 83% rename from src/main/java/dimthread/mixin/WorldMixin.java rename to src/main/java/wearblackallday/dimthread/mixin/WorldMixin.java index 23cc46e..2c887ea 100644 --- a/src/main/java/dimthread/mixin/WorldMixin.java +++ b/src/main/java/wearblackallday/dimthread/mixin/WorldMixin.java @@ -1,6 +1,6 @@ -package dimthread.mixin; +package wearblackallday.dimthread.mixin; -import dimthread.thread.IMutableMainThread; +import wearblackallday.dimthread.thread.IMutableMainThread; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/dimthread/thread/IMutableMainThread.java b/src/main/java/wearblackallday/dimthread/thread/IMutableMainThread.java similarity index 71% rename from src/main/java/dimthread/thread/IMutableMainThread.java rename to src/main/java/wearblackallday/dimthread/thread/IMutableMainThread.java index 1f2bc31..a501327 100644 --- a/src/main/java/dimthread/thread/IMutableMainThread.java +++ b/src/main/java/wearblackallday/dimthread/thread/IMutableMainThread.java @@ -1,4 +1,4 @@ -package dimthread.thread; +package wearblackallday.dimthread.thread; public interface IMutableMainThread { diff --git a/src/main/java/wearblackallday/dimthread/util/CrashInfo.java b/src/main/java/wearblackallday/dimthread/util/CrashInfo.java new file mode 100644 index 0000000..262f360 --- /dev/null +++ b/src/main/java/wearblackallday/dimthread/util/CrashInfo.java @@ -0,0 +1,14 @@ +package wearblackallday.dimthread.util; + +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.crash.CrashException; +import net.minecraft.util.crash.CrashReport; + +public record CrashInfo(ServerWorld world, Throwable throwable) { + + public void crash(String title) { + CrashReport report = CrashReport.create(this.throwable, title); + this.world.addDetailsToCrashReport(report); + throw new CrashException(report); + } +} diff --git a/src/main/java/dimthread/util/ServerManager.java b/src/main/java/wearblackallday/dimthread/util/ServerManager.java similarity index 90% rename from src/main/java/dimthread/util/ServerManager.java rename to src/main/java/wearblackallday/dimthread/util/ServerManager.java index c75f4ec..af399bd 100644 --- a/src/main/java/dimthread/util/ServerManager.java +++ b/src/main/java/wearblackallday/dimthread/util/ServerManager.java @@ -1,9 +1,9 @@ -package dimthread.util; +package wearblackallday.dimthread.util; -import dimthread.init.ModGameRules; import net.minecraft.server.MinecraftServer; import net.minecraft.world.GameRules; -import threading.ThreadPool; +import wearblackallday.dimthread.init.ModGameRules; +import wearblackallday.util.ThreadPool; import java.util.Collections; import java.util.ConcurrentModificationException; @@ -37,5 +37,4 @@ public void setThreadCount(MinecraftServer server, GameRules.IntRule value) { this.threadPools.put(server, new ThreadPool(value.get())); current.shutdown(); } - } diff --git a/src/main/resources/dimthread.mixins.json b/src/main/resources/dimthread.mixins.json index 53f853c..dae46c2 100644 --- a/src/main/resources/dimthread.mixins.json +++ b/src/main/resources/dimthread.mixins.json @@ -1,8 +1,8 @@ { "required": true, "minVersion": "0.8", - "package": "dimthread.mixin", - "compatibilityLevel": "JAVA_8", + "package": "wearblackallday.dimthread.mixin", + "compatibilityLevel": "JAVA_16", "mixins": [ "EntityMixin", "MinecraftServerMixin", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 4ad3165..7b4e63e 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -9,7 +9,7 @@ "environment": "*", "entrypoints": { "main": [ - "dimthread.DimThread" + "wearblackallday.dimthread.DimThread" ] }, "mixins": [ @@ -18,6 +18,6 @@ "accessWidener": "dimthread.accesswidener", "depends": { "fabricloader": ">=0.9.3+build.207", - "minecraft": "1.16.x" + "minecraft": ">=1.16" } }