diff --git a/src/main/java/keystrokesmod/module/ModuleManager.java b/src/main/java/keystrokesmod/module/ModuleManager.java index 9ded6eb4..a52d5a57 100644 --- a/src/main/java/keystrokesmod/module/ModuleManager.java +++ b/src/main/java/keystrokesmod/module/ModuleManager.java @@ -92,6 +92,7 @@ public class ModuleManager { public static StaffDetector staffDetector; public static AutoRespawn autoRespawn; public static Clutch clutch; + public static Ambience ambience; public void register() { this.addModule(autoClicker = new AutoClicker()); @@ -214,6 +215,7 @@ public void register() { this.addModule(staffDetector = new StaffDetector()); this.addModule(new AutoWeapon()); this.addModule(autoRespawn = new AutoRespawn()); + this.addModule(ambience = new Ambience()); antiBot.enable(); commandChat.enable(); modules.sort(Comparator.comparing(Module::getPrettyName)); diff --git a/src/main/java/keystrokesmod/module/impl/render/Ambience.java b/src/main/java/keystrokesmod/module/impl/render/Ambience.java new file mode 100644 index 00000000..b6793cab --- /dev/null +++ b/src/main/java/keystrokesmod/module/impl/render/Ambience.java @@ -0,0 +1,82 @@ +package keystrokesmod.module.impl.render; + +import keystrokesmod.event.PreMotionEvent; +import keystrokesmod.event.ReceivePacketEvent; +import keystrokesmod.module.Module; +import keystrokesmod.module.setting.impl.ModeSetting; +import keystrokesmod.module.setting.impl.SliderSetting; +import net.minecraft.network.play.server.S03PacketTimeUpdate; +import net.minecraft.network.play.server.S2BPacketChangeGameState; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +public class Ambience extends Module { + private final SliderSetting time; + private final SliderSetting speed; + private final ModeSetting weather; + + + public Ambience() { + super("Ambience", category.render); + this.registerSetting(time = new SliderSetting("Time", 0,0, 24000, 10)); + this.registerSetting(speed = new SliderSetting("Speed", 0,0, 20, 1)); + + String[] MODES = new String[]{"Unchanged", "Clear", "Rain"}; + this.registerSetting(weather = new ModeSetting("Weather", MODES, 0)); + } + + @Override + public void onDisable() { + mc.theWorld.setRainStrength(0); + mc.theWorld.getWorldInfo().setCleanWeatherTime(Integer.MAX_VALUE); + mc.theWorld.getWorldInfo().setRainTime(0); + mc.theWorld.getWorldInfo().setThunderTime(0); + mc.theWorld.getWorldInfo().setRaining(false); + mc.theWorld.getWorldInfo().setThundering(false); + } + + @SubscribeEvent + public void onRenderTick(TickEvent.RenderTickEvent event) { + mc.theWorld.setWorldTime((long) (time.getInput() + (System.currentTimeMillis() * speed.getInput()))); + } + + @SubscribeEvent + public void onPreMotion(PreMotionEvent event) { + if (mc.thePlayer.ticksExisted % 20 == 0) { + + switch ((int) this.weather.getInput()) { + case 1: { + mc.theWorld.setRainStrength(0); + mc.theWorld.getWorldInfo().setCleanWeatherTime(Integer.MAX_VALUE); + mc.theWorld.getWorldInfo().setRainTime(0); + mc.theWorld.getWorldInfo().setThunderTime(0); + mc.theWorld.getWorldInfo().setRaining(false); + mc.theWorld.getWorldInfo().setThundering(false); + break; + } + case 2: + mc.theWorld.setRainStrength(1); + mc.theWorld.getWorldInfo().setCleanWeatherTime(0); + mc.theWorld.getWorldInfo().setRainTime(Integer.MAX_VALUE); + mc.theWorld.getWorldInfo().setThunderTime(Integer.MAX_VALUE); + mc.theWorld.getWorldInfo().setRaining(true); + mc.theWorld.getWorldInfo().setThundering(false); + } + } + } + + @SubscribeEvent + public void onReceivePacket(ReceivePacketEvent event) { + if (event.getPacket() instanceof S03PacketTimeUpdate) { + event.setCanceled(true); + } + + else if (event.getPacket() instanceof S2BPacketChangeGameState && this.weather.getInput() != 0) { + S2BPacketChangeGameState s2b = (S2BPacketChangeGameState) event.getPacket(); + + if (s2b.getGameState() == 1 || s2b.getGameState() == 2) { + event.setCanceled(true); + } + } + } +} diff --git a/src/main/java/keystrokesmod/utility/Commands.java b/src/main/java/keystrokesmod/utility/Commands.java index 44379cf4..1945e077 100644 --- a/src/main/java/keystrokesmod/utility/Commands.java +++ b/src/main/java/keystrokesmod/utility/Commands.java @@ -43,7 +43,9 @@ public static void rCMD(@NotNull String c) { List args = Arrays.asList(c.split(" ")); // maybe bug boolean hasArgs = args.size() > 1; String n; - if (args.get(0).equals("setkey")) { + String firstArg = args.get(0).toLowerCase(); + + if (firstArg.equals("setkey")) { if (!hasArgs) { print(invSyn, 1); return; @@ -65,7 +67,7 @@ public static void rCMD(@NotNull String c) { } }); - } else if (args.get(0).equals("nick")) { + } else if (firstArg.equals("nick")) { if (!hasArgs) { print(invSyn, 1); return; @@ -84,7 +86,7 @@ public static void rCMD(@NotNull String c) { DuelsStats.nick = args.get(1); print("&aNick has been set to:", 1); print("\"" + DuelsStats.nick + "\"", 0); - } else if (args.get(0).equals("cname")) { + } else if (firstArg.equals("cname")) { if (!hasArgs) { print(invSyn, 1); return; @@ -99,7 +101,7 @@ public static void rCMD(@NotNull String c) { print("&a" + Utils.uf("name") + "Nick has been set to:".substring(4), 1); print("\"" + NameHider.n + "\"", 0); - } else if (args.get(0).equals(FakeChat.command)) { + } else if (firstArg.equals(FakeChat.command)) { if (!hasArgs) { print(invSyn, 1); return; @@ -113,7 +115,7 @@ public static void rCMD(@NotNull String c) { FakeChat.msg = n; print("&aMessage set!", 1); - } else if (args.get(0).equals("duels")) { + } else if (firstArg.equals("duels")) { if (!hasArgs) { print(invSyn, 1); return; @@ -151,7 +153,7 @@ public static void rCMD(@NotNull String c) { } }); - } else if (args.get(0).equals("setspeed")) { + } else if (firstArg.equals("setspeed")) { if (!hasArgs) { print(invSyn, 1); return; @@ -184,7 +186,7 @@ public static void rCMD(@NotNull String c) { } print("&aSet speed to ", 1); print(args.get(2), 0); - } else if (args.get(0).equals("setvelocity")) { + } else if (firstArg.equals("setvelocity")) { if (!hasArgs) { print(invSyn, 1); return; @@ -225,11 +227,11 @@ public static void rCMD(@NotNull String c) { print("&aSet " + args.get(1) + " velocity to ", 1); print(args.get(2), 0); - } else if (args.get(0).equals("ping")) { + } else if (firstArg.equals("ping")) { Ping.checkPing(); - } else if (args.get(0).equals("clear")) { + } else if (firstArg.equals("clear")) { rs.clear(); - } else if (args.get(0).equals("hide")) { + } else if (firstArg.equals("hide")) { if (!hasArgs) { print(invSyn, 1); return; @@ -247,7 +249,7 @@ public static void rCMD(@NotNull String c) { print("&a" + module.getName() + " is now hidden in HUD", 1); } } - } else if (args.get(0).equals("show")) { + } else if (firstArg.equals("show")) { if (!hasArgs) { print(invSyn, 1); return; @@ -265,7 +267,7 @@ public static void rCMD(@NotNull String c) { print("&a" + module.getName() + " is now visible in HUD", 1); } } - } else if (args.get(0).equals("panic")) { + } else if (firstArg.equals("panic")) { List modulesToDisable = new ArrayList<>(); for (Module m : Raven.getModuleManager().getModules()) { if (m.isEnabled()) { @@ -276,7 +278,7 @@ public static void rCMD(@NotNull String c) { m.disable(); } - }else if (args.get(0).equals("rename")) { + }else if (firstArg.equals("rename")) { if (!hasArgs) { print(invSyn, 1); return; @@ -294,14 +296,14 @@ public static void rCMD(@NotNull String c) { print("&a" + module.getName() + " is now called " + module.getRawPrettyName(), 1); } } - } else if (args.get(0).equals("say")) { + } else if (firstArg.equals("say")) { if (!hasArgs) { print(invSyn, 1); return; } - PacketUtils.sendPacketNoEvent(new C01PacketChatMessage(c.substring(args.get(0).length() + 1))); - } else if (args.get(0).equals("setBName")) { + PacketUtils.sendPacketNoEvent(new C01PacketChatMessage(c.substring(firstArg.length() + 1))); + } else if (firstArg.equals("setbname")) { if (!hasArgs) { print(invSyn, 1); return; @@ -315,13 +317,13 @@ public static void rCMD(@NotNull String c) { HUD.bName = args.get(1); print("&aSet BName to " + HUD.bName, 1); - } else if (args.get(0).equals("binds")) { + } else if (firstArg.equals("binds")) { for (Module module : Raven.getModuleManager().getModules()) { if (module.getKeycode() != 0) { print(ChatFormatting.AQUA + module.getName() + ": " + Keyboard.getKeyName(module.getKeycode()), 1); } } - } else if (args.get(0).equals("bind")) { + } else if (firstArg.equals("bind")) { if (!hasArgs) { print(invSyn, 1); return; @@ -352,7 +354,7 @@ public static void rCMD(@NotNull String c) { targetModule.setBind(keyCode); print(ChatFormatting.GREEN + "Bind '" + ChatFormatting.RESET + args.get(2) + ChatFormatting.GREEN + "' to " + targetModule.getPrettyName() + ".", 1); - } else if (args.get(0).equals("friend") || args.get(0).equals("f")) { + } else if (firstArg.equals("friend") || firstArg.equals("f")) { if (!hasArgs) { print(invSyn, 1); return; @@ -375,7 +377,7 @@ public static void rCMD(@NotNull String c) { } else { print("&aRemoved friend: " + args.get(1), 1); } - } else if (args.get(0).equals("enemy") || args.get(0).equals("e")) { + } else if (firstArg.equals("enemy") || firstArg.equals("e")) { if (!hasArgs) { print(invSyn, 1); return; @@ -396,10 +398,10 @@ public static void rCMD(@NotNull String c) { if (!added) { print("&aRemoved enemy: " + args.get(1), 1); } - } else if (args.get(0).equals("Debug".toLowerCase())) { + } else if (firstArg.equals("Debug".toLowerCase())) { Raven.debugger = !Raven.debugger; print("Debug " + (Raven.debugger ? "enabled" : "disabled") + ".", 1); - } else if (args.get(0).equals("profiles") || args.get(0).equals("p")) { + } else if (firstArg.equals("profiles") || firstArg.equals("p")) { if (!hasArgs) { print("&aAvailable profiles:", 1); if (Raven.profileManager.profiles.isEmpty()) { @@ -458,8 +460,8 @@ public static void rCMD(@NotNull String c) { } print("&cInvalid profile.", 1); } - } else if (!args.get(0).equals("help") && !args.get(0).equals("?")) { - if (args.get(0).equals("shoutout")) { + } else if (!firstArg.equals("help") && !firstArg.equals("?")) { + if (firstArg.equals("shoutout")) { print("&eCelebrities:", 1); print("- hevex", 0); print("- jc", 0);