From 57bc4abe7fe7a9622b095c9154f2b79436f531b2 Mon Sep 17 00:00:00 2001 From: Picono435 Date: Thu, 8 Jun 2023 13:12:00 +0100 Subject: [PATCH] Port of the mod to 1.20 (includes update of loom, gradle & shadow) --- build.gradle | 2 +- .../java/com/gmail/picono435/randomtp/RandomTPMod.java | 4 ++-- .../gmail/picono435/randomtp/commands/RTPBCommand.java | 2 +- .../com/gmail/picono435/randomtp/commands/RTPCommand.java | 8 ++++---- .../gmail/picono435/randomtp/commands/RTPDCommand.java | 6 +++--- .../com/gmail/picono435/randomtp/data/ServerState.java | 2 +- fabric/build.gradle | 8 ++++---- fabric/src/main/resources/fabric.mod.json | 2 +- forge/build.gradle | 8 ++++---- .../gmail/picono435/randomtp/forge/RandomTPModForge.java | 2 +- gradle.properties | 8 ++++---- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 2 +- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/build.gradle b/build.gradle index e6b5dad..1c8f198 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "1.1-SNAPSHOT" apply false + id "dev.architectury.loom" version "1.2-SNAPSHOT" apply false } architectury { diff --git a/common/src/main/java/com/gmail/picono435/randomtp/RandomTPMod.java b/common/src/main/java/com/gmail/picono435/randomtp/RandomTPMod.java index 1a51d16..1f3479d 100644 --- a/common/src/main/java/com/gmail/picono435/randomtp/RandomTPMod.java +++ b/common/src/main/java/com/gmail/picono435/randomtp/RandomTPMod.java @@ -25,7 +25,7 @@ public static void spawnTeleportPlayer(ServerPlayer player) { if(rtpCommand == null) return; switch(rtpCommand.split(" ")[0]) { case "rtp": - RandomTPAPI.randomTeleport(player, player.getLevel()); + RandomTPAPI.randomTeleport(player, player.serverLevel()); return; case "rtpd": String dimension = rtpCommand.split(" ")[1]; @@ -35,7 +35,7 @@ public static void spawnTeleportPlayer(ServerPlayer player) { String biome = rtpCommand.split(" ")[1]; ResourceLocation biomeLocation = ResourceLocation.tryParse(biome); ResourceKey biomeKey = ResourceKey.create(Registries.BIOME, biomeLocation); - RandomTPAPI.randomTeleport(player, player.getLevel(), biomeKey); + RandomTPAPI.randomTeleport(player, player.serverLevel(), biomeKey); return; case "none": {} } diff --git a/common/src/main/java/com/gmail/picono435/randomtp/commands/RTPBCommand.java b/common/src/main/java/com/gmail/picono435/randomtp/commands/RTPBCommand.java index 43e2e4e..d145986 100644 --- a/common/src/main/java/com/gmail/picono435/randomtp/commands/RTPBCommand.java +++ b/common/src/main/java/com/gmail/picono435/randomtp/commands/RTPBCommand.java @@ -63,7 +63,7 @@ private static int runCommand(ServerPlayer p, ResourceOrTagArgument.Result { - RandomTPAPI.randomTeleport(p, p.getLevel(), biomeKey); + RandomTPAPI.randomTeleport(p, p.serverLevel(), biomeKey); }).start(); cooldowns.put(p.getName().getString(), System.currentTimeMillis()); return 1; diff --git a/common/src/main/java/com/gmail/picono435/randomtp/commands/RTPCommand.java b/common/src/main/java/com/gmail/picono435/randomtp/commands/RTPCommand.java index fccb510..584b74f 100644 --- a/common/src/main/java/com/gmail/picono435/randomtp/commands/RTPCommand.java +++ b/common/src/main/java/com/gmail/picono435/randomtp/commands/RTPCommand.java @@ -44,22 +44,22 @@ private static int runCommand(ServerPlayer p) { if(!Config.getDefaultWorld().equals("playerworld")) { RandomTPAPI.randomTeleport(p, RandomTPAPI.getWorld(Config.getDefaultWorld(), p.getServer())); } else { - RandomTPAPI.randomTeleport(p, p.getLevel()); + RandomTPAPI.randomTeleport(p, p.serverLevel()); } }).start(); cooldowns.put(p.getName().getString(), System.currentTimeMillis()); return 1; } - double cal = p.getLevel().getWorldBorder().getSize()/2; + double cal = p.serverLevel().getWorldBorder().getSize()/2; BigDecimal num = new BigDecimal(cal); String maxDistance = num.toPlainString(); if(Config.getMaxDistance() == 0) { - String command = "spreadplayers " + p.getLevel().getWorldBorder().getCenterX() + " " + p.getLevel().getWorldBorder().getCenterZ() + " " + Config.getMinDistance() + " " + maxDistance + " false " + p.getName().getString().toLowerCase(); + String command = "spreadplayers " + p.serverLevel().getWorldBorder().getCenterX() + " " + p.serverLevel().getWorldBorder().getCenterZ() + " " + Config.getMinDistance() + " " + maxDistance + " false " + p.getName().getString().toLowerCase(); p.getServer().getCommands().performCommand(p.getServer().getCommands().getDispatcher().parse(command, p.getServer().createCommandSourceStack()), command); Component successful = Component.literal(Messages.getSuccessful().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockX\\}", "" + (int)p.position().x).replaceAll("\\{blockY\\}", "" + (int)p.position().y).replaceAll("\\{blockZ\\}", "" + (int)p.position().z).replaceAll("&", "§")); p.sendSystemMessage(successful, false); } else { - String command = "spreadplayers " + p.getLevel().getWorldBorder().getCenterX() + " " + p.getLevel().getWorldBorder().getCenterZ() + " " + Config.getMinDistance() + " " + Config.getMaxDistance() + " false " + p.getName().getString().toLowerCase(); + String command = "spreadplayers " + p.serverLevel().getWorldBorder().getCenterX() + " " + p.serverLevel().getWorldBorder().getCenterZ() + " " + Config.getMinDistance() + " " + Config.getMaxDistance() + " false " + p.getName().getString().toLowerCase(); p.getServer().getCommands().performCommand(p.getServer().getCommands().getDispatcher().parse(command, p.getServer().createCommandSourceStack()), command); Component successful = Component.literal(Messages.getSuccessful().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockX\\}", "" + (int)p.position().x).replaceAll("\\{blockY\\}", "" + (int)p.position().y).replaceAll("\\{blockZ\\}", "" + (int)p.position().z).replaceAll("&", "§")); p.sendSystemMessage(successful, false); diff --git a/common/src/main/java/com/gmail/picono435/randomtp/commands/RTPDCommand.java b/common/src/main/java/com/gmail/picono435/randomtp/commands/RTPDCommand.java index 24f3b08..2105f2b 100644 --- a/common/src/main/java/com/gmail/picono435/randomtp/commands/RTPDCommand.java +++ b/common/src/main/java/com/gmail/picono435/randomtp/commands/RTPDCommand.java @@ -63,16 +63,16 @@ private static int runCommand(ServerPlayer p, ServerLevel dim) { } p.handleInsidePortal(p.blockPosition()); p.changeDimension(dim); - double cal = p.getLevel().getWorldBorder().getSize()/2; + double cal = p.serverLevel().getWorldBorder().getSize()/2; BigDecimal num = new BigDecimal(cal); String maxDistance = num.toPlainString(); if(Config.getMaxDistance() == 0) { - String command = "spreadplayers " + p.getLevel().getWorldBorder().getCenterX() + " " + p.getLevel().getWorldBorder().getCenterZ() + " " + Config.getMinDistance() + " " + maxDistance + " false " + p.getName().getString().toLowerCase(); + String command = "spreadplayers " + p.serverLevel().getWorldBorder().getCenterX() + " " + p.serverLevel().getWorldBorder().getCenterZ() + " " + Config.getMinDistance() + " " + maxDistance + " false " + p.getName().getString().toLowerCase(); p.getServer().getCommands().performCommand(p.getServer().getCommands().getDispatcher().parse(command, p.getServer().createCommandSourceStack()), command); Component successful = Component.literal(Messages.getSuccessful().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockX\\}", "" + (int)p.position().x).replaceAll("\\{blockY\\}", "" + (int)p.position().y).replaceAll("\\{blockZ\\}", "" + (int)p.position().z).replaceAll("&", "§")); p.sendSystemMessage(successful, false); } else { - String command = "spreadplayers " + p.getLevel().getWorldBorder().getCenterX() + " " + p.getLevel().getWorldBorder().getCenterZ() + " " + Config.getMinDistance() + " " + Config.getMaxDistance() + " false " + p.getName().getString().toLowerCase(); + String command = "spreadplayers " + p.serverLevel().getWorldBorder().getCenterX() + " " + p.serverLevel().getWorldBorder().getCenterZ() + " " + Config.getMinDistance() + " " + Config.getMaxDistance() + " false " + p.getName().getString().toLowerCase(); p.getServer().getCommands().performCommand(p.getServer().getCommands().getDispatcher().parse(command, p.getServer().createCommandSourceStack()), command); Component successful = Component.literal(Messages.getSuccessful().replaceAll("\\{playerName\\}", p.getName().getString()).replaceAll("\\{blockX\\}", "" + (int)p.position().x).replaceAll("\\{blockY\\}", "" + (int)p.position().y).replaceAll("\\{blockZ\\}", "" + (int)p.position().z).replaceAll("&", "§")); p.sendSystemMessage(successful, false); diff --git a/common/src/main/java/com/gmail/picono435/randomtp/data/ServerState.java b/common/src/main/java/com/gmail/picono435/randomtp/data/ServerState.java index 31a470f..e15911b 100644 --- a/common/src/main/java/com/gmail/picono435/randomtp/data/ServerState.java +++ b/common/src/main/java/com/gmail/picono435/randomtp/data/ServerState.java @@ -60,7 +60,7 @@ public static ServerState getServerState(MinecraftServer server) { } public static PlayerState getPlayerState(LivingEntity player) { - ServerState serverState = getServerState(player.level.getServer()); + ServerState serverState = getServerState(player.getServer()); PlayerState playerState = serverState.players.computeIfAbsent(player.getUUID(), uuid -> new PlayerState()); diff --git a/fabric/build.gradle b/fabric/build.gradle index 71ab2da..f82239f 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" + id "com.github.johnrengelman.shadow" version "8.1.1" } architectury { @@ -40,7 +40,7 @@ processResources { shadowJar { configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" + archiveClassifier.set("dev-shadow") relocate 'org.yaml', 'com.gmail.picono435.dependencies.yaml' relocate 'org.spongepowered', 'com.gmail.picono435.dependencies.spongepowered' @@ -52,11 +52,11 @@ shadowJar { remapJar { input.set shadowJar.archiveFile dependsOn shadowJar - classifier "fabric" + archiveClassifier.set("fabric") } jar { - classifier "dev" + archiveClassifier.set("dev") } sourcesJar { diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 670bf86..3cfcfe1 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -22,7 +22,7 @@ "depends": { "fabricloader": ">=0.7.4", "fabric": "*", - "minecraft": ["1.19.x"] + "minecraft": ["1.20.x"] }, "suggests": { "flamingo": "*" diff --git a/forge/build.gradle b/forge/build.gradle index 7fd1b57..07bb52d 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" + id "com.github.johnrengelman.shadow" version "8.1.1" } architectury { @@ -36,7 +36,7 @@ shadowJar { exclude "fabric.mod.json" configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" + archiveClassifier.set("dev-shadow") relocate 'org.yaml', 'com.gmail.picono435.dependencies.yaml' relocate 'org.spongepowered', 'com.gmail.picono435.dependencies.spongepowered' @@ -48,11 +48,11 @@ shadowJar { remapJar { input.set shadowJar.archiveFile dependsOn shadowJar - classifier "forge" + archiveClassifier.set("forge") } jar { - classifier "dev" + archiveClassifier.set("dev") } sourcesJar { diff --git a/forge/src/main/java/com/gmail/picono435/randomtp/forge/RandomTPModForge.java b/forge/src/main/java/com/gmail/picono435/randomtp/forge/RandomTPModForge.java index d569e04..3c8d315 100644 --- a/forge/src/main/java/com/gmail/picono435/randomtp/forge/RandomTPModForge.java +++ b/forge/src/main/java/com/gmail/picono435/randomtp/forge/RandomTPModForge.java @@ -70,7 +70,7 @@ public void init(ServerStartingEvent event) { @SubscribeEvent(priority = EventPriority.LOWEST) public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) { - if(event.getEntity().level.isClientSide) return; + if(event.getEntity().level().isClientSide) return; PlayerState playerState = ServerState.getPlayerState(event.getEntity()); if(!playerState.hasJoined) { RandomTPMod.spawnTeleportPlayer((ServerPlayer) event.getEntity()); diff --git a/gradle.properties b/gradle.properties index 8b2f1e2..a7b476e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,13 @@ org.gradle.jvmargs=-Xmx6G org.gradle.daemon=false -minecraft_version=1.19.4 +minecraft_version=1.20 archives_base_name=randomtp -mod_version=7.3.0+1.19 +mod_version=8.0.0+1.20 maven_group=com.gmail.picono435 fabric_loader_version=0.14.21 -fabric_api_version=0.82.0+1.19.4 +fabric_api_version=0.83.0+1.20 -forge_version=45.0.64 \ No newline at end of file +forge_version=46.0.1 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 856da69..8f5ef1a 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-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 33c9ec3..f1d7f6a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,4 +11,4 @@ include("common") include("fabric") include("forge") -rootProject.name = "RandomTP-1.19" +rootProject.name = "RandomTP-1.20"