From 610651d98603daeeb5d06a5bfda08d316467291b Mon Sep 17 00:00:00 2001 From: etianl <115842502+etianl@users.noreply.github.com> Date: Mon, 6 Nov 2023 04:42:37 -0800 Subject: [PATCH] 0.7.2 Better .world command! Shows all gamerules and KnownPlayers for server **0.7.2** - Better **.world** info command. - Added the **KnownPlayers** value. This returns all the historical players that have played on a server, no need for a fancy database that pings servers and tracks player names just use the **.world** command. (Doesnt work on all servers) - Replaced DO_DAYLIGHT_CYCLE value with the "GameRules" value which returns all the gamerules on a server. - Added Day Count, and Simulation distance (in chunks). - Added a "save" option to the .world command which saves the world info data to a txt file in your .minecraft folder in the SavedWorldInfo folder. --- README.md | 2 +- gradle.properties | 2 +- .../commands/ViewNbtCommand.java | 2 +- .../commands/WorldInfoCommand.java | 65 +++++++++++++++++-- src/main/resources/fabric.mod.json | 2 +- 5 files changed, 64 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cc5f111b1..9a8bde418 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ This will return the lowest block placed with AutoMountain until AutoLavacast is - **TrouserBuild:** It can build either horizontally or vertically according to a 5x5 grid centered on the block you are aiming at. Right click to build at the targeted location. (Credits to etianl, and to Banana for the checkboxes and idea. :D) - **ViewNbtCommand:** Returns the nbt data for the item in your hand in the chat box. There is also a Save option for the command that saves the data to a text file in your .minecraft folder in the "SavedNBT" folder. - **Voider+:** Replaces the world from the top down. (Credits to Allah-Hack) I added a 3x3 voiding script, a TP foward option for deleting strips, as well as options to set max and minimum height for voiding, and instead of just air it can do whatever block you want now too. -- **WorldInfoCommand** Type .world in chat to tell you the precise coordinates of each of the world borders, as well as some other world info. (Credits to etianl :D) +- **WorldInfoCommand** Type .world in chat to tell you the gamerules on the server, the players that have played there (may not work on all servers), as well as some other world info like world border coordinates. (Credits to etianl :D) ## Known Bugs: - **AutoLavaCaster Bugs** diff --git a/gradle.properties b/gradle.properties index ac698fbf2..cb34f8aed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ yarn_mappings=1.20.2+build.4 loader_version=0.14.22 # Mod Properties -mod_version=0.7.1-1.20.2 +mod_version=0.7.2-1.20.2 maven_group=pwn.noobs archives_base_name=1trouser-streak diff --git a/src/main/java/pwn/noobs/trouserstreak/commands/ViewNbtCommand.java b/src/main/java/pwn/noobs/trouserstreak/commands/ViewNbtCommand.java index 89d0645af..c8dff7ecb 100644 --- a/src/main/java/pwn/noobs/trouserstreak/commands/ViewNbtCommand.java +++ b/src/main/java/pwn/noobs/trouserstreak/commands/ViewNbtCommand.java @@ -31,7 +31,7 @@ public void build(LiteralArgumentBuilder builder) { else error("No item in main hand."); return SINGLE_SUCCESS; }); - builder.then(literal("Save").executes(ctx -> { + builder.then(literal("save").executes(ctx -> { if (!mc.player.getMainHandStack().isEmpty()){ if (mc.player.getMainHandStack().getNbt() == null){ error("No NBT data for item."); diff --git a/src/main/java/pwn/noobs/trouserstreak/commands/WorldInfoCommand.java b/src/main/java/pwn/noobs/trouserstreak/commands/WorldInfoCommand.java index 0a3aff891..77918ff6a 100644 --- a/src/main/java/pwn/noobs/trouserstreak/commands/WorldInfoCommand.java +++ b/src/main/java/pwn/noobs/trouserstreak/commands/WorldInfoCommand.java @@ -4,10 +4,14 @@ import meteordevelopment.meteorclient.commands.Command; import meteordevelopment.meteorclient.utils.player.ChatUtils; import net.minecraft.command.CommandSource; -import net.minecraft.network.packet.c2s.play.JigsawGeneratingC2SPacket; -import net.minecraft.network.packet.s2c.play.AdvancementUpdateS2CPacket; import net.minecraft.text.Text; -import net.minecraft.world.GameRules; +import net.minecraft.util.WorldSavePath; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import static meteordevelopment.meteorclient.MeteorClient.mc; @@ -24,8 +28,59 @@ public void build(LiteralArgumentBuilder builder) { ChatUtils.sendMsg(Text.of("East World Border X: "+(int) mc.world.getWorldBorder().getBoundEast()+", West World Border X: "+(int) mc.world.getWorldBorder().getBoundWest()+", South World Border Z: "+(int) mc.world.getWorldBorder().getBoundSouth()+", North World Border Z: "+(int) mc.world.getWorldBorder().getBoundNorth())); ChatUtils.sendMsg(Text.of("Default WorldSpawn Location (May be different if changed): "+mc.world.getSpawnPos())); ChatUtils.sendMsg(Text.of("Difficulty: "+mc.world.getDifficulty().toString())); - ChatUtils.sendMsg(Text.of("DO_DAYLIGHT_CYCLE: "+mc.world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); + ChatUtils.sendMsg(Text.of("Simulation Distance (chunks): "+mc.world.getSimulationDistance())); + ChatUtils.sendMsg(Text.of("Day Count: "+Math.floor(mc.world.getTime()/24000))); + ChatUtils.sendMsg(Text.of("GameRules: "+mc.world.getGameRules().toNbt().toString())); + ChatUtils.sendMsg(Text.of("KnownPlayers (Names with a period are bedrock players): "+mc.world.getScoreboard().getKnownPlayers())); return SINGLE_SUCCESS; }); + builder.then(literal("save").executes(ctx -> { + if (!mc.player.getMainHandStack().isEmpty()){ + ChatUtils.sendMsg(Text.of("East World Border X: "+(int) mc.world.getWorldBorder().getBoundEast()+", West World Border X: "+(int) mc.world.getWorldBorder().getBoundWest()+", South World Border Z: "+(int) mc.world.getWorldBorder().getBoundSouth()+", North World Border Z: "+(int) mc.world.getWorldBorder().getBoundNorth())); + ChatUtils.sendMsg(Text.of("Default WorldSpawn Location (May be different if changed): "+mc.world.getSpawnPos())); + ChatUtils.sendMsg(Text.of("Difficulty: "+mc.world.getDifficulty().toString())); + ChatUtils.sendMsg(Text.of("Simulation Distance (chunks): "+mc.world.getSimulationDistance())); + ChatUtils.sendMsg(Text.of("Day Count: "+Math.floor(mc.world.getTime()/24000))); + ChatUtils.sendMsg(Text.of("GameRules: "+mc.world.getGameRules().toNbt().toString())); + ChatUtils.sendMsg(Text.of("KnownPlayers (Names with a period are bedrock players): "+mc.world.getScoreboard().getKnownPlayers())); + + String serverip; + if (mc.isInSingleplayer()==true){ + String[] array = mc.getServer().getSavePath(WorldSavePath.ROOT).toString().replace(':', '_').split("/|\\\\"); + serverip=array[array.length-2]; + } else { + serverip = mc.getCurrentServerEntry().address.replace(':', '_'); + } + + if (!Files.exists(Paths.get("SavedWorldInfo/"+serverip+"/WorldInfoData.txt"))){ + File file = new File("SavedWorldInfo/"+serverip+"/WorldInfoData.txt"); + try { + file.createNewFile(); + } catch (IOException e) {} + } + try { + new File("SavedWorldInfo/"+serverip+"/").mkdirs(); + FileWriter writer = new FileWriter("SavedWorldInfo/"+serverip+"/WorldInfoData.txt", true); + writer.write("East World Border X: "+(int) mc.world.getWorldBorder().getBoundEast()+", West World Border X: "+(int) mc.world.getWorldBorder().getBoundWest()+", South World Border Z: "+(int) mc.world.getWorldBorder().getBoundSouth()+", North World Border Z: "+(int) mc.world.getWorldBorder().getBoundNorth()); + writer.write("\r\n"); // write new line + writer.write("Default WorldSpawn Location (May be different if changed): "+mc.world.getSpawnPos()); + writer.write("\r\n"); // write new line + writer.write("Difficulty: "+mc.world.getDifficulty().toString()); + writer.write("\r\n"); // write new line + writer.write("Simulation Distance (chunks): "+mc.world.getSimulationDistance()); + writer.write("\r\n"); // write new line + writer.write("Day Count: "+Math.floor(mc.world.getTime()/24000)); + writer.write("\r\n"); // write new line + writer.write("GameRules: "+mc.world.getGameRules().toNbt().toString()); + writer.write("\r\n"); // write new line + writer.write("KnownPlayers (Names with a period are bedrock players): "+mc.world.getScoreboard().getKnownPlayers()); + writer.write("\r\n"); // write new line + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } else error("No item in main hand."); + return SINGLE_SUCCESS; + })); } -} +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 5be79a142..4227842ef 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "streak-addon", - "version": "0.7.1", + "version": "0.7.2", "name": "TrouserStreak", "description": "Trouser-Streak is a compilation of modules, updated to the latest version and optimized for maximum grief. I did not make all of these.", "authors": [