Skip to content

Commit

Permalink
Port of the mod to 1.20 (includes update of loom, gradle & shadow)
Browse files Browse the repository at this point in the history
  • Loading branch information
Picono435 committed Jun 8, 2023
1 parent af9cb1e commit 57bc4ab
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -35,7 +35,7 @@ public static void spawnTeleportPlayer(ServerPlayer player) {
String biome = rtpCommand.split(" ")[1];
ResourceLocation biomeLocation = ResourceLocation.tryParse(biome);
ResourceKey<Biome> biomeKey = ResourceKey.create(Registries.BIOME, biomeLocation);
RandomTPAPI.randomTeleport(player, player.getLevel(), biomeKey);
RandomTPAPI.randomTeleport(player, player.serverLevel(), biomeKey);
return;
case "none": {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private static int runCommand(ServerPlayer p, ResourceOrTagArgument.Result<Biome
Component finding = Component.literal(Messages.getFinding().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(finding, false);
new Thread(() -> {
RandomTPAPI.randomTeleport(p, p.getLevel(), biomeKey);
RandomTPAPI.randomTeleport(p, p.serverLevel(), biomeKey);
}).start();
cooldowns.put(p.getName().getString(), System.currentTimeMillis());
return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
8 changes: 4 additions & 4 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id "com.github.johnrengelman.shadow" version "8.1.1"
}

architectury {
Expand Down Expand Up @@ -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'
Expand All @@ -52,11 +52,11 @@ shadowJar {
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier "fabric"
archiveClassifier.set("fabric")
}

jar {
classifier "dev"
archiveClassifier.set("dev")
}

sourcesJar {
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
"minecraft": ["1.19.x"]
"minecraft": ["1.20.x"]
},
"suggests": {
"flamingo": "*"
Expand Down
8 changes: 4 additions & 4 deletions forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id "com.github.johnrengelman.shadow" version "8.1.1"
}

architectury {
Expand Down Expand Up @@ -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'
Expand All @@ -48,11 +48,11 @@ shadowJar {
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier "forge"
archiveClassifier.set("forge")
}

jar {
classifier "dev"
archiveClassifier.set("dev")
}

sourcesJar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
forge_version=46.0.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ include("common")
include("fabric")
include("forge")

rootProject.name = "RandomTP-1.19"
rootProject.name = "RandomTP-1.20"

0 comments on commit 57bc4ab

Please sign in to comment.