From 325c28237728ae59f5400186aa6aff08a4156f8a Mon Sep 17 00:00:00 2001 From: Roman Danilov Date: Thu, 11 Apr 2024 18:26:42 +0500 Subject: [PATCH] Fix https://github.com/Nekiplay/MeteorPlus/issues/112 --- src/main/java/nekiplay/MixinPlugin.java | 12 +- .../java/nekiplay/bozeplus/BozePlusAddon.java | 11 +- .../modules/movement/nofall/NoFallMode.java | 27 ++ .../modules/movement/nofall/NoFallModes.java | 5 + .../modules/movement/nofall/NoFallPlus.java | 64 +++ .../movement/nofall/modes/MatrixNew.java | 14 + .../modules/movement/spider/SpiderMode.java | 25 ++ .../modules/movement/spider/SpiderModes.java | 12 + .../modules/movement/spider/SpiderPlus.java | 119 +----- .../modules/movement/spider/modes/Matrix.java | 122 ++++++ .../nekiplay/meteorplus/MeteorPlusAddon.java | 15 +- .../modules/movement/noslow/NoSlowMode.java | 2 + .../modules/movement/noslow/NoSlowModes.java | 3 +- .../modules/movement/noslow/NoSlowPlus.java | 6 + .../modules/movement/noslow/modes/Matrix.java | 21 + .../DefaultSettingsWidgetFactoryMixin.java | 2 +- .../LeftRightSettingsScreenMixin.java | 2 +- .../{ => gui}/ModulesScreenMixin.java | 2 +- .../{ => gui}/WBlockPosEditMixin.java | 2 +- .../{ => gui}/WMeteorModuleMixin.java | 2 +- .../{ => gui}/WPressableMixin.java | 2 +- .../{ => modules}/ModuleMixin.java | 2 +- .../{ => utils/misc}/KeybindMixin.java | 2 +- .../utils/misc/MeteorStarscriptMixin.java | 318 -------------- .../meteorplus/settings/ConfigModifier.java | 404 +++++++++++++++++- src/main/resources/meteorplus.mixins.json | 17 +- 26 files changed, 762 insertions(+), 451 deletions(-) create mode 100644 src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/NoFallMode.java create mode 100644 src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/NoFallModes.java create mode 100644 src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/NoFallPlus.java create mode 100644 src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/modes/MatrixNew.java create mode 100644 src/main/java/nekiplay/bozeplus/features/modules/movement/spider/SpiderMode.java create mode 100644 src/main/java/nekiplay/bozeplus/features/modules/movement/spider/SpiderModes.java create mode 100644 src/main/java/nekiplay/bozeplus/features/modules/movement/spider/modes/Matrix.java create mode 100644 src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/modes/Matrix.java rename src/main/java/nekiplay/meteorplus/mixin/meteorclient/{ => gui}/DefaultSettingsWidgetFactoryMixin.java (94%) rename src/main/java/nekiplay/meteorplus/mixin/meteorclient/{ => gui}/LeftRightSettingsScreenMixin.java (98%) rename src/main/java/nekiplay/meteorplus/mixin/meteorclient/{ => gui}/ModulesScreenMixin.java (97%) rename src/main/java/nekiplay/meteorplus/mixin/meteorclient/{ => gui}/WBlockPosEditMixin.java (98%) rename src/main/java/nekiplay/meteorplus/mixin/meteorclient/{ => gui}/WMeteorModuleMixin.java (96%) rename src/main/java/nekiplay/meteorplus/mixin/meteorclient/{ => gui}/WPressableMixin.java (94%) rename src/main/java/nekiplay/meteorplus/mixin/meteorclient/{ => modules}/ModuleMixin.java (95%) rename src/main/java/nekiplay/meteorplus/mixin/meteorclient/{ => utils/misc}/KeybindMixin.java (89%) delete mode 100644 src/main/java/nekiplay/meteorplus/mixin/meteorclient/utils/misc/MeteorStarscriptMixin.java diff --git a/src/main/java/nekiplay/MixinPlugin.java b/src/main/java/nekiplay/MixinPlugin.java index d3fd4320..0a1ae150 100644 --- a/src/main/java/nekiplay/MixinPlugin.java +++ b/src/main/java/nekiplay/MixinPlugin.java @@ -15,7 +15,13 @@ public class MixinPlugin implements IMixinConfigPlugin { private static final String mixinPackageMeteorPlus = "nekiplay.meteorplus.mixin"; private static final String mixinPackageBozePlus = "nekiplay.bozeplus.mixin"; + public static boolean isMeteorClient = false; + public static boolean isMeteorRejects= false; + + public static boolean isBozeAPI= false; + public static boolean isFutureClient = false; + public static boolean isBaritonePresent = false; public static boolean isJourneyMapPresent = false; public static boolean isXaeroWorldMapresent = false; @@ -23,9 +29,6 @@ public class MixinPlugin implements IMixinConfigPlugin { public static boolean isXaeroPlusMapresent = false; public static boolean isLitematicaMapresent = false; public static boolean isWhereIsIt = false; - public static boolean isMeteorRejects= false; - - public static boolean isBozeAPI= false; @Override public void onLoad(String mixinPackage) { @@ -33,6 +36,7 @@ public void onLoad(String mixinPackage) { isMeteorClient = loader.isModLoaded("meteor-client"); isBozeAPI = loader.isModLoaded("boze-api"); + isFutureClient = loader.isModLoaded("future"); isMeteorRejects = loader.isModLoaded("meteor-rejects"); @@ -78,7 +82,7 @@ else if (mixinClassName.startsWith(mixinPackageMeteorPlus + ".minecraft")) { } else if (mixinClassName.startsWith(mixinPackageBozePlus + ".minecraft")) { - return isBozeAPI; + return isBozeAPI && !isMeteorClient; } return false; diff --git a/src/main/java/nekiplay/bozeplus/BozePlusAddon.java b/src/main/java/nekiplay/bozeplus/BozePlusAddon.java index 19aadb00..2a7fe37b 100644 --- a/src/main/java/nekiplay/bozeplus/BozePlusAddon.java +++ b/src/main/java/nekiplay/bozeplus/BozePlusAddon.java @@ -12,7 +12,6 @@ import dev.boze.api.exception.AddonInitializationException; import meteordevelopment.orbit.EventBus; import meteordevelopment.orbit.IEventBus; -import nekiplay.MixinPlugin; import nekiplay.bozeplus.features.modules.movement.spider.SpiderPlus; import nekiplay.bozeplus.impl.BozePlusDispatcher; import nekiplay.bozeplus.impl.BozePlusModule; @@ -35,7 +34,7 @@ public static BozePlusAddon getInstance() { public final AddonMetadata metadata = new AddonMetadata( "boze-plus", "Boze Plus", - "An example addon for Boze", + "Meteor Plus modules for Boze", new AddonVersion(1, 0, 0)); private final ArrayList modules = new ArrayList<>(); @@ -49,6 +48,11 @@ public void onInitialize() { } } + private void addModule(AddonModule module) { + modules.add(module); + EVENT_BUS.subscribe(module); + } + @Override public AddonMetadata getMetadata() { return metadata; @@ -65,8 +69,7 @@ public boolean initialize() { SpiderPlus spiderPlus = new SpiderPlus(); - modules.add(spiderPlus); - EVENT_BUS.subscribe(spiderPlus); + addModule(spiderPlus); return true; } diff --git a/src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/NoFallMode.java b/src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/NoFallMode.java new file mode 100644 index 00000000..3507f311 --- /dev/null +++ b/src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/NoFallMode.java @@ -0,0 +1,27 @@ +package nekiplay.bozeplus.features.modules.movement.nofall; + +import dev.boze.api.event.EventTick; +import nekiplay.bozeplus.events.packets.PacketEvent; +import nekiplay.bozeplus.features.modules.movement.spider.SpiderPlus; +import net.minecraft.client.MinecraftClient; + +public class NoFallMode { + protected final MinecraftClient mc; + protected final NoFallPlus settings; + private final NoFallModes type; + + public NoFallMode(NoFallModes type, NoFallPlus settings) { + this.settings = settings; + this.mc = MinecraftClient.getInstance(); + this.type = type; + } + + public void onSendPacket(PacketEvent.Send event) {} + public void onSentPacket(PacketEvent.Sent event) {} + + public void onTickEventPre(EventTick.Pre event) {} + public void onTickEventPost(EventTick.Post event) {} + + public void onActivate() {} + public void onDeactivate() {} +} diff --git a/src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/NoFallModes.java b/src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/NoFallModes.java new file mode 100644 index 00000000..0900a707 --- /dev/null +++ b/src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/NoFallModes.java @@ -0,0 +1,5 @@ +package nekiplay.bozeplus.features.modules.movement.nofall; + +public enum NoFallModes { + MatrixNew, +} diff --git a/src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/NoFallPlus.java b/src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/NoFallPlus.java new file mode 100644 index 00000000..8ee9a7af --- /dev/null +++ b/src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/NoFallPlus.java @@ -0,0 +1,64 @@ +package nekiplay.bozeplus.features.modules.movement.nofall; + +import dev.boze.api.addon.module.ToggleableModule; +import dev.boze.api.event.EventTick; +import dev.boze.api.setting.SettingMode; +import meteordevelopment.orbit.EventHandler; +import nekiplay.bozeplus.events.packets.PacketEvent; +import nekiplay.bozeplus.features.modules.movement.nofall.modes.MatrixNew; + +import java.util.ArrayList; + +public class NoFallPlus extends ToggleableModule { + private final SettingMode mode = new SettingMode("Mode", "Bypass mode", new ArrayList<>() {{ + add("Matrix"); + }}); + + public NoFallPlus() { + super("No Fall+", "Bypass no fall"); + elements.add(mode); + onNoFallModeChanged(mode.getMode()); + } + + @Override + protected void onEnable() { + onNoFallModeChanged(mode.getMode()); + if (currentMode != null) { + currentMode.onActivate(); + } + } + + @EventHandler + public void onSendPacket(PacketEvent.Send event) { + if (currentMode != null) { + currentMode.onSendPacket(event); + } + } + + @EventHandler + public void onSentPacket(PacketEvent.Sent event) { + if (currentMode != null) { + currentMode.onSentPacket(event); + } + } + + @EventHandler + public void onTickEventPre(EventTick.Pre event) { + if (currentMode != null) { + currentMode.onTickEventPre(event); + } + } + + @EventHandler + public void onTickEventPost(EventTick.Post event) { + if (currentMode != null) { + currentMode.onTickEventPost(event); + } + } + private NoFallMode currentMode = null; + private void onNoFallModeChanged(int mode) { + switch (mode) { + case 0 -> currentMode = new MatrixNew(this); + } + } +} diff --git a/src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/modes/MatrixNew.java b/src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/modes/MatrixNew.java new file mode 100644 index 00000000..afdeb553 --- /dev/null +++ b/src/main/java/nekiplay/bozeplus/features/modules/movement/nofall/modes/MatrixNew.java @@ -0,0 +1,14 @@ +package nekiplay.bozeplus.features.modules.movement.nofall.modes; + +import nekiplay.Main; +import nekiplay.bozeplus.features.modules.movement.nofall.NoFallMode; +import nekiplay.bozeplus.features.modules.movement.nofall.NoFallModes; +import nekiplay.bozeplus.features.modules.movement.nofall.NoFallPlus; +import nekiplay.bozeplus.features.modules.movement.spider.SpiderModes; +import nekiplay.bozeplus.features.modules.movement.spider.SpiderPlus; + +public class MatrixNew extends NoFallMode { + public MatrixNew(NoFallPlus noFallPlus) { + super(NoFallModes.MatrixNew, noFallPlus); + } +} diff --git a/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/SpiderMode.java b/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/SpiderMode.java new file mode 100644 index 00000000..468f682a --- /dev/null +++ b/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/SpiderMode.java @@ -0,0 +1,25 @@ +package nekiplay.bozeplus.features.modules.movement.spider; +import dev.boze.api.event.EventTick; +import nekiplay.bozeplus.events.packets.PacketEvent; +import net.minecraft.client.MinecraftClient; + +public class SpiderMode { + protected final MinecraftClient mc; + protected final SpiderPlus settings; + private final SpiderModes type; + + public SpiderMode(SpiderModes type, SpiderPlus settings) { + this.settings = settings; + this.mc = MinecraftClient.getInstance(); + this.type = type; + } + + public void onSendPacket(PacketEvent.Send event) {} + public void onSentPacket(PacketEvent.Sent event) {} + + public void onTickEventPre(EventTick.Pre event) {} + public void onTickEventPost(EventTick.Post event) {} + + public void onActivate() {} + public void onDeactivate() {} +} diff --git a/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/SpiderModes.java b/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/SpiderModes.java new file mode 100644 index 00000000..c89b539a --- /dev/null +++ b/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/SpiderModes.java @@ -0,0 +1,12 @@ +package nekiplay.bozeplus.features.modules.movement.spider; + +public enum SpiderModes { + Matrix_Lower_7, + Vulcan, + Elytra_clip; + + @Override + public String toString() { + return super.toString().replace('_', ' ').replaceAll("_Lower_", "<"); + } +} diff --git a/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/SpiderPlus.java b/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/SpiderPlus.java index 9e9e7a0e..4716f174 100644 --- a/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/SpiderPlus.java +++ b/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/SpiderPlus.java @@ -1,19 +1,11 @@ package nekiplay.bozeplus.features.modules.movement.spider; -import dev.boze.api.Globals; import dev.boze.api.addon.module.ToggleableModule; import dev.boze.api.event.EventTick; import dev.boze.api.setting.SettingMode; -import dev.boze.api.setting.SettingToggle; import meteordevelopment.orbit.EventHandler; import nekiplay.bozeplus.events.packets.PacketEvent; -import nekiplay.bozeplus.mixin.minecraft.PlayerMoveC2SPacketAccessor; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.util.math.Vec3d; +import nekiplay.bozeplus.features.modules.movement.spider.modes.Matrix; import java.util.ArrayList; @@ -23,122 +15,51 @@ public class SpiderPlus extends ToggleableModule { add("Matrix"); }}); - private int tick = 0; - private boolean modify = false; - private boolean start = false; - - private double startY = 0; - private double lastY = 0; - - private double coff = 0.0000000000326; - public SpiderPlus() { super("Spider", "Climb on walls"); elements.add(mode); + onSpiderModeChanged(mode.getMode()); } @Override protected void onEnable() { - - } - private boolean YGround(double height, double min, double max) { - String yString = String.valueOf(height); - yString = yString.substring(yString.indexOf(".")); - double y = Double.parseDouble(yString); - return y >= min && y <= max; - } - - private double RGround(double height) { - String yString = String.valueOf(height); - yString = yString.substring(yString.indexOf(".")); - return Double.parseDouble(yString); - } - private void work(Packet packet) { - if (modify) { - if (packet instanceof PlayerMoveC2SPacket move) { - assert MinecraftClient.getInstance().player != null; - double y = MinecraftClient.getInstance().player.getY(); - y = move.getY(y); - - if (YGround(y, RGround(startY) - 0.1, RGround(startY) + 0.1)) { - ((PlayerMoveC2SPacketAccessor) packet).setOnGround(true); - } - if (MinecraftClient.getInstance().player.isOnGround() && block) { - block = false; - startY = MinecraftClient.getInstance().player.getPos().y; - start = false; - } - } - } else { - assert MinecraftClient.getInstance().player != null; - if (MinecraftClient.getInstance().player.isOnGround() && block) { - block = false; - startY = MinecraftClient.getInstance().player.getPos().y; - start = false; - } + onSpiderModeChanged(mode.getMode()); + if (currentMode != null) { + currentMode.onActivate(); } } @EventHandler public void onSendPacket(PacketEvent.Send event) { - work(event.packet); + if (currentMode != null) { + currentMode.onSendPacket(event); + } } @EventHandler public void onSentPacket(PacketEvent.Sent event) { - work(event.packet); + if (currentMode != null) { + currentMode.onSentPacket(event); + } } - private boolean block = false; - @EventHandler public void onTickEventPre(EventTick.Pre event) { - if (modify) { - ClientPlayerEntity player = MinecraftClient.getInstance().player; - double y = player.getPos().y; - if (lastY == y && tick > 1) { - block = true; - } else { - lastY = y; - } + if (currentMode != null) { + currentMode.onTickEventPre(event); } } @EventHandler public void onTickEventPost(EventTick.Post event) { - ClientPlayerEntity player = MinecraftClient.getInstance().player; - assert player != null; - Vec3d pl_velocity = player.getVelocity(); - Vec3d pos = player.getPos(); - ClientPlayNetworkHandler h = MinecraftClient.getInstance().getNetworkHandler(); - modify = player.horizontalCollision; - if (MinecraftClient.getInstance().player.isOnGround()) { - block = false; - startY = MinecraftClient.getInstance().player.getPos().y; - start = false; - } - if (player.horizontalCollision) { - if (!start) { - start = true; - startY = MinecraftClient.getInstance().player.getPos().y; - lastY = MinecraftClient.getInstance().player.getY(); - } - if (!block) { - if (tick == 0) { - MinecraftClient.getInstance().player.setVelocity(pl_velocity.x, 0.41999998688698, pl_velocity.z); - tick = 1; - } else if (tick == 1) { - MinecraftClient.getInstance().player.setVelocity(pl_velocity.x, 0.41999998688698 - 0.08679999325 - coff, pl_velocity.z); - tick = 2; - } else if (tick == 2) { - MinecraftClient.getInstance().player.setVelocity(pl_velocity.x, 0.41999998688698 - 0.17186398826 - coff, pl_velocity.z); - tick = 0; - } - } + if (currentMode != null) { + currentMode.onTickEventPost(event); } - else { - modify = false; - tick = 0; + } + private SpiderMode currentMode = null; + private void onSpiderModeChanged(int mode) { + switch (mode) { + case 0 -> currentMode = new Matrix(this); } } } diff --git a/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/modes/Matrix.java b/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/modes/Matrix.java new file mode 100644 index 00000000..66fac832 --- /dev/null +++ b/src/main/java/nekiplay/bozeplus/features/modules/movement/spider/modes/Matrix.java @@ -0,0 +1,122 @@ +package nekiplay.bozeplus.features.modules.movement.spider.modes; + +import dev.boze.api.event.EventTick; +import nekiplay.bozeplus.features.modules.movement.spider.SpiderMode; +import nekiplay.bozeplus.features.modules.movement.spider.SpiderModes; +import nekiplay.bozeplus.features.modules.movement.spider.SpiderPlus; +import nekiplay.bozeplus.mixin.minecraft.PlayerMoveC2SPacketAccessor; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; +import net.minecraft.util.math.Vec3d; + +public class Matrix extends SpiderMode { + public Matrix(SpiderPlus spiderPlus) { + super(SpiderModes.Matrix_Lower_7, spiderPlus); + } + + private int tick = 0; + private boolean modify = false; + private boolean start = false; + private double startY = 0; + private double lastY = 0; + private double coff = 0.0000000000326; + private boolean block = false; + + @Override + public void onActivate() { + tick = 0; + start = false; + modify = false; + + assert mc.player != null; + startY = mc.player.getPos().y; + } + + private boolean YGround(double height, double min, double max) { + String yString = String.valueOf(height); + yString = yString.substring(yString.indexOf(".")); + double y = Double.parseDouble(yString); + return y >= min && y <= max; + } + + private double RGround(double height) { + String yString = String.valueOf(height); + yString = yString.substring(yString.indexOf(".")); + return Double.parseDouble(yString); + } + private void work(Packet packet) { + if (modify) { + if (packet instanceof PlayerMoveC2SPacket move) { + assert mc.player != null; + double y = mc.player.getY(); + y = move.getY(y); + + if (YGround(y, RGround(startY) - 0.1, RGround(startY) + 0.1)) { + ((PlayerMoveC2SPacketAccessor) packet).setOnGround(true); + } + if (mc.player.isOnGround() && block) { + block = false; + startY = mc.player.getPos().y; + start = false; + } + } + } else { + assert mc.player != null; + if (mc.player.isOnGround() && block) { + block = false; + startY = mc.player.getPos().y; + start = false; + } + } + } + + @Override + public void onTickEventPre(EventTick.Pre event) { + if (modify) { + ClientPlayerEntity player = mc.player; + double y = player.getPos().y; + if (lastY == y && tick > 1) { + block = true; + } else { + lastY = y; + } + } + } + + @Override + public void onTickEventPost(EventTick.Post event) { + ClientPlayerEntity player = mc.player; + assert player != null; + Vec3d pl_velocity = player.getVelocity(); + modify = player.horizontalCollision; + if (mc.player.isOnGround()) { + block = false; + startY = mc.player.getPos().y; + start = false; + } + if (player.horizontalCollision) { + if (!start) { + start = true; + startY = mc.player.getPos().y; + lastY = mc.player.getY(); + } + if (!block) { + if (tick == 0) { + mc.player.setVelocity(pl_velocity.x, 0.41999998688698, pl_velocity.z); + tick = 1; + } else if (tick == 1) { + mc.player.setVelocity(pl_velocity.x, 0.41999998688698 - 0.08679999325 - coff, pl_velocity.z); + tick = 2; + } else if (tick == 2) { + mc.player.setVelocity(pl_velocity.x, 0.41999998688698 - 0.17186398826 - coff, pl_velocity.z); + tick = 0; + } + } + } + else { + modify = false; + tick = 0; + } + } +} diff --git a/src/main/java/nekiplay/meteorplus/MeteorPlusAddon.java b/src/main/java/nekiplay/meteorplus/MeteorPlusAddon.java index 5369a87c..84ba10ed 100644 --- a/src/main/java/nekiplay/meteorplus/MeteorPlusAddon.java +++ b/src/main/java/nekiplay/meteorplus/MeteorPlusAddon.java @@ -94,6 +94,14 @@ public void onInitialize() { else { notFoundIntegrations.add("Journey Map"); } + + if (!isWhereIsIt) { + notFoundIntegrations.add("Where is it"); + } + else { + enabledIntegrations.add("Where is it"); + } + if (!isBaritonePresent) { notFoundBaritoneIntegrations.add("Freecam"); notFoundBaritoneIntegrations.add("Waypoints"); @@ -102,14 +110,9 @@ public void onInitialize() { else { enabledIntegrations.add("Freecam"); enabledIntegrations.add("Waypoints"); + enabledIntegrations.add("Goto+"); } - if (!isWhereIsIt) { - notFoundIntegrations.add("Where is it"); - } - else { - enabledIntegrations.add("Where is it"); - } if (!enabledIntegrations.isEmpty()) { LOG.info(METEOR_LOGPREFIX + " Enabling integrations for: " + String.join(", ", enabledIntegrations)); diff --git a/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/NoSlowMode.java b/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/NoSlowMode.java index 4fe24993..30a2b56a 100644 --- a/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/NoSlowMode.java +++ b/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/NoSlowMode.java @@ -1,5 +1,6 @@ package nekiplay.meteorplus.features.modules.movement.noslow; +import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.systems.modules.Modules; import nekiplay.meteorplus.events.PlayerUseMultiplierEvent; import net.minecraft.client.MinecraftClient; @@ -15,4 +16,5 @@ public NoSlowMode(NoSlowModes type) { this.type = type; } public void onUse(PlayerUseMultiplierEvent event) { } + public void onTickEventPre(TickEvent.Pre event) { } } diff --git a/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/NoSlowModes.java b/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/NoSlowModes.java index 3e781795..b17f7652 100644 --- a/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/NoSlowModes.java +++ b/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/NoSlowModes.java @@ -4,7 +4,8 @@ public enum NoSlowModes { Vanila, NCP_Strict, Grim_1dot8, - Grim_New; + Grim_New, + Matrix; @Override public String toString() { diff --git a/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/NoSlowPlus.java b/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/NoSlowPlus.java index e3ddd300..51723bc8 100644 --- a/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/NoSlowPlus.java +++ b/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/NoSlowPlus.java @@ -1,5 +1,6 @@ package nekiplay.meteorplus.features.modules.movement.noslow; +import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.DoubleSetting; import meteordevelopment.meteorclient.settings.EnumSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -96,4 +97,9 @@ private void onModeChanged(NoSlowModes mode) { private void onUse(PlayerUseMultiplierEvent event) { currentMode.onUse(event); } + + @EventHandler + private void onTickEventPre(TickEvent.Pre event) { + currentMode.onTickEventPre(event); + } } diff --git a/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/modes/Matrix.java b/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/modes/Matrix.java new file mode 100644 index 00000000..f1f1eb07 --- /dev/null +++ b/src/main/java/nekiplay/meteorplus/features/modules/movement/noslow/modes/Matrix.java @@ -0,0 +1,21 @@ +package nekiplay.meteorplus.features.modules.movement.noslow.modes; + +import meteordevelopment.meteorclient.events.world.TickEvent; +import nekiplay.meteorplus.features.modules.movement.noslow.NoSlowMode; +import nekiplay.meteorplus.features.modules.movement.noslow.NoSlowModes; +import nekiplay.meteorplus.features.modules.movement.noslow.NoSlowPlus; + +public class Matrix extends NoSlowMode { + public Matrix() { + super(NoSlowModes.Matrix); + } + + @Override + public void onTickEventPre(TickEvent.Pre event) { + if (mc.player.isUsingItem()) { + if (mc.player.isOnGround()) { + + } + } + } +} diff --git a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/DefaultSettingsWidgetFactoryMixin.java b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/DefaultSettingsWidgetFactoryMixin.java similarity index 94% rename from src/main/java/nekiplay/meteorplus/mixin/meteorclient/DefaultSettingsWidgetFactoryMixin.java rename to src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/DefaultSettingsWidgetFactoryMixin.java index 9045c488..3ae4a913 100644 --- a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/DefaultSettingsWidgetFactoryMixin.java +++ b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/DefaultSettingsWidgetFactoryMixin.java @@ -1,4 +1,4 @@ -package nekiplay.meteorplus.mixin.meteorclient; +package nekiplay.meteorplus.mixin.meteorclient.gui; import meteordevelopment.meteorclient.gui.DefaultSettingsWidgetFactory; import meteordevelopment.meteorclient.gui.GuiTheme; diff --git a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/LeftRightSettingsScreenMixin.java b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/LeftRightSettingsScreenMixin.java similarity index 98% rename from src/main/java/nekiplay/meteorplus/mixin/meteorclient/LeftRightSettingsScreenMixin.java rename to src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/LeftRightSettingsScreenMixin.java index 8238234a..c6308dd0 100644 --- a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/LeftRightSettingsScreenMixin.java +++ b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/LeftRightSettingsScreenMixin.java @@ -1,4 +1,4 @@ -package nekiplay.meteorplus.mixin.meteorclient; +package nekiplay.meteorplus.mixin.meteorclient.gui; import meteordevelopment.meteorclient.gui.GuiTheme; import meteordevelopment.meteorclient.gui.screens.settings.LeftRightListSettingScreen; diff --git a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/ModulesScreenMixin.java b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/ModulesScreenMixin.java similarity index 97% rename from src/main/java/nekiplay/meteorplus/mixin/meteorclient/ModulesScreenMixin.java rename to src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/ModulesScreenMixin.java index 1ce0e974..d5c9dcf3 100644 --- a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/ModulesScreenMixin.java +++ b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/ModulesScreenMixin.java @@ -1,4 +1,4 @@ -package nekiplay.meteorplus.mixin.meteorclient; +package nekiplay.meteorplus.mixin.meteorclient.gui; import meteordevelopment.meteorclient.gui.GuiTheme; import meteordevelopment.meteorclient.gui.screens.ModulesScreen; diff --git a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/WBlockPosEditMixin.java b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/WBlockPosEditMixin.java similarity index 98% rename from src/main/java/nekiplay/meteorplus/mixin/meteorclient/WBlockPosEditMixin.java rename to src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/WBlockPosEditMixin.java index 146104fb..992dd778 100644 --- a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/WBlockPosEditMixin.java +++ b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/WBlockPosEditMixin.java @@ -1,4 +1,4 @@ -package nekiplay.meteorplus.mixin.meteorclient; +package nekiplay.meteorplus.mixin.meteorclient.gui; import meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList; import meteordevelopment.meteorclient.gui.widgets.input.WBlockPosEdit; diff --git a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/WMeteorModuleMixin.java b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/WMeteorModuleMixin.java similarity index 96% rename from src/main/java/nekiplay/meteorplus/mixin/meteorclient/WMeteorModuleMixin.java rename to src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/WMeteorModuleMixin.java index 9252b79b..3660f352 100644 --- a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/WMeteorModuleMixin.java +++ b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/WMeteorModuleMixin.java @@ -1,4 +1,4 @@ -package nekiplay.meteorplus.mixin.meteorclient; +package nekiplay.meteorplus.mixin.meteorclient.gui; import meteordevelopment.meteorclient.gui.GuiThemes; import meteordevelopment.meteorclient.gui.tabs.Tabs; diff --git a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/WPressableMixin.java b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/WPressableMixin.java similarity index 94% rename from src/main/java/nekiplay/meteorplus/mixin/meteorclient/WPressableMixin.java rename to src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/WPressableMixin.java index f6e0aec0..d9cd1ca7 100644 --- a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/WPressableMixin.java +++ b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/gui/WPressableMixin.java @@ -1,4 +1,4 @@ -package nekiplay.meteorplus.mixin.meteorclient; +package nekiplay.meteorplus.mixin.meteorclient.gui; import meteordevelopment.meteorclient.gui.widgets.WWidget; import meteordevelopment.meteorclient.gui.widgets.pressable.WPressable; diff --git a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/ModuleMixin.java b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/modules/ModuleMixin.java similarity index 95% rename from src/main/java/nekiplay/meteorplus/mixin/meteorclient/ModuleMixin.java rename to src/main/java/nekiplay/meteorplus/mixin/meteorclient/modules/ModuleMixin.java index 921cae36..f8200f3b 100644 --- a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/ModuleMixin.java +++ b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/modules/ModuleMixin.java @@ -1,4 +1,4 @@ -package nekiplay.meteorplus.mixin.meteorclient; +package nekiplay.meteorplus.mixin.meteorclient.modules; import meteordevelopment.meteorclient.systems.modules.Module; import net.minecraft.nbt.NbtCompound; diff --git a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/KeybindMixin.java b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/utils/misc/KeybindMixin.java similarity index 89% rename from src/main/java/nekiplay/meteorplus/mixin/meteorclient/KeybindMixin.java rename to src/main/java/nekiplay/meteorplus/mixin/meteorclient/utils/misc/KeybindMixin.java index 8780b957..f0b909d1 100644 --- a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/KeybindMixin.java +++ b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/utils/misc/KeybindMixin.java @@ -1,4 +1,4 @@ -package nekiplay.meteorplus.mixin.meteorclient; +package nekiplay.meteorplus.mixin.meteorclient.utils.misc; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/utils/misc/MeteorStarscriptMixin.java b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/utils/misc/MeteorStarscriptMixin.java deleted file mode 100644 index f45a225a..00000000 --- a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/utils/misc/MeteorStarscriptMixin.java +++ /dev/null @@ -1,318 +0,0 @@ -package nekiplay.meteorplus.mixin.meteorclient.utils.misc; - -import meteordevelopment.meteorclient.mixin.ClientPlayerInteractionManagerAccessor; -import meteordevelopment.meteorclient.utils.Utils; -import meteordevelopment.meteorclient.utils.misc.HorizontalDirection; -import meteordevelopment.meteorclient.utils.misc.MeteorStarscript; -import meteordevelopment.meteorclient.utils.player.PlayerUtils; -import meteordevelopment.meteorclient.utils.world.Dimension; -import meteordevelopment.starscript.Starscript; -import meteordevelopment.starscript.value.Value; -import meteordevelopment.starscript.value.ValueMap; -import nekiplay.meteorplus.settings.ConfigModifier; -import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.network.packet.c2s.play.ClientStatusC2SPacket; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.registry.Registries; -import net.minecraft.stat.Stat; -import net.minecraft.stat.Stats; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import org.apache.commons.lang3.StringUtils; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.Arrays; -import java.util.stream.Collectors; - -import static meteordevelopment.meteorclient.MeteorClient.mc; -import static meteordevelopment.meteorclient.utils.misc.MeteorStarscript.popIdentifier; -import static meteordevelopment.meteorclient.utils.misc.MeteorStarscript.wrap; - -@Mixin(value = MeteorStarscript.class, remap = false, priority = 1001) -public class MeteorStarscriptMixin { - @Shadow - @Final - private static final BlockPos.Mutable BP = new BlockPos.Mutable(); - @Shadow - public static Starscript ss = new Starscript(); - @Inject(method = "init", at = @At("RETURN")) - private static void init(CallbackInfo ci) { - ss.set("camera", new ValueMap() - .set("pos", new ValueMap() - .set("_toString", () -> posString(false, true)) - .set("x", () -> Value.number(mc.gameRenderer.getCamera().getPos().x + ConfigModifier.get().x_spoof.get())) - .set("y", () -> Value.number(mc.gameRenderer.getCamera().getPos().y)) - .set("z", () -> Value.number(mc.gameRenderer.getCamera().getPos().z + ConfigModifier.get().z_spoof.get())) - ) - .set("opposite_dim_pos", new ValueMap() - .set("_toString", () -> posString(true, true)) - .set("x", () -> oppositeX(true)) - .set("y", () -> Value.number(mc.gameRenderer.getCamera().getPos().y)) - .set("z", () -> oppositeZ(true)) - ) - - .set("yaw", () -> yaw(true)) - .set("pitch", () -> pitch(true)) - .set("direction", () -> direction(true)) - ); - - // Player - ss.set("player", new ValueMap() - .set("_toString", () -> Value.string(mc.getSession().getUsername())) - .set("health", () -> Value.number(mc.player != null ? mc.player.getHealth() : 0)) - .set("absorption", () -> Value.number(mc.player != null ? mc.player.getAbsorptionAmount() : 0)) - .set("hunger", () -> Value.number(mc.player != null ? mc.player.getHungerManager().getFoodLevel() : 0)) - - .set("speed", () -> Value.number(Utils.getPlayerSpeed().horizontalLength())) - .set("speed_all", new ValueMap() - .set("_toString", () -> Value.string(mc.player != null ? Utils.getPlayerSpeed().toString() : "")) - .set("x", () -> Value.number(mc.player != null ? Utils.getPlayerSpeed().x : 0)) - .set("y", () -> Value.number(mc.player != null ? Utils.getPlayerSpeed().y : 0)) - .set("z", () -> Value.number(mc.player != null ? Utils.getPlayerSpeed().z : 0)) - ) - - .set("breaking_progress", () -> Value.number(mc.interactionManager != null ? ((ClientPlayerInteractionManagerAccessor) mc.interactionManager).getBreakingProgress() : 0)) - .set("biome", MeteorStarscriptMixin::biome) - - .set("dimension", () -> Value.string(PlayerUtils.getDimension().name())) - .set("opposite_dimension", () -> Value.string(PlayerUtils.getDimension().opposite().name())) - - - .set("pos", new ValueMap() - .set("_toString", () -> posString(false, false)) - .set("x", () -> Value.number(mc.player != null ? mc.player.getX() + ConfigModifier.get().x_spoof.get() : 0)) - .set("y", () -> Value.number(mc.player != null ? mc.player.getY() : 0)) - .set("z", () -> Value.number(mc.player != null ? mc.player.getZ() + ConfigModifier.get().z_spoof.get(): 0)) - ) - .set("opposite_dim_pos", new ValueMap() - .set("_toString", () -> posString(true, false)) - .set("x", () -> oppositeX(false)) - .set("y", () -> Value.number(mc.player != null ? mc.player.getY() : 0)) - .set("z", () -> oppositeZ(false)) - ) - - .set("yaw", () -> yaw(false)) - .set("pitch", () -> pitch(false)) - .set("direction", () -> direction(false)) - - .set("hand", () -> mc.player != null ? wrap(mc.player.getMainHandStack()) : Value.null_()) - .set("offhand", () -> mc.player != null ? wrap(mc.player.getOffHandStack()) : Value.null_()) - .set("hand_or_offhand", MeteorStarscriptMixin::handOrOffhand) - .set("get_item", MeteorStarscriptMixin::getItem) - .set("count_items", MeteorStarscriptMixin::countItems) - - .set("xp", new ValueMap() - .set("level", () -> Value.number(mc.player != null ? mc.player.experienceLevel : 0)) - .set("progress", () -> Value.number(mc.player != null ? mc.player.experienceProgress : 0)) - .set("total", () -> Value.number(mc.player != null ? mc.player.totalExperience : 0)) - ) - - .set("has_potion_effect", MeteorStarscriptMixin::hasPotionEffect) - .set("get_potion_effect", MeteorStarscriptMixin::getPotionEffect) - - .set("get_stat", MeteorStarscriptMixin::getStat) - ); - } - - private static Value oppositeX(boolean camera) { - double x = camera ? mc.gameRenderer.getCamera().getPos().x + ConfigModifier.get().x_spoof.get() : (mc.player != null ? mc.player.getX() + ConfigModifier.get().x_spoof.get() : 0); - Dimension dimension = PlayerUtils.getDimension(); - - if (dimension == Dimension.Overworld) x /= 8; - else if (dimension == Dimension.Nether) x *= 8; - - return Value.number(x); - } - - private static Value oppositeZ(boolean camera) { - double z = camera ? mc.gameRenderer.getCamera().getPos().z + ConfigModifier.get().z_spoof.get() : (mc.player != null ? mc.player.getZ() + ConfigModifier.get().z_spoof.get() : 0); - Dimension dimension = PlayerUtils.getDimension(); - - if (dimension == Dimension.Overworld) z /= 8; - else if (dimension == Dimension.Nether) z *= 8; - - return Value.number(z); - } - - private static Value yaw(boolean camera) { - float yaw; - if (camera) yaw = mc.gameRenderer.getCamera().getYaw(); - else yaw = mc.player != null ? mc.player.getYaw() : 0; - yaw %= 360; - - if (yaw < 0) yaw += 360; - if (yaw > 180) yaw -= 360; - - return Value.number(yaw); - } - - private static Value pitch(boolean camera) { - float pitch; - if (camera) pitch = mc.gameRenderer.getCamera().getPitch(); - else pitch = mc.player != null ? mc.player.getPitch() : 0; - pitch %= 360; - - if (pitch < 0) pitch += 360; - if (pitch > 180) pitch -= 360; - - return Value.number(pitch); - } - - private static Value direction(boolean camera) { - float yaw; - if (camera) yaw = mc.gameRenderer.getCamera().getYaw(); - else yaw = mc.player != null ? mc.player.getYaw() : 0; - - return wrap(HorizontalDirection.get(yaw)); - } - - private static Value biome() { - if (mc.player == null || mc.world == null) return Value.string(""); - - BP.set(mc.player.getX(), mc.player.getY(), mc.player.getZ()); - Identifier id = mc.world.getRegistryManager().get(RegistryKeys.BIOME).getId(mc.world.getBiome(BP).value()); - if (id == null) return Value.string("Unknown"); - - return Value.string(Arrays.stream(id.getPath().split("_")).map(StringUtils::capitalize).collect(Collectors.joining(" "))); - } - - private static Value handOrOffhand() { - if (mc.player == null) return Value.null_(); - - ItemStack itemStack = mc.player.getMainHandStack(); - if (itemStack.isEmpty()) itemStack = mc.player.getOffHandStack(); - - return itemStack != null ? wrap(itemStack) : Value.null_(); - } - - private static Value ping() { - if (mc.getNetworkHandler() == null || mc.player == null) return Value.number(0); - - PlayerListEntry playerListEntry = mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()); - return Value.number(playerListEntry != null ? playerListEntry.getLatency() : 0); - } - private static Value posString(boolean opposite, boolean camera) { - Vec3d pos; - if (camera) pos = mc.gameRenderer.getCamera().getPos(); - else pos = mc.player != null ? mc.player.getPos() : Vec3d.ZERO; - - double x = pos.x; - double z = pos.z; - - if (opposite) { - Dimension dimension = PlayerUtils.getDimension(); - - if (dimension == Dimension.Overworld) { - x /= 8; - z /= 8; - } - else if (dimension == Dimension.Nether) { - x *= 8; - z *= 8; - } - } - - return posString(x, pos.y, z); - } - - private static Value posString(double x, double y, double z) { - return Value.string(String.format("X: %.0f Y: %.0f Z: %.0f", x + ConfigModifier.get().x_spoof.get(), y, z + ConfigModifier.get().z_spoof.get())); - } - - private static Value getItem(Starscript ss, int argCount) { - if (argCount != 1) ss.error("player.get_item() requires 1 argument, got %d.", argCount); - - int i = (int) ss.popNumber("First argument to player.get_item() needs to be a number."); - return mc.player != null ? wrap(mc.player.getInventory().getStack(i)) : Value.null_(); - } - - private static Value countItems(Starscript ss, int argCount) { - if (argCount != 1) ss.error("player.count_items() requires 1 argument, got %d.", argCount); - - String idRaw = ss.popString("First argument to player.count_items() needs to be a string."); - Identifier id = Identifier.tryParse(idRaw); - if (id == null) return Value.number(0); - - Item item = Registries.ITEM.get(id); - if (item == Items.AIR || mc.player == null) return Value.number(0); - - int count = 0; - for (int i = 0; i < mc.player.getInventory().size(); i++) { - ItemStack itemStack = mc.player.getInventory().getStack(i); - if (itemStack.getItem() == item) count += itemStack.getCount(); - } - - return Value.number(count); - } - - private static Value hasPotionEffect(Starscript ss, int argCount) { - if (argCount < 1) ss.error("player.has_potion_effect() requires 1 argument, got %d.", argCount); - if (mc.player == null) return Value.bool(false); - - Identifier name = popIdentifier(ss, "First argument to player.has_potion_effect() needs to a string."); - - StatusEffect effect = Registries.STATUS_EFFECT.get(name); - if (effect == null) return Value.bool(false); - - StatusEffectInstance effectInstance = mc.player.getStatusEffect(effect); - return Value.bool(effectInstance != null); - } - - private static Value getPotionEffect(Starscript ss, int argCount) { - if (argCount < 1) ss.error("player.get_potion_effect() requires 1 argument, got %d.", argCount); - if (mc.player == null) return Value.null_(); - - Identifier name = popIdentifier(ss, "First argument to player.get_potion_effect() needs to a string."); - - StatusEffect effect = Registries.STATUS_EFFECT.get(name); - if (effect == null) return Value.null_(); - - StatusEffectInstance effectInstance = mc.player.getStatusEffect(effect); - if (effectInstance == null) return Value.null_(); - - return wrap(effectInstance); - } - private static long lastRequestedStatsTime = 0; - private static Value getStat(Starscript ss, int argCount) { - if (argCount < 1) ss.error("player.get_stat() requires 1 argument, got %d.", argCount); - if (mc.player == null) return Value.number(0); - - long time = System.currentTimeMillis(); - if ((time - lastRequestedStatsTime) / 1000.0 >= 1 && mc.getNetworkHandler() != null) { - mc.getNetworkHandler().sendPacket(new ClientStatusC2SPacket(ClientStatusC2SPacket.Mode.REQUEST_STATS)); - lastRequestedStatsTime = time; - } - - String type = argCount > 1 ? ss.popString("First argument to player.get_stat() needs to be a string.") : "custom"; - Identifier name = popIdentifier(ss, (argCount > 1 ? "Second" : "First") + " argument to player.get_stat() needs to be a string."); - - Stat stat = switch (type) { - case "mined" -> Stats.MINED.getOrCreateStat(Registries.BLOCK.get(name)); - case "crafted" -> Stats.CRAFTED.getOrCreateStat(Registries.ITEM.get(name)); - case "used" -> Stats.USED.getOrCreateStat(Registries.ITEM.get(name)); - case "broken" -> Stats.BROKEN.getOrCreateStat(Registries.ITEM.get(name)); - case "picked_up" -> Stats.PICKED_UP.getOrCreateStat(Registries.ITEM.get(name)); - case "dropped" -> Stats.DROPPED.getOrCreateStat(Registries.ITEM.get(name)); - case "killed" -> Stats.KILLED.getOrCreateStat(Registries.ENTITY_TYPE.get(name)); - case "killed_by" -> Stats.KILLED_BY.getOrCreateStat(Registries.ENTITY_TYPE.get(name)); - case "custom" -> { - name = Registries.CUSTOM_STAT.get(name); - yield name != null ? Stats.CUSTOM.getOrCreateStat(name) : null; - } - default -> null; - }; - - return Value.number(stat != null ? mc.player.getStatHandler().getStat(stat) : 0); - } -} diff --git a/src/main/java/nekiplay/meteorplus/settings/ConfigModifier.java b/src/main/java/nekiplay/meteorplus/settings/ConfigModifier.java index a39114e8..565aec61 100644 --- a/src/main/java/nekiplay/meteorplus/settings/ConfigModifier.java +++ b/src/main/java/nekiplay/meteorplus/settings/ConfigModifier.java @@ -1,17 +1,49 @@ package nekiplay.meteorplus.settings; +import meteordevelopment.meteorclient.mixin.ClientPlayerInteractionManagerAccessor; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.config.Config; +import meteordevelopment.meteorclient.utils.Utils; +import meteordevelopment.meteorclient.utils.misc.HorizontalDirection; +import meteordevelopment.meteorclient.utils.misc.MeteorStarscript; +import meteordevelopment.meteorclient.utils.player.PlayerUtils; +import meteordevelopment.meteorclient.utils.world.Dimension; +import meteordevelopment.starscript.Starscript; +import meteordevelopment.starscript.value.Value; +import meteordevelopment.starscript.value.ValueMap; import nekiplay.meteorplus.mixinclasses.SpoofMode; +import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.entity.effect.StatusEffect; +import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.network.packet.c2s.play.ClientStatusC2SPacket; +import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.stat.Stat; +import net.minecraft.stat.Stats; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import org.apache.commons.lang3.StringUtils; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import static meteordevelopment.meteorclient.MeteorClient.mc; +import static meteordevelopment.meteorclient.utils.misc.MeteorStarscript.popIdentifier; +import static meteordevelopment.meteorclient.utils.misc.MeteorStarscript.wrap; public class ConfigModifier { private static ConfigModifier INSTANCE; - public final SettingGroup sgMeteorPlus = Config.get().settings.createGroup("Meteor+"); - public final Setting positionProtection = sgMeteorPlus.add(new BoolSetting.Builder() + public static final SettingGroup sgMeteorPlus = Config.get().settings.createGroup("Meteor+"); + public static final Setting positionProtection = sgMeteorPlus.add(new BoolSetting.Builder() .name("position-protection") .description("Set fake position in F3 and in mods.") .defaultValue(false) + .onChanged((a) -> changedProtection()) .build() ); @@ -19,6 +51,7 @@ public class ConfigModifier { .name("protection-mode") .defaultValue(SpoofMode.Sensor) .visible(positionProtection::get) + .onChanged((a) -> changedProtection()) .build() ); @@ -40,4 +73,371 @@ public static ConfigModifier get() { if (INSTANCE == null) INSTANCE = new ConfigModifier(); return INSTANCE; } + + private static void changedProtection() { + Starscript ss = MeteorStarscript.ss; + + if (positionProtection.get()) { + ss.set("camera", new ValueMap() + .set("pos", new ValueMap() + .set("_toString", () -> posString(false, true)) + .set("x", () -> Value.number(mc.gameRenderer.getCamera().getPos().x + ConfigModifier.get().x_spoof.get())) + .set("y", () -> Value.number(mc.gameRenderer.getCamera().getPos().y)) + .set("z", () -> Value.number(mc.gameRenderer.getCamera().getPos().z + ConfigModifier.get().z_spoof.get())) + ) + .set("opposite_dim_pos", new ValueMap() + .set("_toString", () -> posString(true, true)) + .set("x", () -> oppositeX(true)) + .set("y", () -> Value.number(mc.gameRenderer.getCamera().getPos().y)) + .set("z", () -> oppositeZ(true)) + ) + + .set("yaw", () -> yaw(true)) + .set("pitch", () -> pitch(true)) + .set("direction", () -> direction(true)) + ); + + // Player + ss.set("player", new ValueMap() + .set("_toString", () -> Value.string(mc.getSession().getUsername())) + .set("health", () -> Value.number(mc.player != null ? mc.player.getHealth() : 0)) + .set("absorption", () -> Value.number(mc.player != null ? mc.player.getAbsorptionAmount() : 0)) + .set("hunger", () -> Value.number(mc.player != null ? mc.player.getHungerManager().getFoodLevel() : 0)) + + .set("speed", () -> Value.number(Utils.getPlayerSpeed().horizontalLength())) + .set("speed_all", new ValueMap() + .set("_toString", () -> Value.string(mc.player != null ? Utils.getPlayerSpeed().toString() : "")) + .set("x", () -> Value.number(mc.player != null ? Utils.getPlayerSpeed().x : 0)) + .set("y", () -> Value.number(mc.player != null ? Utils.getPlayerSpeed().y : 0)) + .set("z", () -> Value.number(mc.player != null ? Utils.getPlayerSpeed().z : 0)) + ) + + .set("breaking_progress", () -> Value.number(mc.interactionManager != null ? ((ClientPlayerInteractionManagerAccessor) mc.interactionManager).getBreakingProgress() : 0)) + .set("biome", ConfigModifier::biome) + + .set("dimension", () -> Value.string(PlayerUtils.getDimension().name())) + .set("opposite_dimension", () -> Value.string(PlayerUtils.getDimension().opposite().name())) + + + .set("pos", new ValueMap() + .set("_toString", () -> posString(false, false)) + .set("x", () -> Value.number(mc.player != null ? mc.player.getX() + ConfigModifier.get().x_spoof.get() : 0)) + .set("y", () -> Value.number(mc.player != null ? mc.player.getY() : 0)) + .set("z", () -> Value.number(mc.player != null ? mc.player.getZ() + ConfigModifier.get().z_spoof.get() : 0)) + ) + .set("opposite_dim_pos", new ValueMap() + .set("_toString", () -> posString(true, false)) + .set("x", () -> oppositeX(false)) + .set("y", () -> Value.number(mc.player != null ? mc.player.getY() : 0)) + .set("z", () -> oppositeZ(false)) + ) + + .set("yaw", () -> yaw(false)) + .set("pitch", () -> pitch(false)) + .set("direction", () -> direction(false)) + + .set("hand", () -> mc.player != null ? wrap(mc.player.getMainHandStack()) : Value.null_()) + .set("offhand", () -> mc.player != null ? wrap(mc.player.getOffHandStack()) : Value.null_()) + .set("hand_or_offhand", ConfigModifier::handOrOffhand) + .set("get_item", ConfigModifier::getItem) + .set("count_items", ConfigModifier::countItems) + + .set("xp", new ValueMap() + .set("level", () -> Value.number(mc.player != null ? mc.player.experienceLevel : 0)) + .set("progress", () -> Value.number(mc.player != null ? mc.player.experienceProgress : 0)) + .set("total", () -> Value.number(mc.player != null ? mc.player.totalExperience : 0)) + ) + + .set("has_potion_effect", ConfigModifier::hasPotionEffect) + .set("get_potion_effect", ConfigModifier::getPotionEffect) + + .set("get_stat", ConfigModifier::getStat) + ); + } + else { + ss.set("camera", new ValueMap() + .set("pos", new ValueMap() + .set("_toString", () -> posString(false, true)) + .set("x", () -> Value.number(mc.gameRenderer.getCamera().getPos().x)) + .set("y", () -> Value.number(mc.gameRenderer.getCamera().getPos().y)) + .set("z", () -> Value.number(mc.gameRenderer.getCamera().getPos().z)) + ) + .set("opposite_dim_pos", new ValueMap() + .set("_toString", () -> posString(true, true)) + .set("x", () -> oppositeX(true)) + .set("y", () -> Value.number(mc.gameRenderer.getCamera().getPos().y)) + .set("z", () -> oppositeZ(true)) + ) + + .set("yaw", () -> yaw(true)) + .set("pitch", () -> pitch(true)) + .set("direction", () -> direction(true)) + ); + + // Player + ss.set("player", new ValueMap() + .set("_toString", () -> Value.string(mc.getSession().getUsername())) + .set("health", () -> Value.number(mc.player != null ? mc.player.getHealth() : 0)) + .set("absorption", () -> Value.number(mc.player != null ? mc.player.getAbsorptionAmount() : 0)) + .set("hunger", () -> Value.number(mc.player != null ? mc.player.getHungerManager().getFoodLevel() : 0)) + + .set("speed", () -> Value.number(Utils.getPlayerSpeed().horizontalLength())) + .set("speed_all", new ValueMap() + .set("_toString", () -> Value.string(mc.player != null ? Utils.getPlayerSpeed().toString() : "")) + .set("x", () -> Value.number(mc.player != null ? Utils.getPlayerSpeed().x : 0)) + .set("y", () -> Value.number(mc.player != null ? Utils.getPlayerSpeed().y : 0)) + .set("z", () -> Value.number(mc.player != null ? Utils.getPlayerSpeed().z : 0)) + ) + + .set("breaking_progress", () -> Value.number(mc.interactionManager != null ? ((ClientPlayerInteractionManagerAccessor) mc.interactionManager).getBreakingProgress() : 0)) + .set("biome", ConfigModifier::biome) + + .set("dimension", () -> Value.string(PlayerUtils.getDimension().name())) + .set("opposite_dimension", () -> Value.string(PlayerUtils.getDimension().opposite().name())) + + + .set("pos", new ValueMap() + .set("_toString", () -> posString(false, false)) + .set("x", () -> Value.number(mc.player != null ? mc.player.getX() : 0)) + .set("y", () -> Value.number(mc.player != null ? mc.player.getY() : 0)) + .set("z", () -> Value.number(mc.player != null ? mc.player.getZ() : 0)) + ) + .set("opposite_dim_pos", new ValueMap() + .set("_toString", () -> posString(true, false)) + .set("x", () -> oppositeX(false)) + .set("y", () -> Value.number(mc.player != null ? mc.player.getY() : 0)) + .set("z", () -> oppositeZ(false)) + ) + + .set("yaw", () -> yaw(false)) + .set("pitch", () -> pitch(false)) + .set("direction", () -> direction(false)) + + .set("hand", () -> mc.player != null ? wrap(mc.player.getMainHandStack()) : Value.null_()) + .set("offhand", () -> mc.player != null ? wrap(mc.player.getOffHandStack()) : Value.null_()) + .set("hand_or_offhand", ConfigModifier::handOrOffhand) + .set("get_item", ConfigModifier::getItem) + .set("count_items", ConfigModifier::countItems) + + .set("xp", new ValueMap() + .set("level", () -> Value.number(mc.player != null ? mc.player.experienceLevel : 0)) + .set("progress", () -> Value.number(mc.player != null ? mc.player.experienceProgress : 0)) + .set("total", () -> Value.number(mc.player != null ? mc.player.totalExperience : 0)) + ) + + .set("has_potion_effect", ConfigModifier::hasPotionEffect) + .set("get_potion_effect", ConfigModifier::getPotionEffect) + + .set("get_stat", ConfigModifier::getStat) + ); + } + } + + private static Value oppositeX(boolean camera) { + double x = 0; + if (positionProtection.get()) { + x = camera ? mc.gameRenderer.getCamera().getPos().x + ConfigModifier.get().x_spoof.get() : (mc.player != null ? mc.player.getX() + ConfigModifier.get().x_spoof.get() : 0); + } + else { + x = camera ? mc.gameRenderer.getCamera().getPos().x : (mc.player != null ? mc.player.getX() : 0); + } + Dimension dimension = PlayerUtils.getDimension(); + + if (dimension == Dimension.Overworld) x /= 8; + else if (dimension == Dimension.Nether) x *= 8; + + return Value.number(x); + } + + private static Value oppositeZ(boolean camera) { + double z = 0; + if (positionProtection.get()) { + z = camera ? mc.gameRenderer.getCamera().getPos().z + ConfigModifier.get().z_spoof.get() : (mc.player != null ? mc.player.getZ() + ConfigModifier.get().z_spoof.get() : 0); + } + else { + z = camera ? mc.gameRenderer.getCamera().getPos().z : (mc.player != null ? mc.player.getZ() : 0); + } + Dimension dimension = PlayerUtils.getDimension(); + + if (dimension == Dimension.Overworld) z /= 8; + else if (dimension == Dimension.Nether) z *= 8; + + return Value.number(z); + } + + private static Value yaw(boolean camera) { + float yaw; + if (camera) yaw = mc.gameRenderer.getCamera().getYaw(); + else yaw = mc.player != null ? mc.player.getYaw() : 0; + yaw %= 360; + + if (yaw < 0) yaw += 360; + if (yaw > 180) yaw -= 360; + + return Value.number(yaw); + } + + private static Value pitch(boolean camera) { + float pitch; + if (camera) pitch = mc.gameRenderer.getCamera().getPitch(); + else pitch = mc.player != null ? mc.player.getPitch() : 0; + pitch %= 360; + + if (pitch < 0) pitch += 360; + if (pitch > 180) pitch -= 360; + + return Value.number(pitch); + } + + private static Value direction(boolean camera) { + float yaw; + if (camera) yaw = mc.gameRenderer.getCamera().getYaw(); + else yaw = mc.player != null ? mc.player.getYaw() : 0; + + return wrap(HorizontalDirection.get(yaw)); + } + private static final BlockPos.Mutable BP = new BlockPos.Mutable(); + private static Value biome() { + if (mc.player == null || mc.world == null) return Value.string(""); + + BP.set(mc.player.getX(), mc.player.getY(), mc.player.getZ()); + Identifier id = mc.world.getRegistryManager().get(RegistryKeys.BIOME).getId(mc.world.getBiome(BP).value()); + if (id == null) return Value.string("Unknown"); + + return Value.string(Arrays.stream(id.getPath().split("_")).map(StringUtils::capitalize).collect(Collectors.joining(" "))); + } + + private static Value handOrOffhand() { + if (mc.player == null) return Value.null_(); + + ItemStack itemStack = mc.player.getMainHandStack(); + if (itemStack.isEmpty()) itemStack = mc.player.getOffHandStack(); + + return itemStack != null ? wrap(itemStack) : Value.null_(); + } + + private static Value ping() { + if (mc.getNetworkHandler() == null || mc.player == null) return Value.number(0); + + PlayerListEntry playerListEntry = mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid()); + return Value.number(playerListEntry != null ? playerListEntry.getLatency() : 0); + } + private static Value posString(boolean opposite, boolean camera) { + Vec3d pos; + if (camera) pos = mc.gameRenderer.getCamera().getPos(); + else pos = mc.player != null ? mc.player.getPos() : Vec3d.ZERO; + + double x = pos.x; + double z = pos.z; + + if (opposite) { + Dimension dimension = PlayerUtils.getDimension(); + + if (dimension == Dimension.Overworld) { + x /= 8; + z /= 8; + } + else if (dimension == Dimension.Nether) { + x *= 8; + z *= 8; + } + } + + return posString(x, pos.y, z); + } + + private static Value posString(double x, double y, double z) { + if (positionProtection.get()) { + return Value.string(String.format("X: %.0f Y: %.0f Z: %.0f", x + ConfigModifier.get().x_spoof.get(), y, z + ConfigModifier.get().z_spoof.get())); + } + else { + return Value.string(String.format("X: %.0f Y: %.0f Z: %.0f", x, y, z)); + } + } + + private static Value getItem(Starscript ss, int argCount) { + if (argCount != 1) ss.error("player.get_item() requires 1 argument, got %d.", argCount); + + int i = (int) ss.popNumber("First argument to player.get_item() needs to be a number."); + return mc.player != null ? wrap(mc.player.getInventory().getStack(i)) : Value.null_(); + } + + private static Value countItems(Starscript ss, int argCount) { + if (argCount != 1) ss.error("player.count_items() requires 1 argument, got %d.", argCount); + + String idRaw = ss.popString("First argument to player.count_items() needs to be a string."); + Identifier id = Identifier.tryParse(idRaw); + if (id == null) return Value.number(0); + + Item item = Registries.ITEM.get(id); + if (item == Items.AIR || mc.player == null) return Value.number(0); + + int count = 0; + for (int i = 0; i < mc.player.getInventory().size(); i++) { + ItemStack itemStack = mc.player.getInventory().getStack(i); + if (itemStack.getItem() == item) count += itemStack.getCount(); + } + + return Value.number(count); + } + + private static Value hasPotionEffect(Starscript ss, int argCount) { + if (argCount < 1) ss.error("player.has_potion_effect() requires 1 argument, got %d.", argCount); + if (mc.player == null) return Value.bool(false); + + Identifier name = popIdentifier(ss, "First argument to player.has_potion_effect() needs to a string."); + + StatusEffect effect = Registries.STATUS_EFFECT.get(name); + if (effect == null) return Value.bool(false); + + StatusEffectInstance effectInstance = mc.player.getStatusEffect(effect); + return Value.bool(effectInstance != null); + } + + private static Value getPotionEffect(Starscript ss, int argCount) { + if (argCount < 1) ss.error("player.get_potion_effect() requires 1 argument, got %d.", argCount); + if (mc.player == null) return Value.null_(); + + Identifier name = popIdentifier(ss, "First argument to player.get_potion_effect() needs to a string."); + + StatusEffect effect = Registries.STATUS_EFFECT.get(name); + if (effect == null) return Value.null_(); + + StatusEffectInstance effectInstance = mc.player.getStatusEffect(effect); + if (effectInstance == null) return Value.null_(); + + return wrap(effectInstance); + } + private static long lastRequestedStatsTime = 0; + private static Value getStat(Starscript ss, int argCount) { + if (argCount < 1) ss.error("player.get_stat() requires 1 argument, got %d.", argCount); + if (mc.player == null) return Value.number(0); + + long time = System.currentTimeMillis(); + if ((time - lastRequestedStatsTime) / 1000.0 >= 1 && mc.getNetworkHandler() != null) { + mc.getNetworkHandler().sendPacket(new ClientStatusC2SPacket(ClientStatusC2SPacket.Mode.REQUEST_STATS)); + lastRequestedStatsTime = time; + } + + String type = argCount > 1 ? ss.popString("First argument to player.get_stat() needs to be a string.") : "custom"; + Identifier name = popIdentifier(ss, (argCount > 1 ? "Second" : "First") + " argument to player.get_stat() needs to be a string."); + + Stat stat = switch (type) { + case "mined" -> Stats.MINED.getOrCreateStat(Registries.BLOCK.get(name)); + case "crafted" -> Stats.CRAFTED.getOrCreateStat(Registries.ITEM.get(name)); + case "used" -> Stats.USED.getOrCreateStat(Registries.ITEM.get(name)); + case "broken" -> Stats.BROKEN.getOrCreateStat(Registries.ITEM.get(name)); + case "picked_up" -> Stats.PICKED_UP.getOrCreateStat(Registries.ITEM.get(name)); + case "dropped" -> Stats.DROPPED.getOrCreateStat(Registries.ITEM.get(name)); + case "killed" -> Stats.KILLED.getOrCreateStat(Registries.ENTITY_TYPE.get(name)); + case "killed_by" -> Stats.KILLED_BY.getOrCreateStat(Registries.ENTITY_TYPE.get(name)); + case "custom" -> { + name = Registries.CUSTOM_STAT.get(name); + yield name != null ? Stats.CUSTOM.getOrCreateStat(name) : null; + } + default -> null; + }; + + return Value.number(stat != null ? mc.player.getStatHandler().getStat(stat) : 0); + } } diff --git a/src/main/resources/meteorplus.mixins.json b/src/main/resources/meteorplus.mixins.json index d597f59c..e99a2bc9 100644 --- a/src/main/resources/meteorplus.mixins.json +++ b/src/main/resources/meteorplus.mixins.json @@ -4,12 +4,12 @@ "compatibilityLevel": "JAVA_17", "plugin": "nekiplay.MixinPlugin", "client": [ - "meteorclient.LeftRightSettingsScreenMixin", - "meteorclient.ModuleMixin", - "meteorclient.ModulesScreenMixin", - "meteorclient.WBlockPosEditMixin", - "meteorclient.WMeteorModuleMixin", - "meteorclient.WPressableMixin", + "meteorclient.gui.LeftRightSettingsScreenMixin", + "meteorclient.modules.ModuleMixin", + "meteorclient.gui.ModulesScreenMixin", + "meteorclient.gui.WBlockPosEditMixin", + "meteorclient.gui.WMeteorModuleMixin", + "meteorclient.gui.WPressableMixin", "meteorclient.modules.NameTagsMixin", "meteorclient.modules.AutoToolMixin", "meteorclient.modules.BlockESPMixin", @@ -31,9 +31,8 @@ "defaultRequire": 1 }, "mixins": [ - "meteorclient.DefaultSettingsWidgetFactoryMixin", - "meteorclient.KeybindMixin", - "meteorclient.utils.misc.MeteorStarscriptMixin", + "meteorclient.gui.DefaultSettingsWidgetFactoryMixin", + "meteorclient.utils.misc.KeybindMixin", "minecraft.ClientPlayerEntityMixin", "minecraft.LivingEntityMixin", "minecraft.StringReaderMixin"