From 022b9b7390b9769210e8638305dc1a1ba792f46b Mon Sep 17 00:00:00 2001 From: Stachelbeere1248 Date: Thu, 12 Dec 2024 20:49:47 +0100 Subject: [PATCH] perhaps patch difficulty --- README.md | 33 +++++++++------- gradle.properties | 2 +- .../config/ZombiesUtilsConfig.java | 37 +++++++++++++----- .../zombiesutils/game/GameData.java | 1 - .../zombiesutils/handlers/ChatHandler.java | 25 ++++++------ .../handlers/RenderPlayerHandler.java | 3 +- .../zombiesutils/timer/GameManager.java | 25 ++++++++++-- src/main/resources/mcmod.info | 4 +- src/main/resources/zombiesutils.png | Bin 0 -> 273 bytes update.json | 7 ++-- 10 files changed, 88 insertions(+), 49 deletions(-) create mode 100644 src/main/resources/zombiesutils.png diff --git a/README.md b/README.md index 2443425..04d0b0b 100644 --- a/README.md +++ b/README.md @@ -12,21 +12,23 @@ Hello, I am currently working on this mod. More features will come. For now it h ## For Users The timer automatically splits every round. The PB/Segment recorder automatically distinguishes maps and difficulties, but not player count. ### Config -- Language: The selected Hypixel language. Currently supports EN,FR,DE. -- Timer: - - Default Category: The record-category to be selected when starting the game. - - PB Announcements: Whether to show **\*\*\*NEW PERSONAL BEST\*\*\*** on PB in summaries. -- SST: +- `Language`: The selected Hypixel language. Currently supports EN,FR,DE. +- ###### Timer: + - `Default Category`: The record-category to be selected when starting the game. + - `PB Announcements`: Whether to show **\*\*\*NEW PERSONAL BEST\*\*\*** on PB in summaries. +- ###### SST: - Enabled: Enables / disables this feature. - Auditory: A List of tick offsets that a sound should be played. Default (-40, -20, 0) means 2s and 1s in advance, as well as on spawn. - RL pre-timing: During RL mode, how much SST times sohuld be offsetted. Defaults to 1.4s earlier. Affects HUD as well as auditory. - Truncate: Whether to show passed rounds in the HUD. -- SLA: - - Enabled: Whether the SLA HUD should automatically be shown when starting a game. - - Truncate: Whether inactive windows and rooms should be shown. -- Macro Message: The Message to be sent when pressing the Chat Macro Key. Do NOT use "§" as symbol. -- Player Visibility: Whether to enable PlayerVisibility by default. -- CPS Counter: A simple CPS Counter which shows the amount of clicks within the last 20 gameticks. +- ###### SLA: + - `Enabled`: Whether the SLA HUD should automatically be shown when starting a game. + - `Truncate`: Whether inactive windows and rooms should be shown. +- ###### Player Visibility: + - `Enabled`: Whether to enable PlayerVisibility by default. + - `Range`: The range within which players are hidden while enabled. +- `Macro Message`: The Message to be sent when pressing the Chat Macro Key. Do NOT use "§" as symbol. +- `CPS Counter`: A simple CPS Counter which shows the amount of clicks within the last 20 gameticks. ### Commands - /category \ - Switches to the category called name. All recorded times are bound to its category. Tabcomplete suggests already existing categories, but you can insert a new (clean) one as well. - Examples: @@ -37,9 +39,10 @@ The timer automatically splits every round. The PB/Segment recorder automaticall - /sla off - Disables the SLA hud - /sla map \ - forcefully set the map - /sla quick \ - - /sla rotate - rotates all windows around the axis (0,y,0) - - /sla mirror \ - mirrors all windows along the plane (0,y,z) or (x,y,0) - - /sla offset \ \ \ - set an offset, allowing you to use sla on map-recreations, such as housings + - useless for most players: + - /sla rotate - rotates all windows around the axis (0,y,0) + - /sla mirror \ - mirrors all windows along the plane (0,y,z) or (x,y,0) + - /sla offset \ \ \ - set an offset, allowing you to use sla on map-recreations, such as housings - /zombiesutils \ - /zombiesutils timer \ - /zombiesutils timer kill - Stops the running timer completely @@ -50,4 +53,4 @@ The timer automatically splits every round. The PB/Segment recorder automaticall - RL Mode: Toggles usage of the rocket launcher mode spawn-time offset. - Player Visibility: Toggles whether to show players that are within a 4 block radius. ### Extra -- Managing split-categories: In your game directory is a folder called "zombies" which contains the folder "splits". You can simply rename or delete the folders inside "splits". You can also edit your splits, the data is stored as a list of ticks inside the MAP_DIFFICULTY.times files, a simple text editor (such as Notepad on Windows) should be able to edit it (UTF-16 encoded text). The other subfolder, runs, logs all the splits for every run you play. +- Managing split-categories: In your game directory (aka `.minecraft`) is a folder called `zombies` which contains the folder `splits`. You can simply rename or delete the folders inside `splits`, they represent your categories. You can also edit your splits, the data is stored as a list of ticks inside the `MAP_DIFFICULTY.times` files, a simple text editor (such as Notepad on Windows) should be able to edit it (UTF-16 encoded text). The other subfolder, runs, logs all the splits for every run you play. diff --git a/gradle.properties b/gradle.properties index f9ac0bf..3230223 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx2g baseGroup = com.github.stachelbeere1248.zombiesutils mcVersion = 1.8.9 modid = zombiesutils -version = 1.3.6 \ No newline at end of file +version = 1.3.6-PRE_1 \ No newline at end of file diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/config/ZombiesUtilsConfig.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/config/ZombiesUtilsConfig.java index 6af7def..560f478 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/config/ZombiesUtilsConfig.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/config/ZombiesUtilsConfig.java @@ -1,6 +1,5 @@ package com.github.stachelbeere1248.zombiesutils.config; -import com.github.stachelbeere1248.zombiesutils.ZombiesUtils; import com.github.stachelbeere1248.zombiesutils.utils.LanguageSupport; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; @@ -27,6 +26,7 @@ public class ZombiesUtilsConfig { private Property cpsCounter; private Property announcePB; private Property playerVis; + private Property playerVisRange; public ZombiesUtilsConfig(Configuration config) { this.config = config; @@ -34,9 +34,7 @@ public class ZombiesUtilsConfig { } private void read() { - ZombiesUtils.getInstance().getLogger().debug("Loading config..."); config.load(); - ZombiesUtils.getInstance().getLogger().debug("Config loaded."); //SST sstHud = config.get( @@ -99,6 +97,22 @@ public class ZombiesUtilsConfig { "Whether to announce PBs." ); + //Player Visibility + playerVis = config.get( + "PlayerVis", + "default", + false, + "If players should always be visible" + ); + playerVisRange = config.get( + "PlayerVis", + "range", + 4, + "The range within which players are hidden", + 0, + 50 + ); + //ROOT language = config.get( @@ -114,12 +128,6 @@ public class ZombiesUtilsConfig { "T", "The Text to be sent when pressing the chat-macro hotkey" ); - playerVis = config.get( - Configuration.CATEGORY_GENERAL, - "playervis", - false, - "If players should always be visible" - ); cpsCounter = config.get( Configuration.CATEGORY_GENERAL, "cps", @@ -150,6 +158,12 @@ public class ZombiesUtilsConfig { new CustomConfigElement("PB announcements", announcePB) ); } + private List getPlayerVisElements() { + return Arrays.asList( + new CustomConfigElement("Enabled", playerVis), + new CustomConfigElement("Range", playerVisRange) + ); + } List getRootElements() { return Arrays.asList( @@ -157,8 +171,8 @@ public class ZombiesUtilsConfig { new DummyConfigElement.DummyCategoryElement("Timer", "", getTimerElements()), new DummyConfigElement.DummyCategoryElement("SST", "", getSpawntimeElements()), new DummyConfigElement.DummyCategoryElement("SLA", "", getSlaElements()), + new DummyConfigElement.DummyCategoryElement("Player Visibility", "", getPlayerVisElements()), new CustomConfigElement("Macro message", chatMacro), - new CustomConfigElement("Player visibility", playerVis), new CustomConfigElement("CPS counter", cpsCounter) ); @@ -210,6 +224,9 @@ public class ZombiesUtilsConfig { public boolean getPlayerVis() { return playerVis.getBoolean(); } + public int getPlayerVisRange() { + return playerVis.getInt(); + } @SubscribeEvent public void onConfigChange(ConfigChangedEvent.@NotNull OnConfigChangedEvent event) { diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/game/GameData.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/game/GameData.java index 202e37d..4759615 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/game/GameData.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/game/GameData.java @@ -23,7 +23,6 @@ public class GameData { } public Round getRound(@NotNull GameMode gameMode, int round) { - final Round[] selected; switch (gameMode) { case DEAD_END: return roundData[0][round-1]; diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/ChatHandler.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/ChatHandler.java index a2a3e82..cf3fb7f 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/ChatHandler.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/ChatHandler.java @@ -17,18 +17,19 @@ public class ChatHandler { @SubscribeEvent public void difficultyChange(@NotNull final ClientChatReceivedEvent event) { - ZombiesUtils.getInstance().getGameManager().getGame().ifPresent( - game -> { - String message = STRIP_COLOR_PATTERN.matcher(event.message.getUnformattedText()).replaceAll("").trim(); - if (message.contains(":")) return; - if (LanguageSupport.containsHard(message)) { - game.changeDifficulty(Difficulty.HARD); - } else if (LanguageSupport.containsRIP(message)) { - game.changeDifficulty(Difficulty.RIP); - } else if (LanguageSupport.isHelicopterIncoming(message)) { - game.helicopter(); + if (event.message.getUnformattedText().contains(":")) return; + final String message = STRIP_COLOR_PATTERN.matcher(event.message.getUnformattedText()).replaceAll("").trim(); + + if (LanguageSupport.containsHard(message)) { + ZombiesUtils.getInstance().getGameManager().setDifficulty(Difficulty.HARD); + } else if (LanguageSupport.containsRIP(message)) { + ZombiesUtils.getInstance().getGameManager().setDifficulty(Difficulty.RIP); + } else { + ZombiesUtils.getInstance().getGameManager().getGame().ifPresent( + game -> { + if (LanguageSupport.isHelicopterIncoming(message)) game.helicopter(); } - } - ); + ); + } } } diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/RenderPlayerHandler.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/RenderPlayerHandler.java index 9fc34c7..b3fd3a4 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/RenderPlayerHandler.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/handlers/RenderPlayerHandler.java @@ -24,7 +24,8 @@ public class RenderPlayerHandler { } private boolean inRange(@NotNull Vec3 playerOther) { - return playerOther.squareDistanceTo(Minecraft.getMinecraft().thePlayer.getPositionVector()) <= 16; + final int range = ZombiesUtils.getInstance().getConfig().getPlayerVisRange(); + return playerOther.squareDistanceTo(Minecraft.getMinecraft().thePlayer.getPositionVector()) <= range * range; } public void togglePlayerVisibility() { this.visible = !this.visible; diff --git a/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/GameManager.java b/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/GameManager.java index 1d13a4f..2b17ee7 100644 --- a/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/GameManager.java +++ b/src/main/java/com/github/stachelbeere1248/zombiesutils/timer/GameManager.java @@ -1,17 +1,20 @@ package com.github.stachelbeere1248.zombiesutils.timer; +import com.github.stachelbeere1248.zombiesutils.game.enums.Difficulty; import com.github.stachelbeere1248.zombiesutils.game.enums.Map; import com.github.stachelbeere1248.zombiesutils.utils.InvalidMapException; import com.github.stachelbeere1248.zombiesutils.utils.ScoardboardException; import com.github.stachelbeere1248.zombiesutils.utils.Scoreboard; +import org.jetbrains.annotations.NotNull; import java.util.HashMap; -import java.util.List; import java.util.Optional; import java.util.Set; public class GameManager { private final HashMap GAMES; + private Optional queuedDifficulty = Optional.empty(); + private String queuedDifficultyServer = "INVALID"; public GameManager() { GAMES = new HashMap<>(); @@ -43,11 +46,25 @@ public class GameManager { public void splitOrNew(int round) throws ScoardboardException, InvalidMapException { final String serverNumber = Scoreboard.getServerNumber().orElseThrow(ScoardboardException::new); if (GAMES.containsKey(serverNumber)) { - if (round == 0) GAMES.put(serverNumber, new Game(Map.getMap().orElseThrow(InvalidMapException::new), serverNumber)); + if (round == 0) newGame(serverNumber); else GAMES.get(serverNumber).pass(round); - } else { - GAMES.put(serverNumber, new Game(Map.getMap().orElseThrow(InvalidMapException::new), serverNumber, round + 1)); + } else newGame(serverNumber); + } + + private void newGame(@NotNull String serverNumber) throws InvalidMapException { + final Game game = new Game(Map.getMap().orElseThrow(InvalidMapException::new), serverNumber); + if (serverNumber.equals(queuedDifficultyServer)) { + this.queuedDifficulty.ifPresent(game::changeDifficulty); } + this.queuedDifficulty = Optional.empty(); + this.GAMES.put(serverNumber, game); + } + + public void setDifficulty(@NotNull Difficulty difficulty) { + this.queuedDifficultyServer = Scoreboard.getServerNumber().orElse("INVALID"); + if (this.GAMES.containsKey(this.queuedDifficultyServer)) { + this.GAMES.get(this.queuedDifficultyServer).changeDifficulty(difficulty); + } else this.queuedDifficulty = Optional.of(difficulty); } public Set getGames() { diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 232c651..6953cb8 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -2,7 +2,7 @@ { "modid": "${modid}", "name": "Zombies Utils", - "description": "", + "description": "An all-in-one mod for Hypixel Zombies. Targets legit speed-runners.", "version": "${version}", "mcversion": "${mcversion}", "url": "https://github.com/Stachelbeere1248/zombies-utils", @@ -11,7 +11,7 @@ "Stachelbeere1248" ], "credits": "Seosean, thamid-23", - "logoFile": "", + "logoFile": "zombiesutils.png", "screenshots": [], "dependencies": [] } diff --git a/src/main/resources/zombiesutils.png b/src/main/resources/zombiesutils.png new file mode 100644 index 0000000000000000000000000000000000000000..bbe153f7c2681338faa232ee3b8b2978da14139a GIT binary patch literal 273 zcmeAS@N?(olHy`uVBq!ia0vp^3qY8K8Aw(>tdav#asfUeu0WbYRY60J+tW-`ebX#H zdo%6hYdX`_GyLR?U!Pv``qwj{3dWKkzhDN3XE)M-oQ0k)jv*CsZ?8J?9&(Uq3Dmjb zq?^FV9TCADv7&XCDl=#O&6b?1hnwCDf5@A>^N+gcq<8z7m>Su${dMo!ZT%9oKGXYh zlS9JF)8(%Amu96gHy$Xw9#R}5B*5`zt?t^DcG;c|3LkPy*N4n!WntoP*5>A5;bXhr zsO!td)cE+|*9Y^|fLcC2_;qR)0}B&-v$P2#2g^JO83B%%;7Fj(m`U?id`ddeeS3#J P(6J1ju6{1-oD!M