From 1b2144b5650c848f06cd5dfb58edad6917c001e0 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Wed, 22 May 2024 12:08:19 +0100 Subject: [PATCH 01/66] Fix crash on startup with liquidbounce PSA: Gui rendering is still extremely broken but that's a separate issue. Disable custom font to mostly fix it. --- .../mixin/ClientPlayerEntityMixin.java | 6 ++-- .../meteorclient/mixin/EntityMixin.java | 30 +++++++++++++++++ .../meteorclient/mixin/MouseMixin.java | 32 ------------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java index cedf6b361c..7b73e5a9dd 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java @@ -22,7 +22,9 @@ import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.damage.DamageSource; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -75,7 +77,7 @@ private void onDamage(DamageSource source, float amount, CallbackInfoReturnable< if (Utils.canUpdate() && getWorld().isClient && canTakeDamage()) MeteorClient.EVENT_BUS.post(DamageEvent.get(this, source)); } - @ModifyConstant(method = "canSprint", constant = @Constant(floatValue = 6.0f)) + @ModifyExpressionValue(method = "canSprint", at = @At(value = "CONSTANT", args = "floatValue=6.0f")) private float onHunger(float constant) { if (Modules.get().get(NoSlow.class).hunger()) return -1; return constant; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/EntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/EntityMixin.java index e62c6f6395..4c36a1192b 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/EntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/EntityMixin.java @@ -11,12 +11,16 @@ import meteordevelopment.meteorclient.events.entity.LivingEntityMoveEvent; import meteordevelopment.meteorclient.events.entity.player.JumpVelocityMultiplierEvent; import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent; +import meteordevelopment.meteorclient.mixininterface.ICamera; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.combat.Hitboxes; import meteordevelopment.meteorclient.systems.modules.movement.*; import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.ElytraFly; import meteordevelopment.meteorclient.systems.modules.render.ESP; +import meteordevelopment.meteorclient.systems.modules.render.FreeLook; +import meteordevelopment.meteorclient.systems.modules.render.Freecam; import meteordevelopment.meteorclient.systems.modules.render.NoRender; +import meteordevelopment.meteorclient.systems.modules.world.HighwayBuilder; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerEntity; import meteordevelopment.meteorclient.utils.render.color.Color; @@ -24,6 +28,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.client.render.Camera; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityPose; import net.minecraft.entity.LivingEntity; @@ -177,4 +182,29 @@ private void getPoseHook(CallbackInfoReturnable info) { private boolean cancelBounce(boolean original) { return Modules.get().get(NoFall.class).cancelBounce() || original; } + + @Inject(method = "changeLookDirection", at = @At("HEAD"), cancellable = true) + private void updateChangeLookDirection(double cursorDeltaX, double cursorDeltaY, CallbackInfo ci) { + if ((Object) this != mc.player) return; + + Freecam freecam = Modules.get().get(Freecam.class); + FreeLook freeLook = Modules.get().get(FreeLook.class); + + if (freecam.isActive()) { + freecam.changeLookDirection(cursorDeltaX * 0.15, cursorDeltaY * 0.15); + ci.cancel(); + } + else if (Modules.get().isActive(HighwayBuilder.class)) { + Camera camera = mc.gameRenderer.getCamera(); + ((ICamera) camera).setRot(camera.getYaw() + cursorDeltaX * 0.15, camera.getPitch() + cursorDeltaY * 0.15); + ci.cancel(); + } + else if (freeLook.cameraMode()) { + freeLook.cameraYaw += cursorDeltaX / freeLook.sensitivity.get().floatValue(); + freeLook.cameraPitch += cursorDeltaY / freeLook.sensitivity.get().floatValue(); + + if (Math.abs(freeLook.cameraPitch) > 90.0F) freeLook.cameraPitch = freeLook.cameraPitch > 0.0F ? 90.0F : -90.0F; + ci.cancel(); + } + } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/MouseMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/MouseMixin.java index d9b5fcf5de..3e2b20d565 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/MouseMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/MouseMixin.java @@ -8,31 +8,18 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.meteor.MouseButtonEvent; import meteordevelopment.meteorclient.events.meteor.MouseScrollEvent; -import meteordevelopment.meteorclient.mixininterface.ICamera; -import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.render.FreeLook; -import meteordevelopment.meteorclient.systems.modules.render.Freecam; -import meteordevelopment.meteorclient.systems.modules.world.HighwayBuilder; import meteordevelopment.meteorclient.utils.misc.input.Input; import meteordevelopment.meteorclient.utils.misc.input.KeyAction; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.Mouse; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.client.render.Camera; -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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import static org.lwjgl.glfw.GLFW.GLFW_RELEASE; @Mixin(Mouse.class) public abstract class MouseMixin { - @Shadow @Final private MinecraftClient client; - @Inject(method = "onMouseButton", at = @At("HEAD"), cancellable = true) private void onMouseButton(long window, int button, int action, int mods, CallbackInfo info) { Input.setButtonState(button, action != GLFW_RELEASE); @@ -44,23 +31,4 @@ private void onMouseButton(long window, int button, int action, int mods, Callba private void onMouseScroll(long window, double horizontal, double vertical, CallbackInfo info) { if (MeteorClient.EVENT_BUS.post(MouseScrollEvent.get(vertical)).isCancelled()) info.cancel(); } - - @Redirect(method = "updateMouse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;changeLookDirection(DD)V")) - private void updateMouseChangeLookDirection(ClientPlayerEntity player, double cursorDeltaX, double cursorDeltaY) { - Freecam freecam = Modules.get().get(Freecam.class); - FreeLook freeLook = Modules.get().get(FreeLook.class); - - if (freecam.isActive()) freecam.changeLookDirection(cursorDeltaX * 0.15, cursorDeltaY * 0.15); - else if (Modules.get().isActive(HighwayBuilder.class)) { - Camera camera = client.gameRenderer.getCamera(); - ((ICamera) camera).setRot(camera.getYaw() + cursorDeltaX * 0.15, camera.getPitch() + cursorDeltaY * 0.15); - } - else if (freeLook.cameraMode()) { - freeLook.cameraYaw += cursorDeltaX / freeLook.sensitivity.get().floatValue(); - freeLook.cameraPitch += cursorDeltaY / freeLook.sensitivity.get().floatValue(); - - if (Math.abs(freeLook.cameraPitch) > 90.0F) freeLook.cameraPitch = freeLook.cameraPitch > 0.0F ? 90.0F : -90.0F; - } - else player.changeLookDirection(cursorDeltaX, cursorDeltaY); - } } From fa00a6da7847e1e644d6d15d2326738d1a9135a0 Mon Sep 17 00:00:00 2001 From: misterx Date: Wed, 22 May 2024 00:17:39 +0200 Subject: [PATCH 02/66] fixed fabric packets not being detected by the event system --- .../meteorclient/mixin/ClientConnectionMixin.java | 8 +++++--- .../systems/modules/misc/PacketCanceller.java | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java index b959abbe97..9c6bb603fb 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java @@ -22,6 +22,7 @@ import meteordevelopment.meteorclient.systems.proxies.Proxy; import net.minecraft.network.ClientConnection; import net.minecraft.network.NetworkSide; +import net.minecraft.network.PacketCallbacks; import net.minecraft.network.handler.PacketEncoderException; import net.minecraft.network.handler.PacketSizeLogger; import net.minecraft.network.listener.ClientPlayPacketListener; @@ -30,6 +31,7 @@ import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -66,7 +68,7 @@ private static void onConnect(InetSocketAddress address, boolean useEpoll, Clien MeteorClient.EVENT_BUS.post(ServerConnectEndEvent.get(address)); } - @Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;)V", cancellable = true) + @Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;)V", cancellable = true) private void onSendPacketHead(CallbackInfo info, @Local LocalRef> packet) { PacketEvent.Send processedPacket = MeteorClient.EVENT_BUS.post(PacketEvent.Send.get(packet.get())); if (processedPacket.isCancelled()) { @@ -76,8 +78,8 @@ private void onSendPacketHead(CallbackInfo info, @Local LocalRef> pack } } - @Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("TAIL")) - private void onSendPacketTail(Packet packet, CallbackInfo info) { + @Inject(method = "send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;)V", at = @At("TAIL")) + private void onSendPacketTail(Packet packet, @Nullable PacketCallbacks callbacks, CallbackInfo ci) { MeteorClient.EVENT_BUS.post(PacketEvent.Sent.get(packet)); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/PacketCanceller.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/PacketCanceller.java index 219b9395c6..ba7a2c1f15 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/PacketCanceller.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/PacketCanceller.java @@ -37,6 +37,7 @@ public class PacketCanceller extends Module { public PacketCanceller() { super(Categories.Misc, "packet-canceller", "Allows you to cancel certain packets."); + runInMainMenu = true; } @EventHandler(priority = EventPriority.HIGHEST + 1) From f9b1c75913ac946376bbfbae28c2b844755e76f9 Mon Sep 17 00:00:00 2001 From: tyrannus00 Date: Thu, 23 May 2024 00:39:58 +0200 Subject: [PATCH 03/66] Fixed Criticals not working Possibly also fixed other weird packet behavior after 1.20.6 update --- .../meteorclient/mixin/ClientConnectionMixin.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java index 9c6bb603fb..d0e1ad5571 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java @@ -69,12 +69,9 @@ private static void onConnect(InetSocketAddress address, boolean useEpoll, Clien } @Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;)V", cancellable = true) - private void onSendPacketHead(CallbackInfo info, @Local LocalRef> packet) { - PacketEvent.Send processedPacket = MeteorClient.EVENT_BUS.post(PacketEvent.Send.get(packet.get())); - if (processedPacket.isCancelled()) { + private void onSendPacketHead(CallbackInfo info, @Local(argsOnly = true) Packet packet) { + if (MeteorClient.EVENT_BUS.post(PacketEvent.Send.get(packet)).isCancelled()) { info.cancel(); - } else { - packet.set(processedPacket.packet); } } From 56fbe959c16705f338ad08f708037251f9172ee7 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Fri, 24 May 2024 13:41:40 +0100 Subject: [PATCH 04/66] revert more thoroughly --- .../meteorclient/events/packets/PacketEvent.java | 1 - .../meteorclient/mixin/ClientConnectionMixin.java | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java b/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java index d525056c51..2603e5dc5a 100644 --- a/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java +++ b/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java @@ -27,7 +27,6 @@ public static Receive get(Packet packet, ClientConnection connection) { public static class Send extends Cancellable { private static final Send INSTANCE = new Send(); - // overwriting this will overwrite the packet being sent public Packet packet; public static Send get(Packet packet) { diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java index d0e1ad5571..7275fbb4af 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java @@ -5,8 +5,6 @@ package meteordevelopment.meteorclient.mixin; -import com.llamalad7.mixinextras.sugar.Local; -import com.llamalad7.mixinextras.sugar.ref.LocalRef; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPipeline; import io.netty.handler.proxy.Socks4ProxyHandler; @@ -69,9 +67,9 @@ private static void onConnect(InetSocketAddress address, boolean useEpoll, Clien } @Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;)V", cancellable = true) - private void onSendPacketHead(CallbackInfo info, @Local(argsOnly = true) Packet packet) { + private void onSendPacketHead(Packet packet, PacketCallbacks callbacks, CallbackInfo ci) { if (MeteorClient.EVENT_BUS.post(PacketEvent.Send.get(packet)).isCancelled()) { - info.cancel(); + ci.cancel(); } } From dded574e91f851150ada983171913f93e9d1593e Mon Sep 17 00:00:00 2001 From: MineGame159 Date: Fri, 24 May 2024 19:17:56 +0200 Subject: [PATCH 05/66] Fix crash on servers that send "fake players" that don't have an entry in the player list --- .../meteorclient/mixin/PlayerEntityRendererMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java index 44e999799c..4932ab2a91 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java @@ -30,7 +30,7 @@ private void modifyRenderLayer(Args args, MatrixStack matrices, VertexConsumerPr Chams chams = Modules.get().get(Chams.class); if (chams.isActive() && chams.hand.get()) { - Identifier texture = chams.handTexture.get() ? player.playerListEntry.getSkinTextures().texture() : Chams.BLANK; + Identifier texture = chams.handTexture.get() ? player.getSkinTextures().texture() : Chams.BLANK; args.set(1, vertexConsumers.getBuffer(RenderLayer.getEntityTranslucent(texture))); } } From 2b68dd40ee969eff79125e2170686e2cc881c204 Mon Sep 17 00:00:00 2001 From: 19MisterX98 <41451155+19MisterX98@users.noreply.github.com> Date: Fri, 24 May 2024 21:26:22 +0200 Subject: [PATCH 06/66] Fixed ServerSpoof (#4599) --- .../meteorclient/events/packets/PacketEvent.java | 8 ++++++-- .../meteorclient/mixin/ClientConnectionMixin.java | 4 ++-- .../systems/modules/misc/ServerSpoof.java | 11 ++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java b/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java index 2603e5dc5a..44274b9648 100644 --- a/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java +++ b/src/main/java/meteordevelopment/meteorclient/events/packets/PacketEvent.java @@ -28,10 +28,12 @@ public static class Send extends Cancellable { private static final Send INSTANCE = new Send(); public Packet packet; + public ClientConnection connection; - public static Send get(Packet packet) { + public static Send get(Packet packet, ClientConnection connection) { INSTANCE.setCancelled(false); INSTANCE.packet = packet; + INSTANCE.connection = connection; return INSTANCE; } } @@ -40,9 +42,11 @@ public static class Sent { private static final Sent INSTANCE = new Sent(); public Packet packet; + public ClientConnection connection; - public static Sent get(Packet packet) { + public static Sent get(Packet packet, ClientConnection connection) { INSTANCE.packet = packet; + INSTANCE.connection = connection; return INSTANCE; } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java index 7275fbb4af..444a120550 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientConnectionMixin.java @@ -68,14 +68,14 @@ private static void onConnect(InetSocketAddress address, boolean useEpoll, Clien @Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;)V", cancellable = true) private void onSendPacketHead(Packet packet, PacketCallbacks callbacks, CallbackInfo ci) { - if (MeteorClient.EVENT_BUS.post(PacketEvent.Send.get(packet)).isCancelled()) { + if (MeteorClient.EVENT_BUS.post(PacketEvent.Send.get(packet, (ClientConnection) (Object) this)).isCancelled()) { ci.cancel(); } } @Inject(method = "send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;)V", at = @At("TAIL")) private void onSendPacketTail(Packet packet, @Nullable PacketCallbacks callbacks, CallbackInfo ci) { - MeteorClient.EVENT_BUS.post(PacketEvent.Sent.get(packet)); + MeteorClient.EVENT_BUS.post(PacketEvent.Sent.get(packet, (ClientConnection) (Object) this)); } @Inject(method = "exceptionCaught", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java index d279b2ae1f..a81d9bd882 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java @@ -76,9 +76,6 @@ private void onPacketSend(PacketEvent.Send event) { if (!isActive() || !(event.packet instanceof CustomPayloadC2SPacket)) return; Identifier id = ((CustomPayloadC2SPacket) event.packet).payload().getId().id(); - if (spoofBrand.get() && id.equals(BrandCustomPayload.ID.id())) - event.packet = new CustomPayloadC2SPacket(new BrandCustomPayload(brand.get())); - if (blockChannels.get()) { for (String channel : channels.get()) { if (StringUtils.containsIgnoreCase(id.toString(), channel)) { @@ -87,6 +84,14 @@ private void onPacketSend(PacketEvent.Send event) { } } } + + if (spoofBrand.get() && id.equals(BrandCustomPayload.ID.id())) { + CustomPayloadC2SPacket spoofedPacket = new CustomPayloadC2SPacket(new BrandCustomPayload(brand.get())); + + // PacketEvent.Send doesn't trigger if we send the packet like this + event.connection.send(spoofedPacket, null, true); + event.cancel(); + } } @EventHandler From 2ee726af581d95df9838818b92cc739bc8526f5a Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Sat, 25 May 2024 20:28:30 +0100 Subject: [PATCH 07/66] Prevent the ViaFabricPlus settings button overlapping with ours in the multiplayer menu. --- build.gradle | 5 +++++ gradle.properties | 3 +++ .../meteorclient/MixinPlugin.java | 5 +++++ .../viafabricplus/GeneralSettingsMixin.java | 21 +++++++++++++++++++ src/main/resources/fabric.mod.json | 3 ++- .../meteor-client-viafabricplus.mixins.json | 12 +++++++++++ 6 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/viafabricplus/GeneralSettingsMixin.java create mode 100644 src/main/resources/meteor-client-viafabricplus.mixins.json diff --git a/build.gradle b/build.gradle index 97453581de..b46ec23a52 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,10 @@ repositories { name = "vram" url = "https://maven.vram.io//" } + maven { + name = "ViaVersion" + url = "https://repo.viaversion.com" + } mavenCentral() } @@ -58,6 +62,7 @@ dependencies { modCompileOnly("maven.modrinth:iris:${project.iris_version}") { transitive = false } //modCompileOnly("io.vram:canvas-fabric-mc119:1.0.+") { transitive = false } // TODO: 1.19.3 modCompileOnly("maven.modrinth:indium:${project.indium_version}") { transitive = false } + modCompileOnly("de.florianmichael:ViaFabricPlus:${project.viafabricplus_version}") { transitive = false } // Baritone (https://github.com/MeteorDevelopment/baritone) modCompileOnly "meteordevelopment:baritone:${project.baritone_version}-SNAPSHOT" diff --git a/gradle.properties b/gradle.properties index cad87af402..8e046fac85 100644 --- a/gradle.properties +++ b/gradle.properties @@ -42,3 +42,6 @@ reflections_version=0.10.2 # Netty (https://github.com/netty/netty) netty_version=4.1.90.Final + +# ViaFabricPlus (https://github.com/ViaVersion/ViaFabricPlus) +viafabricplus_version=3.2.1 diff --git a/src/main/java/meteordevelopment/meteorclient/MixinPlugin.java b/src/main/java/meteordevelopment/meteorclient/MixinPlugin.java index c4d672e2f9..ab7d7bb59d 100644 --- a/src/main/java/meteordevelopment/meteorclient/MixinPlugin.java +++ b/src/main/java/meteordevelopment/meteorclient/MixinPlugin.java @@ -29,6 +29,7 @@ public class MixinPlugin implements IMixinConfigPlugin { private static boolean isLithiumPresent; public static boolean isIrisPresent; private static boolean isIndiumPresent; + private static boolean isVFPPresent; @Override public void onLoad(String mixinPackage) { @@ -74,6 +75,7 @@ public void onLoad(String mixinPackage) { isLithiumPresent = FabricLoader.getInstance().isModLoaded("lithium"); isIrisPresent = FabricLoader.getInstance().isModLoaded("iris"); isIndiumPresent = FabricLoader.getInstance().isModLoaded("indium"); + isVFPPresent = FabricLoader.getInstance().isModLoaded("viafabricplus"); loaded = true; } @@ -106,6 +108,9 @@ else if (mixinClassName.startsWith(mixinPackage + ".lithium")) { else if (mixinClassName.startsWith(mixinPackage + ".indium")) { return isIndiumPresent; } + else if (mixinClassName.startsWith(mixinPackage + ".viafabricplus")) { + return isVFPPresent; + } return true; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/viafabricplus/GeneralSettingsMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/viafabricplus/GeneralSettingsMixin.java new file mode 100644 index 0000000000..2bab3594bb --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/viafabricplus/GeneralSettingsMixin.java @@ -0,0 +1,21 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin.viafabricplus; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import de.florianmichael.viafabricplus.settings.impl.GeneralSettings; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(GeneralSettings.class) +public class GeneralSettingsMixin { + // specifies the '2' value on this line: + // public final ModeSetting multiplayerScreenButtonOrientation = new ModeSetting(this, Text.translatable("general_settings.viafabricplus.multiplayer_screen_button_orientation"), 2, ORIENTATION_OPTIONS); + @ModifyExpressionValue(method = "", at = @At(value = "CONSTANT", args = "intValue=2", ordinal = 1)) + private int modifyDefaultPosition(int original) { + return 4; + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2817bcfbad..482ee94175 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,7 +30,8 @@ "meteor-client-sodium.mixins.json", "meteor-client-canvas.mixins.json", "meteor-client-lithium.mixins.json", - "meteor-client-indium.mixins.json" + "meteor-client-indium.mixins.json", + "meteor-client-viafabricplus.mixins.json" ], "accessWidener": "meteor-client.accesswidener", "custom": { diff --git a/src/main/resources/meteor-client-viafabricplus.mixins.json b/src/main/resources/meteor-client-viafabricplus.mixins.json new file mode 100644 index 0000000000..38868b7bcd --- /dev/null +++ b/src/main/resources/meteor-client-viafabricplus.mixins.json @@ -0,0 +1,12 @@ +{ + "required": false, + "package": "meteordevelopment.meteorclient.mixin.viafabricplus", + "compatibilityLevel": "JAVA_21", + "plugin": "meteordevelopment.meteorclient.MixinPlugin", + "client": [ + "GeneralSettingsMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} From c320c13ca117f858b2d0e09c8e088cb76f1de1f4 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Sat, 25 May 2024 20:47:58 +0100 Subject: [PATCH 08/66] fix warning --- .../meteorclient/mixin/viafabricplus/GeneralSettingsMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/viafabricplus/GeneralSettingsMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/viafabricplus/GeneralSettingsMixin.java index 2bab3594bb..b85ee55887 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/viafabricplus/GeneralSettingsMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/viafabricplus/GeneralSettingsMixin.java @@ -14,7 +14,7 @@ public class GeneralSettingsMixin { // specifies the '2' value on this line: // public final ModeSetting multiplayerScreenButtonOrientation = new ModeSetting(this, Text.translatable("general_settings.viafabricplus.multiplayer_screen_button_orientation"), 2, ORIENTATION_OPTIONS); - @ModifyExpressionValue(method = "", at = @At(value = "CONSTANT", args = "intValue=2", ordinal = 1)) + @ModifyExpressionValue(method = "", at = @At(value = "CONSTANT", args = "intValue=2", ordinal = 1), remap = false) private int modifyDefaultPosition(int original) { return 4; } From f647d06bc89b11cda5357bfb3a3003a962aeee71 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Sun, 26 May 2024 16:03:52 +0100 Subject: [PATCH 09/66] Made rage sprint omnidirectional --- .../mixin/ClientPlayerEntityMixin.java | 35 +++++++++++++++---- .../meteorclient/mixin/LivingEntityMixin.java | 19 ++++++++++ .../systems/modules/movement/Sprint.java | 18 ++++++---- 3 files changed, 59 insertions(+), 13 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java index 7b73e5a9dd..72e6d169cb 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java @@ -17,11 +17,13 @@ import meteordevelopment.meteorclient.utils.Utils; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.input.Input; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.damage.DamageSource; 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.Redirect; @@ -30,6 +32,9 @@ @Mixin(ClientPlayerEntity.class) public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity { + @Shadow + public Input input; + public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) { super(world, profile); } @@ -83,6 +88,30 @@ private float onHunger(float constant) { return constant; } + @ModifyExpressionValue(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSneaking()Z")) + private boolean isSneaking(boolean sneaking) { + return Modules.get().get(Sneak.class).doPacket() || Modules.get().get(NoSlow.class).airStrict() || sneaking; + } + + @ModifyExpressionValue(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z")) + private boolean modifyIsWalking(boolean original) { + boolean rage = Modules.get().isActive(Sprint.class) && Modules.get().get(Sprint.class).mode.get() == Sprint.Mode.Rage; + if (!rage) return original; + + float forwards = Math.abs(input.movementSideways); + float sideways = Math.abs(input.movementForward); + + return (isSubmergedInWater() ? (forwards > 1.0E-5F || sideways > 1.0E-5F) : (forwards > 0.8 || sideways > 0.8)); + } + + @ModifyExpressionValue(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;hasForwardMovement()Z")) + private boolean modifyMovement(boolean original) { + boolean rage = Modules.get().isActive(Sprint.class) && Modules.get().get(Sprint.class).mode.get() == Sprint.Mode.Rage; + if (!rage) return original; + + return Math.abs(input.movementSideways) > 1.0E-5F || Math.abs(input.movementForward) > 1.0E-5F; + } + // Rotations @Inject(method = "sendMovementPackets", at = @At("HEAD")) @@ -104,10 +133,4 @@ private void onSendMovementPacketsTail(CallbackInfo info) { private void onTickHasVehicleAfterSendPackets(CallbackInfo info) { MeteorClient.EVENT_BUS.post(SendMovementPacketsEvent.Post.get()); } - - // Sneak - @ModifyExpressionValue(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSneaking()Z")) - private boolean isSneaking(boolean sneaking) { - return Modules.get().get(Sneak.class).doPacket() || Modules.get().get(NoSlow.class).airStrict() || sneaking; - } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java index e11f9e9b0c..f27d36d9b8 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java @@ -5,11 +5,13 @@ package meteordevelopment.meteorclient.mixin; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.entity.DamageEvent; import meteordevelopment.meteorclient.events.entity.player.CanWalkOnFluidEvent; import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.movement.Sprint; import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.ElytraFlightModes; import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.ElytraFly; import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.modes.Bounce; @@ -124,4 +126,21 @@ private boolean hasStatusEffect(boolean original, RegistryEntry ef return original; } + + @ModifyExpressionValue(method = "jump", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getYaw()F")) + private float modifyGetYaw(float original) { + if ((Object) this != mc.player) return original; + + Sprint s = Modules.get().get(Sprint.class); + if (!s.isActive() || s.mode.get() != Sprint.Mode.Rage || !s.jumpFix.get()) return original; + + float forward = Math.signum(mc.player.input.movementForward); + float strafe = 90 * Math.signum(mc.player.input.movementSideways); + if (forward != 0) strafe *= (forward * 0.5f); + + original -= strafe; + if (forward < 0) original -= 180; + + return original; + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java index f499316beb..316e24bcb2 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java @@ -6,6 +6,7 @@ package meteordevelopment.meteorclient.systems.modules.movement; import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.EnumSetting; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.SettingGroup; @@ -21,15 +22,20 @@ public enum Mode { Rage } - private final Setting mode = sgGeneral.add(new EnumSetting.Builder() + public final Setting mode = sgGeneral.add(new EnumSetting.Builder() .name("speed-mode") .description("What mode of sprinting.") .defaultValue(Mode.Strict) .build() ); - // Removed whenStationary as it was just Rage sprint - + public final Setting jumpFix = sgGeneral.add(new BoolSetting.Builder() + .name("jump-fix") + .description("Whether to correct jumping directions.") + .defaultValue(true) + .visible(() -> mode.get() == Mode.Rage) + .build() + ); public Sprint() { super(Categories.Movement, "sprint", "Automatically sprints."); @@ -49,11 +55,9 @@ private void sprint() { private void onTick(TickEvent.Post event) { switch (mode.get()) { case Strict -> { - if (mc.player.forwardSpeed > 0) { - sprint(); - } + if (mc.player.forwardSpeed > 0) sprint(); } case Rage -> sprint(); - } } + } } From 339cf2b801084dec188d505c4add4e86c2e463b1 Mon Sep 17 00:00:00 2001 From: FurnyGo <68079109+FurnyGo@users.noreply.github.com> Date: Mon, 27 May 2024 17:23:56 +0400 Subject: [PATCH 10/66] Add titles to No Render (#4607) --- .../meteorclient/mixin/InGameHudMixin.java | 5 +++++ .../meteorclient/systems/modules/render/NoRender.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/InGameHudMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/InGameHudMixin.java index ec05796a14..768ba8c8e2 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/InGameHudMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/InGameHudMixin.java @@ -98,6 +98,11 @@ private void onRenderCrosshair(DrawContext context, float tickDelta, CallbackInf if (Modules.get().get(NoRender.class).noCrosshair()) ci.cancel(); } + @Inject(method = "renderTitleAndSubtitle", at = @At("HEAD"), cancellable = true) + private void onRenderTitle(DrawContext context, float tickDelta, CallbackInfo ci) { + if (Modules.get().get(NoRender.class).noTitle()) ci.cancel(); + } + @Inject(method = "renderHeldItemTooltip", at = @At("HEAD"), cancellable = true) private void onRenderHeldItemTooltip(DrawContext context, CallbackInfo ci) { if (Modules.get().get(NoRender.class).noHeldItemName()) ci.cancel(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java index 8692934f8a..da62e0aae6 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java @@ -140,6 +140,12 @@ public class NoRender extends Module { .defaultValue(false) .build() ); + private final Setting noTitle = sgHUD.add(new BoolSetting.Builder() + .name("title") + .description("Disables rendering of the title.") + .defaultValue(false) + .build() + ); private final Setting noHeldItemName = sgHUD.add(new BoolSetting.Builder() .name("held-item-name") @@ -436,6 +442,9 @@ public boolean noScoreboard() { public boolean noCrosshair() { return isActive() && noCrosshair.get(); } + public boolean noTitle() { + return isActive() && noTitle.get(); + } public boolean noHeldItemName() { return isActive() && noHeldItemName.get(); From 66549bacaf37812d4e3db93ad294f9f48ff0ba37 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Wed, 29 May 2024 16:46:38 +0100 Subject: [PATCH 11/66] Fix bind command --- .../meteorclient/commands/commands/BindCommand.java | 3 +-- .../meteorclient/systems/modules/Modules.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/BindCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/BindCommand.java index 9811963067..3ef50aa80d 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/BindCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/BindCommand.java @@ -12,8 +12,6 @@ import meteordevelopment.meteorclient.systems.modules.Modules; import net.minecraft.command.CommandSource; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class BindCommand extends Command { public BindCommand() { super("bind", "Binds a specified module to the next pressed key."); @@ -24,6 +22,7 @@ public void build(LiteralArgumentBuilder builder) { builder.then(argument("module", ModuleArgumentType.create()).executes(context -> { Module module = context.getArgument("module", Module.class); Modules.get().setModuleToBind(module); + Modules.get().awaitKeyRelease(); module.info("Press a key to bind the module to."); return SINGLE_SUCCESS; })); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java index 695a28548b..3da4a9aa89 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java @@ -74,6 +74,7 @@ public class Modules extends System { private final List active = new ArrayList<>(); private Module moduleToBind; + private boolean awaitingKeyRelease = false; public Modules() { super("modules"); @@ -220,6 +221,10 @@ public void setModuleToBind(Module moduleToBind) { this.moduleToBind = moduleToBind; } + public void awaitKeyRelease() { + this.awaitingKeyRelease = true; + } + public boolean isBinding() { return moduleToBind != null; } @@ -237,6 +242,11 @@ private void onButtonBinding(MouseButtonEvent event) { private boolean onBinding(boolean isKey, int value, int modifiers) { if (!isBinding()) return false; + if (awaitingKeyRelease) { + awaitingKeyRelease = false; + return false; + } + if (moduleToBind.keybind.canBindTo(isKey, value, modifiers)) { moduleToBind.keybind.set(isKey, value, modifiers); moduleToBind.info("Bound to (highlight)%s(default).", moduleToBind.keybind); From 3494a75c87262740838b2c24618395c36bd42563 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Wed, 29 May 2024 17:07:42 +0100 Subject: [PATCH 12/66] ensure correct key --- .../meteorclient/systems/modules/Modules.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java index 3da4a9aa89..a82ef7f875 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java @@ -221,6 +221,10 @@ public void setModuleToBind(Module moduleToBind) { this.moduleToBind = moduleToBind; } + /*** + * @see meteordevelopment.meteorclient.commands.commands.BindCommand + * For ensuring we don't instantly bind the module to the enter key. + */ public void awaitKeyRelease() { this.awaitingKeyRelease = true; } @@ -243,6 +247,8 @@ private boolean onBinding(boolean isKey, int value, int modifiers) { if (!isBinding()) return false; if (awaitingKeyRelease) { + if (!isKey || value != GLFW.GLFW_KEY_ENTER) return false; + awaitingKeyRelease = false; return false; } From 49f330575973cc2e146efc96ecdf4ec434fe217b Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Fri, 31 May 2024 19:51:23 +0100 Subject: [PATCH 13/66] Add keep sprint setting to the Sprint module closes #4084 --- .../meteorclient/mixin/PlayerEntityMixin.java | 16 ++++++++++++---- .../systems/modules/movement/Sprint.java | 11 +++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityMixin.java index a135ee99e0..8beed23b56 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityMixin.java @@ -6,14 +6,12 @@ package meteordevelopment.meteorclient.mixin; import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.entity.DropItemsEvent; import meteordevelopment.meteorclient.events.entity.player.ClipAtLedgeEvent; import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.movement.Anchor; -import meteordevelopment.meteorclient.systems.modules.movement.Flight; -import meteordevelopment.meteorclient.systems.modules.movement.NoSlow; -import meteordevelopment.meteorclient.systems.modules.movement.Scaffold; +import meteordevelopment.meteorclient.systems.modules.movement.*; import meteordevelopment.meteorclient.systems.modules.player.Reach; import meteordevelopment.meteorclient.systems.modules.player.SpeedMine; import meteordevelopment.meteorclient.utils.world.BlockUtils; @@ -26,6 +24,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -113,6 +112,15 @@ private void onGetOffGroundSpeed(CallbackInfoReturnable info) { if (speed != -1) info.setReturnValue(speed); } + @WrapWithCondition(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V")) + private boolean keepSprint$setVelocity(PlayerEntity instance, Vec3d vec3d) { + return Modules.get().get(Sprint.class).stopSprinting(); + } + + @WrapWithCondition(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setSprinting(Z)V")) + private boolean keepSprint$setSprinting(PlayerEntity instance, boolean b) { + return Modules.get().get(Sprint.class).stopSprinting(); + } @ModifyReturnValue(method = "getBlockInteractionRange", at = @At("RETURN")) private double modifyBlockInteractionRange(double original) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java index 316e24bcb2..5b8e15e915 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java @@ -37,6 +37,13 @@ public enum Mode { .build() ); + private final Setting keepSprint = sgGeneral.add(new BoolSetting.Builder() + .name("keep-sprint") + .description("Whether to keep sprinting after attacking an entity.") + .defaultValue(false) + .build() + ); + public Sprint() { super(Categories.Movement, "sprint", "Automatically sprints."); } @@ -60,4 +67,8 @@ private void onTick(TickEvent.Post event) { case Rage -> sprint(); } } + + public boolean stopSprinting() { + return !isActive() || !keepSprint.get(); + } } From 3e49a94fea765f246dd6ace819ad4b2a93e022f8 Mon Sep 17 00:00:00 2001 From: misterx Date: Mon, 3 Jun 2024 16:44:48 +0200 Subject: [PATCH 14/66] fixed lithium border collisions #4618 --- .../lithium/LithiumEntityCollisionsMixin.java | 26 +++++++++++++++++++ .../systems/modules/world/Collisions.java | 2 +- .../meteor-client-lithium.mixins.json | 3 ++- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/lithium/LithiumEntityCollisionsMixin.java diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/lithium/LithiumEntityCollisionsMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/lithium/LithiumEntityCollisionsMixin.java new file mode 100644 index 0000000000..e04058c0ab --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/lithium/LithiumEntityCollisionsMixin.java @@ -0,0 +1,26 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin.lithium; + +import me.jellysquid.mods.lithium.common.entity.LithiumEntityCollisions; +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.world.Collisions; +import net.minecraft.util.math.Box; +import net.minecraft.world.border.WorldBorder; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(value = LithiumEntityCollisions.class) +public class LithiumEntityCollisionsMixin { + @Inject(method = "isWithinWorldBorder", at = @At("HEAD"), cancellable = true) + private static void onIsWithinWorldBorder(WorldBorder border, Box box, CallbackInfoReturnable cir) { + if (Modules.get().get(Collisions.class).ignoreBorder()) { + cir.setReturnValue(true); + } + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Collisions.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Collisions.java index 0c441ba7c5..49ae4a1f6b 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Collisions.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Collisions.java @@ -113,6 +113,6 @@ private boolean blockFilter(Block block) { } public boolean ignoreBorder() { - return isActive() && ignoreBorder.get(); + return isActive() && ignoreBorder.get(); } } diff --git a/src/main/resources/meteor-client-lithium.mixins.json b/src/main/resources/meteor-client-lithium.mixins.json index fcad6bd961..58e8d53b0a 100644 --- a/src/main/resources/meteor-client-lithium.mixins.json +++ b/src/main/resources/meteor-client-lithium.mixins.json @@ -4,7 +4,8 @@ "compatibilityLevel": "JAVA_21", "plugin": "meteordevelopment.meteorclient.MixinPlugin", "client": [ - "ChunkAwareBlockCollisionSweeperMixin" + "ChunkAwareBlockCollisionSweeperMixin", + "LithiumEntityCollisionsMixin" ], "injectors": { "defaultRequire": 1 From 580ad3f3e517d048a90a535631e3dc6d9f3c7283 Mon Sep 17 00:00:00 2001 From: tyrannus00 Date: Wed, 5 Jun 2024 18:07:31 +0200 Subject: [PATCH 15/66] Fixed incompatibility with Bleachhack420 --- .../mixin/BlockCollisionSpliteratorMixin.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BlockCollisionSpliteratorMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BlockCollisionSpliteratorMixin.java index e40b859046..69856efc23 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/BlockCollisionSpliteratorMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BlockCollisionSpliteratorMixin.java @@ -5,6 +5,8 @@ package meteordevelopment.meteorclient.mixin; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.world.CollisionShapeEvent; import net.minecraft.block.BlockState; @@ -17,16 +19,22 @@ import net.minecraft.world.BlockView; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(BlockCollisionSpliterator.class) public abstract class BlockCollisionSpliteratorMixin { - @Redirect(method = "computeNext", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getCollisionShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;")) - private VoxelShape onComputeNextCollisionBox(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - VoxelShape shape = state.getCollisionShape(world, pos, context); - if (world != MinecraftClient.getInstance().world) + @WrapOperation(method = "computeNext", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/block/BlockState;getCollisionShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;" + ) + ) + private VoxelShape onComputeNextCollisionBox(BlockState state, BlockView world, BlockPos pos, ShapeContext context, Operation original) { + VoxelShape shape = original.call(state, world, pos, context); + + if (world != MinecraftClient.getInstance().world) { return shape; + } CollisionShapeEvent event = MeteorClient.EVENT_BUS.post(CollisionShapeEvent.get(state, pos, shape)); return event.isCancelled() ? VoxelShapes.empty() : event.shape; From 94ee5c6173592479b48b8dd0e6a26a97bda3d0b6 Mon Sep 17 00:00:00 2001 From: Big Iron <52252627+Big-Iron-Cheems@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:54:27 +0200 Subject: [PATCH 16/66] NoRender: map content (#4624) --- .../meteorclient/mixin/MapRendererMixin.java | 9 +++++++++ .../meteorclient/systems/modules/render/NoRender.java | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/MapRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/MapRendererMixin.java index 0394134d7e..9df35f2209 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/MapRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/MapRendererMixin.java @@ -10,9 +10,13 @@ import meteordevelopment.meteorclient.systems.modules.render.NoRender; import meteordevelopment.meteorclient.utils.misc.EmptyIterator; import net.minecraft.client.render.MapRenderer; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.map.MapDecoration; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(MapRenderer.MapTexture.class) public abstract class MapRendererMixin { @@ -20,4 +24,9 @@ public abstract class MapRendererMixin { private Iterable getIconsProxy(Iterable original) { return (Modules.get().get(NoRender.class).noMapMarkers()) ? EmptyIterator::new : original; } + + @Inject(method = "draw(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ZI)V", at = @At("HEAD"), cancellable = true) + private void onDraw(MatrixStack matrices, VertexConsumerProvider vertexConsumers, boolean hidePlayerIcons, int light, CallbackInfo ci) { + if (Modules.get().get(NoRender.class).noMapContents()) ci.cancel(); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java index da62e0aae6..5ab56f9d10 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/NoRender.java @@ -269,6 +269,13 @@ public class NoRender extends Module { .build() ); + private final Setting noMapContents = sgWorld.add(new BoolSetting.Builder() + .name("map-contents") + .description("Disable rendering of maps.") + .defaultValue(false) + .build() + ); + private final Setting bannerRender = sgWorld.add(new EnumSetting.Builder() .name("banners") .description("Changes rendering of banners.") @@ -517,6 +524,10 @@ public boolean noMapMarkers() { return isActive() && noMapMarkers.get(); } + public boolean noMapContents() { + return isActive() && noMapContents.get(); + } + public BannerRenderMode getBannerRenderMode() { if (!isActive()) return BannerRenderMode.Everything; else return bannerRender.get(); From f08df5c9898f7c94f9db8570f4bee89a4ed77fcd Mon Sep 17 00:00:00 2001 From: 19MisterX98 <41451155+19MisterX98@users.noreply.github.com> Date: Wed, 12 Jun 2024 02:25:05 +0200 Subject: [PATCH 17/66] fixed hud default elements not working (#4634) --- .../java/meteordevelopment/meteorclient/systems/hud/Hud.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/Hud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/Hud.java index b5d898e329..d04a1b3b71 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/Hud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/Hud.java @@ -208,13 +208,14 @@ private void resetToDefaultElementsImpl() { @EventHandler private void onTick(TickEvent.Post event) { if (Utils.isLoading()) return; - if (!(active || HudEditorScreen.isOpen())) return; if (resetToDefaultElements) { resetToDefaultElementsImpl(); resetToDefaultElements = false; } + if (!(active || HudEditorScreen.isOpen())) return; + for (HudElement element : elements) { if (element.isActive()) element.tick(HudRenderer.INSTANCE); } From c82f0c03b683c93173a52aaabaeee115bd5e73c1 Mon Sep 17 00:00:00 2001 From: RealMuffinTime Date: Fri, 24 May 2024 21:33:29 +0200 Subject: [PATCH 18/66] add anti chat clear option to BetterChat --- .../systems/modules/misc/BetterChat.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java index 5c9944b0aa..d5e4d62ba5 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java @@ -112,6 +112,13 @@ public class BetterChat extends Module { .build() ); + private final Setting antiClear = sgFilter.add(new BoolSetting.Builder() + .name("anti-clear") + .description("Prevents servers from clearing chat.") + .defaultValue(true) + .build() + ); + private final Setting filterRegex = sgFilter.add(new BoolSetting.Builder() .name("filter-regex") .description("Filter out chat messages that match the regex filter.") @@ -219,6 +226,7 @@ public class BetterChat extends Module { ); private static final Pattern antiSpamRegex = Pattern.compile(" \\(([0-9]+)\\)$"); + private static final Pattern antiClearRegex = Pattern.compile("\\\\n(\\\\n|\\s)*\\\\n"); private static final Pattern timestampRegex = Pattern.compile("^(<[0-9]{2}:[0-9]{2}>\\s)"); private static final Pattern usernameRegex = Pattern.compile("^(?:<[0-9]{2}:[0-9]{2}>\\s)?<(.*?)>.*"); @@ -249,6 +257,16 @@ private void onMessageReceive(ReceiveMessageEvent event) { } } + if (antiClear.get()) { + // more than two \n behind each other will be reduced to only two \n + String jsonString = Text.Serialization.toJsonString(message, mc.player.getRegistryManager()); + + Matcher antiClearMatcher = antiClearRegex.matcher(jsonString); + String replacedString = antiClearMatcher.replaceAll("\n\n"); + + message = (Text) Text.Serialization.fromJson(replacedString, mc.player.getRegistryManager()); + } + if (antiSpam.get()) { Text antiSpammed = appendAntiSpam(message); From 1a859f05cb40300b065a397575514e0be0025cd0 Mon Sep 17 00:00:00 2001 From: triskj0 Date: Wed, 12 Jun 2024 19:04:07 +0200 Subject: [PATCH 19/66] fix chest swapping after getting an error with pitch40 --- .../systems/modules/movement/elytrafly/ElytraFly.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/elytrafly/ElytraFly.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/elytrafly/ElytraFly.java index 0fccaba54e..58c4348446 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/elytrafly/ElytraFly.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/elytrafly/ElytraFly.java @@ -341,11 +341,11 @@ public ElytraFly() { @Override public void onActivate() { - currentMode.onActivate(); if ((chestSwap.get() == ChestSwapMode.Always || chestSwap.get() == ChestSwapMode.WaitForGround) && mc.player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) { Modules.get().get(ChestSwap.class).swap(); } + currentMode.onActivate(); } @Override From 1c15b021cd7b582afe01e65ad5d4e3ed19186354 Mon Sep 17 00:00:00 2001 From: triskj0 Date: Wed, 12 Jun 2024 21:05:44 +0200 Subject: [PATCH 20/66] suggested change --- .../systems/modules/movement/elytrafly/ElytraFly.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/elytrafly/ElytraFly.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/elytrafly/ElytraFly.java index 58c4348446..d3ad217585 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/elytrafly/ElytraFly.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/elytrafly/ElytraFly.java @@ -341,11 +341,11 @@ public ElytraFly() { @Override public void onActivate() { + currentMode.onActivate(); if ((chestSwap.get() == ChestSwapMode.Always || chestSwap.get() == ChestSwapMode.WaitForGround) - && mc.player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) { + && mc.player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA && isActive()) { Modules.get().get(ChestSwap.class).swap(); } - currentMode.onActivate(); } @Override From e2e92dfbcb0922676a2e3673b386f33ff30c3913 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Thu, 13 Jun 2024 12:48:08 +0100 Subject: [PATCH 21/66] Add waypoint fade distance setting --- .../systems/modules/render/WaypointsModule.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java index 4c28321b0f..569c4ba515 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java @@ -57,6 +57,15 @@ public class WaypointsModule extends Module { .build() ); + private final Setting waypointFadeDistance = sgGeneral.add(new IntSetting.Builder() + .name("waypoint-fade-distance") + .description("The distance to a waypoint at which it begins to start fading.") + .defaultValue(20) + .sliderRange(0, 100) + .min(0) + .build() + ); + private final Setting maxDeathPositions = sgDeathPosition.add(new IntSetting.Builder() .name("max-death-positions") .description("The amount of death positions to save, 0 to disable") @@ -103,8 +112,8 @@ private void onRender2D(Render2DEvent event) { double distToCenter = pos.distance(center); double a = 1; - if (dist < 20) { - a = (dist - 10) / 10; + if (dist < waypointFadeDistance.get()) { + a = (dist - (waypointFadeDistance.get() / 2d)) / (waypointFadeDistance.get() / 2d); if (a < 0.01) continue; } From 6704302aa7332c3be2823ec00bba28929a65b461 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Thu, 13 Jun 2024 14:46:06 +0100 Subject: [PATCH 22/66] Rename the 'Instamine' module to 'Instant Rebreak' Should hopefully avoid confusion with how the module works. Closes #4631 --- .../meteorclient/systems/modules/Modules.java | 2 +- .../{InstaMine.java => InstantRebreak.java} | 6 ++-- .../systems/modules/world/HighwayBuilder.java | 28 +++++++++---------- .../meteorclient/utils/world/BlockUtils.java | 13 +++++---- 4 files changed, 26 insertions(+), 23 deletions(-) rename src/main/java/meteordevelopment/meteorclient/systems/modules/player/{InstaMine.java => InstantRebreak.java} (96%) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java index a82ef7f875..e50ec6e586 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java @@ -441,7 +441,7 @@ private void initPlayer() { add(new FakePlayer()); add(new FastUse()); add(new GhostHand()); - add(new InstaMine()); + add(new InstantRebreak()); add(new LiquidInteract()); add(new MiddleClickExtra()); add(new BreakDelay()); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/InstaMine.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/InstantRebreak.java similarity index 96% rename from src/main/java/meteordevelopment/meteorclient/systems/modules/player/InstaMine.java rename to src/main/java/meteordevelopment/meteorclient/systems/modules/player/InstantRebreak.java index 71efa7ea0f..7994ed980f 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/InstaMine.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/InstantRebreak.java @@ -23,7 +23,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -public class InstaMine extends Module { +public class InstantRebreak extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgRender = settings.createGroup("Render"); @@ -84,8 +84,8 @@ public class InstaMine extends Module { private int ticks; private Direction direction; - public InstaMine() { - super(Categories.Player, "insta-mine", "Instantly re-breaks blocks in the same position."); + public InstantRebreak() { + super(Categories.Player, "instant-rebreak", "Instantly re-breaks blocks in the same position."); } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java index fb1acf7d63..657525a1dd 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java @@ -16,7 +16,7 @@ import meteordevelopment.meteorclient.systems.modules.player.AutoEat; import meteordevelopment.meteorclient.systems.modules.player.AutoGap; import meteordevelopment.meteorclient.systems.modules.player.AutoTool; -import meteordevelopment.meteorclient.systems.modules.player.InstaMine; +import meteordevelopment.meteorclient.systems.modules.player.InstantRebreak; import meteordevelopment.meteorclient.utils.misc.HorizontalDirection; import meteordevelopment.meteorclient.utils.misc.MBlockPos; import meteordevelopment.meteorclient.utils.player.CustomPlayerInput; @@ -239,20 +239,20 @@ public enum Rotation { .build() ); - private final Setting instamineEchests = sgInventory.add(new BoolSetting.Builder() - .name("instamine-echests") - .description("Whether or not to use the instamine exploit to break echests.") + private final Setting rebreakEchests = sgInventory.add(new BoolSetting.Builder() + .name("instantly-rebreak-echests") + .description("Whether or not to use the instant rebreak exploit to break echests.") .defaultValue(false) .visible(mineEnderChests::get) .build() ); - private final Setting instamineDelay = sgInventory.add(new IntSetting.Builder() - .name("instamine-delay") - .description("Delay between instamine attempts.") + private final Setting rebreakTimer = sgInventory.add(new IntSetting.Builder() + .name("rebreak-delay") + .description("Delay between rebreak attempts.") .defaultValue(0) .sliderMax(20) - .visible(() -> mineEnderChests.get() && instamineEchests.get()) + .visible(() -> mineEnderChests.get() && rebreakEchests.get()) .build() ); @@ -371,7 +371,7 @@ public void onActivate() { if (blocksPerTick.get() > 1 && rotation.get().mine) warning("With rotations enabled, you can break at most 1 block per tick."); if (placementsPerTick.get() > 1 && rotation.get().place) warning("With rotations enabled, you can place at most 1 block per tick."); - if (Modules.get().get(InstaMine.class).isActive()) warning("It's recommended to disable the InstaMine module and instead use 'instamine-echests' to avoid errors."); + if (Modules.get().get(InstantRebreak.class).isActive()) warning("It's recommended to disable the Instant Rebreak module and instead use the 'instantly-rebreak-echests' setting to avoid errors."); } @Override @@ -758,7 +758,7 @@ protected void tick(HighwayBuilder b) { private int minimumObsidian; private boolean first, primed; private boolean stopTimerEnabled; - private int stopTimer, moveTimer, instamineTimer; + private int stopTimer, moveTimer, rebreakTimer; @Override protected void start(HighwayBuilder b) { @@ -856,14 +856,14 @@ protected void tick(HighwayBuilder b) { InvUtils.swap(slot, false); - if (b.instamineEchests.get() && primed) { - if (instamineTimer > 0) { - instamineTimer--; + if (b.rebreakEchests.get() && primed) { + if (rebreakTimer > 0) { + rebreakTimer--; return; } PlayerActionC2SPacket p = new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, bp, BlockUtils.getDirection(bp)); - instamineTimer = b.instamineDelay.get(); + rebreakTimer = b.rebreakTimer.get(); if (b.rotation.get().mine) Rotations.rotate(Rotations.getYaw(bp), Rotations.getPitch(bp), () -> b.mc.getNetworkHandler().sendPacket(p)); else b.mc.getNetworkHandler().sendPacket(p); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java index ef5cc93a1e..e260159c57 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java @@ -8,9 +8,12 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.systems.modules.Modules; -import meteordevelopment.meteorclient.systems.modules.player.InstaMine; +import meteordevelopment.meteorclient.systems.modules.player.InstantRebreak; import meteordevelopment.meteorclient.utils.PreInit; -import meteordevelopment.meteorclient.utils.player.*; +import meteordevelopment.meteorclient.utils.player.FindItemResult; +import meteordevelopment.meteorclient.utils.player.InvUtils; +import meteordevelopment.meteorclient.utils.player.Rotations; +import meteordevelopment.meteorclient.utils.player.SlotUtils; import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventPriority; import net.minecraft.block.*; @@ -235,9 +238,9 @@ public static boolean breakBlock(BlockPos blockPos, boolean swing) { // Creating new instance of block pos because minecraft assigns the parameter to a field, and we don't want it to change when it has been stored in a field somewhere BlockPos pos = blockPos instanceof BlockPos.Mutable ? new BlockPos(blockPos) : blockPos; - InstaMine im = Modules.get().get(InstaMine.class); - if (im != null && im.isActive() && im.blockPos.equals(pos) && im.shouldMine()) { - im.sendPacket(); + InstantRebreak ir = Modules.get().get(InstantRebreak.class); + if (ir != null && ir.isActive() && ir.blockPos.equals(pos) && ir.shouldMine()) { + ir.sendPacket(); return true; } From b3e260d341642850ba1f8cb63b2bfc9a542d69b5 Mon Sep 17 00:00:00 2001 From: misterx Date: Thu, 13 Jun 2024 18:16:23 +0200 Subject: [PATCH 23/66] hostnames can have minus hyphens --- src/main/java/meteordevelopment/meteorclient/utils/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/utils/Utils.java b/src/main/java/meteordevelopment/meteorclient/utils/Utils.java index 7a32b27a27..182b33176e 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/Utils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/Utils.java @@ -595,6 +595,6 @@ public static boolean nameFilter(String text, char character) { public static boolean ipFilter(String text, char character) { if (text.contains(":") && character == ':') return false; - return (character >= 'a' && character <= 'z') || (character >= 'A' && character <= 'Z') || (character >= '0' && character <= '9') || character == '.'; + return (character >= 'a' && character <= 'z') || (character >= 'A' && character <= 'Z') || (character >= '0' && character <= '9') || character == '.' || character == '-'; } } From 546d0b945a98c61cafd4cd9330db3936eee286d1 Mon Sep 17 00:00:00 2001 From: Wide-Cat <74723656+Wide-Cat@users.noreply.github.com> Date: Fri, 14 Jun 2024 21:21:09 +0100 Subject: [PATCH 24/66] Abstract shared code in prompts (#4641) --- .../utils/render/prompts/OkPrompt.java | 101 ++------------- .../utils/render/prompts/Prompt.java | 98 +++++++++++++++ .../utils/render/prompts/YesNoPrompt.java | 116 +++--------------- 3 files changed, 127 insertions(+), 188 deletions(-) create mode 100644 src/main/java/meteordevelopment/meteorclient/utils/render/prompts/Prompt.java diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/prompts/OkPrompt.java b/src/main/java/meteordevelopment/meteorclient/utils/render/prompts/OkPrompt.java index 6ec2986500..9f909773e2 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/prompts/OkPrompt.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/prompts/OkPrompt.java @@ -5,120 +5,41 @@ package meteordevelopment.meteorclient.utils.render.prompts; -import com.mojang.blaze3d.systems.RenderSystem; import meteordevelopment.meteorclient.gui.GuiTheme; import meteordevelopment.meteorclient.gui.GuiThemes; -import meteordevelopment.meteorclient.gui.WindowScreen; -import meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList; import meteordevelopment.meteorclient.gui.widgets.pressable.WButton; -import meteordevelopment.meteorclient.gui.widgets.pressable.WCheckbox; import meteordevelopment.meteorclient.systems.config.Config; import net.minecraft.client.gui.screen.Screen; -import java.util.ArrayList; -import java.util.List; - import static meteordevelopment.meteorclient.MeteorClient.mc; -public class OkPrompt { - private final GuiTheme theme; - private final Screen parent; - - private String title = ""; - private final List messages = new ArrayList<>(); - private boolean dontShowAgainCheckboxVisible = true; - private String id = null; - +public class OkPrompt extends Prompt { private Runnable onOk = () -> {}; - private OkPrompt() { - this(GuiThemes.get(), mc.currentScreen); - } - private OkPrompt(GuiTheme theme, Screen parent) { - this.theme = theme; - this.parent = parent; + super(theme, parent); } public static OkPrompt create() { - return new OkPrompt(); + return new OkPrompt(GuiThemes.get(), mc.currentScreen); } public static OkPrompt create(GuiTheme theme, Screen parent) { return new OkPrompt(theme, parent); } - public OkPrompt title(String title) { - this.title = title; - return this; - } - - public OkPrompt message(String message) { - this.messages.add(message); - return this; - } - - public OkPrompt message(String message, Object... args) { - this.messages.add(String.format(message, args)); - return this; - } - - public OkPrompt dontShowAgainCheckboxVisible(boolean visible) { - this.dontShowAgainCheckboxVisible = visible; - return this; - } - - public OkPrompt id(String from) { - this.id = from; - return this; - } - public OkPrompt onOk(Runnable action) { this.onOk = action; return this; } - public boolean show() { - if (id == null) this.id(this.title); - if (Config.get().dontShowAgainPrompts.contains(id)) return false; - - if (!RenderSystem.isOnRenderThread()) { - RenderSystem.recordRenderCall(() -> mc.setScreen(new PromptScreen(theme))); - } - else { - mc.setScreen(new PromptScreen(theme)); - } - - return true; - } - - private class PromptScreen extends WindowScreen { - public PromptScreen(GuiTheme theme) { - super(theme, OkPrompt.this.title); - - this.parent = OkPrompt.this.parent; - } - - @Override - public void initWidgets() { - for (String line : messages) add(theme.label(line)).expandX(); - add(theme.horizontalSeparator()).expandX(); - - WCheckbox dontShowAgainCheckbox; - - if (dontShowAgainCheckboxVisible) { - WHorizontalList checkboxContainer = add(theme.horizontalList()).expandX().widget(); - dontShowAgainCheckbox = checkboxContainer.add(theme.checkbox(false)).widget(); - checkboxContainer.add(theme.label("Don't show this again.")).expandX(); - } else dontShowAgainCheckbox = null; - - WHorizontalList list = add(theme.horizontalList()).expandX().widget(); - WButton okButton = list.add(theme.button("Ok")).expandX().widget(); - okButton.action = () -> { - if (dontShowAgainCheckbox != null && dontShowAgainCheckbox.checked) Config.get().dontShowAgainPrompts.add(id); - onOk.run(); - close(); - }; - } + @Override + protected void initialiseWidgets(PromptScreen screen) { + WButton okButton = screen.list.add(theme.button("Ok")).expandX().widget(); + okButton.action = () -> { + if (screen.dontShowAgainCheckbox != null && screen.dontShowAgainCheckbox.checked) Config.get().dontShowAgainPrompts.add(id); + onOk.run(); + screen.close(); + }; } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/prompts/Prompt.java b/src/main/java/meteordevelopment/meteorclient/utils/render/prompts/Prompt.java new file mode 100644 index 0000000000..da8372968b --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/prompts/Prompt.java @@ -0,0 +1,98 @@ +package meteordevelopment.meteorclient.utils.render.prompts; + +import com.mojang.blaze3d.systems.RenderSystem; +import meteordevelopment.meteorclient.gui.GuiTheme; +import meteordevelopment.meteorclient.gui.WindowScreen; +import meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList; +import meteordevelopment.meteorclient.gui.widgets.pressable.WCheckbox; +import meteordevelopment.meteorclient.systems.config.Config; +import net.minecraft.client.gui.screen.Screen; + +import java.util.ArrayList; +import java.util.List; + +import static meteordevelopment.meteorclient.MeteorClient.mc; + +@SuppressWarnings("unchecked") // cant instantiate a Prompt directly so this is fine +public abstract class Prompt { + final GuiTheme theme; + final Screen parent; + + String title = ""; + final List messages = new ArrayList<>(); + boolean dontShowAgainCheckboxVisible = true; + String id = null; + + protected Prompt(GuiTheme theme, Screen parent) { + this.theme = theme; + this.parent = parent; + } + + public T title(String title) { + this.title = title; + return (T) this; + } + + public T message(String message) { + this.messages.add(message); + return (T) this; + } + + public T message(String message, Object... args) { + this.messages.add(String.format(message, args)); + return (T) this; + } + + public T dontShowAgainCheckboxVisible(boolean visible) { + this.dontShowAgainCheckboxVisible = visible; + return (T) this; + } + + public T id(String from) { + this.id = from; + return (T) this; + } + + public boolean show() { + if (id == null) this.id(this.title); + if (Config.get().dontShowAgainPrompts.contains(id)) return false; + + if (!RenderSystem.isOnRenderThread()) { + RenderSystem.recordRenderCall(() -> mc.setScreen(new PromptScreen(theme))); + } + else { + mc.setScreen(new PromptScreen(theme)); + } + + return true; + } + + abstract void initialiseWidgets(PromptScreen screen); + + protected class PromptScreen extends WindowScreen { + WCheckbox dontShowAgainCheckbox; + WHorizontalList list; + + public PromptScreen(GuiTheme theme) { + super(theme, Prompt.this.title); + + this.parent = Prompt.this.parent; + } + + @Override + public void initWidgets() { + for (String line : messages) add(theme.label(line)).expandX(); + add(theme.horizontalSeparator()).expandX(); + + if (dontShowAgainCheckboxVisible) { + WHorizontalList checkboxContainer = add(theme.horizontalList()).expandX().widget(); + dontShowAgainCheckbox = checkboxContainer.add(theme.checkbox(false)).widget(); + checkboxContainer.add(theme.label("Don't show this again.")).expandX(); + } else dontShowAgainCheckbox = null; + + list = add(theme.horizontalList()).expandX().widget(); + + initialiseWidgets(this); + } + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/prompts/YesNoPrompt.java b/src/main/java/meteordevelopment/meteorclient/utils/render/prompts/YesNoPrompt.java index edf8d4e9fb..ccb1a4d250 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/prompts/YesNoPrompt.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/prompts/YesNoPrompt.java @@ -5,75 +5,30 @@ package meteordevelopment.meteorclient.utils.render.prompts; -import com.mojang.blaze3d.systems.RenderSystem; import meteordevelopment.meteorclient.gui.GuiTheme; import meteordevelopment.meteorclient.gui.GuiThemes; -import meteordevelopment.meteorclient.gui.WindowScreen; -import meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList; import meteordevelopment.meteorclient.gui.widgets.pressable.WButton; -import meteordevelopment.meteorclient.gui.widgets.pressable.WCheckbox; import meteordevelopment.meteorclient.systems.config.Config; import net.minecraft.client.gui.screen.Screen; -import java.util.ArrayList; -import java.util.List; - import static meteordevelopment.meteorclient.MeteorClient.mc; -public class YesNoPrompt { - private final GuiTheme theme; - private final Screen parent; - - private String title = ""; - private final List messages = new ArrayList<>(); - private boolean dontShowAgainCheckboxVisible = true; - private String id = null; - +public class YesNoPrompt extends Prompt { private Runnable onYes = () -> {}; private Runnable onNo = () -> {}; - private YesNoPrompt() { - this(GuiThemes.get(), mc.currentScreen); - } - private YesNoPrompt(GuiTheme theme, Screen parent) { - this.theme = theme; - this.parent = parent; + super(theme, parent); } public static YesNoPrompt create() { - return new YesNoPrompt(); + return new YesNoPrompt(GuiThemes.get(), mc.currentScreen); } public static YesNoPrompt create(GuiTheme theme, Screen parent) { return new YesNoPrompt(theme, parent); } - public YesNoPrompt title(String title) { - this.title = title; - return this; - } - - public YesNoPrompt message(String message) { - this.messages.add(message); - return this; - } - - public YesNoPrompt message(String message, Object... args) { - this.messages.add(String.format(message, args)); - return this; - } - - public YesNoPrompt dontShowAgainCheckboxVisible(boolean visible) { - this.dontShowAgainCheckboxVisible = visible; - return this; - } - - public YesNoPrompt id(String from) { - this.id = from; - return this; - } - public YesNoPrompt onYes(Runnable action) { this.onYes = action; return this; @@ -84,55 +39,20 @@ public YesNoPrompt onNo(Runnable action) { return this; } - public boolean show() { - if (id == null) this.id(this.title); - if (Config.get().dontShowAgainPrompts.contains(id)) return false; - - if (!RenderSystem.isOnRenderThread()) { - RenderSystem.recordRenderCall(() -> mc.setScreen(new PromptScreen(theme))); - } - else { - mc.setScreen(new PromptScreen(theme)); - } - - return true; - } - - private class PromptScreen extends WindowScreen { - public PromptScreen(GuiTheme theme) { - super(theme, YesNoPrompt.this.title); - - this.parent = YesNoPrompt.this.parent; - } - - @Override - public void initWidgets() { - for (String line : messages) add(theme.label(line)).expandX(); - add(theme.horizontalSeparator()).expandX(); - - WCheckbox dontShowAgainCheckbox; - - if (dontShowAgainCheckboxVisible) { - WHorizontalList checkboxContainer = add(theme.horizontalList()).expandX().widget(); - dontShowAgainCheckbox = checkboxContainer.add(theme.checkbox(false)).widget(); - checkboxContainer.add(theme.label("Don't show this again.")).expandX(); - } else dontShowAgainCheckbox = null; - - WHorizontalList list = add(theme.horizontalList()).expandX().widget(); - - WButton yesButton = list.add(theme.button("Yes")).expandX().widget(); - yesButton.action = () -> { - if (dontShowAgainCheckbox != null && dontShowAgainCheckbox.checked) Config.get().dontShowAgainPrompts.add(id); - onYes.run(); - close(); - }; - - WButton noButton = list.add(theme.button("No")).expandX().widget(); - noButton.action = () -> { - if (dontShowAgainCheckbox != null && dontShowAgainCheckbox.checked) Config.get().dontShowAgainPrompts.add(id); - onNo.run(); - close(); - }; - } + @Override + protected void initialiseWidgets(PromptScreen screen) { + WButton yesButton = screen.list.add(theme.button("Yes")).expandX().widget(); + yesButton.action = () -> { + if (screen.dontShowAgainCheckbox != null && screen.dontShowAgainCheckbox.checked) Config.get().dontShowAgainPrompts.add(id); + onYes.run(); + screen.close(); + }; + + WButton noButton = screen.list.add(theme.button("No")).expandX().widget(); + noButton.action = () -> { + if (screen.dontShowAgainCheckbox != null && screen.dontShowAgainCheckbox.checked) Config.get().dontShowAgainPrompts.add(id); + onNo.run(); + screen.close(); + }; } } From c47000887f1d7cd2fa5518087925239fa8bd8c0a Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Tue, 18 Jun 2024 13:37:16 +0100 Subject: [PATCH 25/66] Fix issue with better chat and clientside messages Co-authored-by: RacoonDog <32882447+racoondog@users.noreply.github.com> --- .../systems/modules/misc/BetterChat.java | 32 ++++++++----- .../utils/misc/text/TextVisitor.java | 46 +++++++++++++++++++ 2 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 src/main/java/meteordevelopment/meteorclient/utils/misc/text/TextVisitor.java diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java index d5e4d62ba5..be32f76f40 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java @@ -23,16 +23,14 @@ import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; import meteordevelopment.meteorclient.utils.misc.text.MeteorClickEvent; +import meteordevelopment.meteorclient.utils.misc.text.TextVisitor; import meteordevelopment.meteorclient.utils.player.ChatUtils; import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.orbit.EventHandler; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.ChatHudLine; import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.text.ClickEvent; -import net.minecraft.text.HoverEvent; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; +import net.minecraft.text.*; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; @@ -40,6 +38,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -226,7 +225,7 @@ public class BetterChat extends Module { ); private static final Pattern antiSpamRegex = Pattern.compile(" \\(([0-9]+)\\)$"); - private static final Pattern antiClearRegex = Pattern.compile("\\\\n(\\\\n|\\s)*\\\\n"); + private static final Pattern antiClearRegex = Pattern.compile("\\\\n(\\\\n|\\s)+\\\\n"); private static final Pattern timestampRegex = Pattern.compile("^(<[0-9]{2}:[0-9]{2}>\\s)"); private static final Pattern usernameRegex = Pattern.compile("^(?:<[0-9]{2}:[0-9]{2}>\\s)?<(.*?)>.*"); @@ -258,13 +257,22 @@ private void onMessageReceive(ReceiveMessageEvent event) { } if (antiClear.get()) { - // more than two \n behind each other will be reduced to only two \n - String jsonString = Text.Serialization.toJsonString(message, mc.player.getRegistryManager()); - - Matcher antiClearMatcher = antiClearRegex.matcher(jsonString); - String replacedString = antiClearMatcher.replaceAll("\n\n"); - - message = (Text) Text.Serialization.fromJson(replacedString, mc.player.getRegistryManager()); + String messageString = message.getString(); + if (antiClearRegex.matcher(messageString).matches()) { + MutableText newMessage = Text.empty(); + TextVisitor.visit(message, (text, style, string) -> { + Matcher antiClearMatcher = antiClearRegex.matcher(string); + if (antiClearMatcher.matches()) { + // assume literal text content + newMessage.append(Text.literal(antiClearMatcher.replaceAll("\n\n")).setStyle(style)); + } else { + newMessage.append(text.copyContentOnly().setStyle(style)); + } + + return Optional.empty(); + }, Style.EMPTY); + message = newMessage; + } } if (antiSpam.get()) { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/text/TextVisitor.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/text/TextVisitor.java new file mode 100644 index 0000000000..9fc1f5ae0e --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/text/TextVisitor.java @@ -0,0 +1,46 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.utils.misc.text; + +import net.minecraft.text.Style; +import net.minecraft.text.Text; + +import java.util.ArrayDeque; +import java.util.Optional; +import java.util.Queue; + +/** + * An extension of {@link net.minecraft.text.StringVisitable.StyledVisitor} with access to the underlying {@link Text} objects. + * @param the optional short circuit return type, to match the semantics of {@link net.minecraft.text.StringVisitable.Visitor} and {@link net.minecraft.text.StringVisitable.StyledVisitor}. + * @author Crosby + */ +@FunctionalInterface +public interface TextVisitor { + Optional accept(Text text, Style style, String string); + + static Optional visit(Text text, TextVisitor visitor, Style baseStyle) { + Queue queue = collectSiblings(text); + return text.visit((style, string) -> visitor.accept(queue.remove(), style, string), baseStyle); + } + + /** + * Collapses the tree of {@link Text} siblings into a one dimensional LIFO {@link Queue} + * @param text the text + * @return the text and its siblings in the order they appear when rendered. + */ + static Queue collectSiblings(Text text) { + Queue queue = new ArrayDeque<>(); + collectSiblings(text, queue); + return queue; + } + + private static void collectSiblings(Text text, Queue queue) { + queue.add(text); + for (Text sibling : text.getSiblings()) { + collectSiblings(sibling, queue); + } + } +} From 0ddeab2af38d08e0403a83b692edfb0ad71aa647 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Wed, 19 Jun 2024 15:53:40 +0100 Subject: [PATCH 26/66] Fix anti-clear in better chat. smh crosby. Closes #4660 --- .../meteorclient/systems/modules/misc/BetterChat.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java index be32f76f40..e621d06d35 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java @@ -225,7 +225,7 @@ public class BetterChat extends Module { ); private static final Pattern antiSpamRegex = Pattern.compile(" \\(([0-9]+)\\)$"); - private static final Pattern antiClearRegex = Pattern.compile("\\\\n(\\\\n|\\s)+\\\\n"); + private static final Pattern antiClearRegex = Pattern.compile("\\n(\\n|\\s)+\\n"); private static final Pattern timestampRegex = Pattern.compile("^(<[0-9]{2}:[0-9]{2}>\\s)"); private static final Pattern usernameRegex = Pattern.compile("^(?:<[0-9]{2}:[0-9]{2}>\\s)?<(.*?)>.*"); @@ -258,7 +258,7 @@ private void onMessageReceive(ReceiveMessageEvent event) { if (antiClear.get()) { String messageString = message.getString(); - if (antiClearRegex.matcher(messageString).matches()) { + if (antiClearRegex.matcher(messageString).find()) { MutableText newMessage = Text.empty(); TextVisitor.visit(message, (text, style, string) -> { Matcher antiClearMatcher = antiClearRegex.matcher(string); From 309bbc8f3d31f6defe30a11d4ddedad413085d61 Mon Sep 17 00:00:00 2001 From: Moxvallix Mox Date: Wed, 19 Jun 2024 02:25:22 +0930 Subject: [PATCH 27/66] Add a GUI positioning reset button to GUI tab screen --- .../meteorclient/gui/tabs/builtin/GuiTab.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/GuiTab.java b/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/GuiTab.java index 4dcb480255..b4d4135aa6 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/GuiTab.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/tabs/builtin/GuiTab.java @@ -11,6 +11,7 @@ import meteordevelopment.meteorclient.gui.tabs.TabScreen; import meteordevelopment.meteorclient.gui.tabs.WindowTabScreen; import meteordevelopment.meteorclient.gui.widgets.containers.WTable; +import meteordevelopment.meteorclient.gui.widgets.pressable.WButton; import meteordevelopment.meteorclient.gui.widgets.input.WDropdown; import meteordevelopment.meteorclient.utils.misc.NbtUtils; import net.minecraft.client.gui.screen.Screen; @@ -53,6 +54,9 @@ public void initWidgets() { tab.openScreen(GuiThemes.get()); }; + WButton reset = add(theme.button("Reset GUI Layout")).widget(); + reset.action = () -> theme.clearWindowConfigs(); + add(theme.settings(theme.settings)).expandX(); } From 73726168df3e4501dee6a93d1eaaa886c3421f17 Mon Sep 17 00:00:00 2001 From: RacoonDog <32882447+RacoonDog@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:40:47 -0400 Subject: [PATCH 28/66] Correct better chat anti-clear behaviour --- .../systems/modules/misc/BetterChat.java | 2 +- .../meteorclient/utils/misc/text/TextVisitor.java | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java index e621d06d35..297e6bfbb1 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java @@ -262,7 +262,7 @@ private void onMessageReceive(ReceiveMessageEvent event) { MutableText newMessage = Text.empty(); TextVisitor.visit(message, (text, style, string) -> { Matcher antiClearMatcher = antiClearRegex.matcher(string); - if (antiClearMatcher.matches()) { + if (antiClearMatcher.find()) { // assume literal text content newMessage.append(Text.literal(antiClearMatcher.replaceAll("\n\n")).setStyle(style)); } else { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/text/TextVisitor.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/text/TextVisitor.java index 9fc1f5ae0e..c1bf774d7f 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/text/TextVisitor.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/text/TextVisitor.java @@ -5,6 +5,8 @@ package meteordevelopment.meteorclient.utils.misc.text; +import net.minecraft.text.PlainTextContent; +import net.minecraft.text.StringVisitable; import net.minecraft.text.Style; import net.minecraft.text.Text; @@ -27,18 +29,21 @@ static Optional visit(Text text, TextVisitor visitor, Style baseStyle) } /** - * Collapses the tree of {@link Text} siblings into a one dimensional LIFO {@link Queue} + * Collapses the tree of {@link Text} siblings into a one dimensional FIFO {@link Queue}. To match the behaviours of + * the {@link Text#visit(StringVisitable.Visitor)} and {@link Text#visit(StringVisitable.StyledVisitor, Style)} + * methods, texts with empty contents (created from {@link Text#empty()}) are ignored but their siblings are still + * processed. * @param text the text * @return the text and its siblings in the order they appear when rendered. */ - static Queue collectSiblings(Text text) { - Queue queue = new ArrayDeque<>(); + static ArrayDeque collectSiblings(Text text) { + ArrayDeque queue = new ArrayDeque<>(); collectSiblings(text, queue); return queue; } private static void collectSiblings(Text text, Queue queue) { - queue.add(text); + if (!(text.getContent() instanceof PlainTextContent ptc) || !ptc.string().isEmpty()) queue.add(text); for (Text sibling : text.getSiblings()) { collectSiblings(sibling, queue); } From 0d5fbae7291613b550e5dda8562282a614c4390b Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Wed, 19 Jun 2024 23:50:09 +0100 Subject: [PATCH 29/66] Entity owner no longer works with horses and projectiles --- .../systems/modules/render/EntityOwner.java | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/EntityOwner.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/EntityOwner.java index 5b2f672650..a365727ad9 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/EntityOwner.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/EntityOwner.java @@ -6,10 +6,8 @@ package meteordevelopment.meteorclient.systems.modules.render; import meteordevelopment.meteorclient.events.render.Render2DEvent; -import meteordevelopment.meteorclient.mixin.ProjectileEntityAccessor; import meteordevelopment.meteorclient.renderer.Renderer2D; import meteordevelopment.meteorclient.renderer.text.TextRenderer; -import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.DoubleSetting; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.SettingGroup; @@ -22,10 +20,8 @@ import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.orbit.EventHandler; import net.minecraft.entity.Entity; -import net.minecraft.entity.passive.AbstractHorseEntity; import net.minecraft.entity.passive.TameableEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.projectile.ProjectileEntity; import org.joml.Vector3d; import java.util.HashMap; @@ -46,13 +42,6 @@ public class EntityOwner extends Module { .build() ); - private final Setting projectiles = sgGeneral.add(new BoolSetting.Builder() - .name("projectiles") - .description("Display owner names of projectiles.") - .defaultValue(false) - .build() - ); - private final Vector3d pos = new Vector3d(); private final Map uuidToName = new HashMap<>(); @@ -71,8 +60,6 @@ private void onRender2D(Render2DEvent event) { UUID ownerUuid; if (entity instanceof TameableEntity tameable) ownerUuid = tameable.getOwnerUuid(); - else if (entity instanceof AbstractHorseEntity horse) ownerUuid = horse.getOwnerUuid(); - else if (entity instanceof ProjectileEntity && projectiles.get()) ownerUuid = ((ProjectileEntityAccessor) entity).getOwnerUuid(); else continue; if (ownerUuid != null) { @@ -116,7 +103,7 @@ private String getOwnerName(UUID uuid) { String name = uuidToName.get(uuid); if (name != null) return name; - // Makes a HTTP request to Mojang API + // Makes an HTTP request to Mojang API MeteorExecutor.execute(() -> { if (isActive()) { ProfileResponse res = Http.get("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.toString().replace("-", "")).sendJson(ProfileResponse.class); From cedabd41d49790bb6e8f8e60ab737e25ead824c6 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Wed, 19 Jun 2024 23:57:35 +0100 Subject: [PATCH 30/66] Fix notebot reach --- .../meteorclient/systems/modules/misc/Notebot.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java index 0bc2c6009c..44363f7421 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java @@ -36,7 +36,6 @@ import net.minecraft.block.Blocks; import net.minecraft.block.NoteBlock; import net.minecraft.block.enums.Instrument; -import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket; import net.minecraft.sound.SoundEvents; @@ -780,9 +779,7 @@ private void scanForNoteblocks() { if (blockState.getBlock() != Blocks.NOTE_BLOCK) continue; // Copied from ServerPlayNetworkHandler#onPlayerInteractBlock - Vec3d vec3d2 = Vec3d.ofCenter(pos); - double sqDist = mc.player.getEyePos().squaredDistanceTo(vec3d2); - if (sqDist > mc.player.getAttributeValue(EntityAttributes.PLAYER_BLOCK_INTERACTION_RANGE)) continue; + if (!mc.player.canInteractWithBlockAt(pos, 1)) continue; if (!isValidScanSpot(pos)) continue; @@ -790,7 +787,6 @@ private void scanForNoteblocks() { scannedNoteblocks.put(note, pos); } } - } } From 1392c8becdc0c9b9c54a544366c976ce77d45c25 Mon Sep 17 00:00:00 2001 From: RacoonDog <32882447+RacoonDog@users.noreply.github.com> Date: Mon, 6 May 2024 23:35:21 -0400 Subject: [PATCH 31/66] port .nbt to 1.20.5+ --- .../arguments/ComponentMapArgumentType.java | 53 +++++ .../commands/commands/NbtCommand.java | 198 ++++++++++-------- .../utils/misc/ComponentMapReader.java | 189 +++++++++++++++++ 3 files changed, 354 insertions(+), 86 deletions(-) create mode 100644 src/main/java/meteordevelopment/meteorclient/commands/arguments/ComponentMapArgumentType.java create mode 100644 src/main/java/meteordevelopment/meteorclient/utils/misc/ComponentMapReader.java diff --git a/src/main/java/meteordevelopment/meteorclient/commands/arguments/ComponentMapArgumentType.java b/src/main/java/meteordevelopment/meteorclient/commands/arguments/ComponentMapArgumentType.java new file mode 100644 index 0000000000..4ec8c2648a --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/commands/arguments/ComponentMapArgumentType.java @@ -0,0 +1,53 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.commands.arguments; + +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.arguments.ArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import meteordevelopment.meteorclient.utils.misc.ComponentMapReader; +import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.command.CommandSource; +import net.minecraft.component.ComponentMap; + +import java.util.Collection; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +public class ComponentMapArgumentType implements ArgumentType { + private static final Collection EXAMPLES = List.of("{foo=bar}"); + private final ComponentMapReader reader; + + public ComponentMapArgumentType(CommandRegistryAccess commandRegistryAccess) { + this.reader = new ComponentMapReader(commandRegistryAccess); + } + + public static ComponentMapArgumentType componentMap(CommandRegistryAccess commandRegistryAccess) { + return new ComponentMapArgumentType(commandRegistryAccess); + } + + public static ComponentMap getComponentMap(CommandContext context, String name) { + return context.getArgument(name, ComponentMap.class); + } + + @Override + public ComponentMap parse(StringReader reader) throws CommandSyntaxException { + return this.reader.consume(reader); + } + + @Override + public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { + return this.reader.getSuggestions(builder); + } + + @Override + public Collection getExamples() { + return EXAMPLES; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java index 9bbb3b39fd..3acda1c180 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java @@ -5,150 +5,176 @@ package meteordevelopment.meteorclient.commands.commands; -import com.mojang.brigadier.StringReader; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import com.mojang.serialization.DataResult; import meteordevelopment.meteorclient.commands.Command; -import meteordevelopment.meteorclient.commands.arguments.CompoundNbtTagArgumentType; -import meteordevelopment.meteorclient.systems.config.Config; +import meteordevelopment.meteorclient.commands.arguments.ComponentMapArgumentType; import meteordevelopment.meteorclient.utils.misc.text.MeteorClickEvent; import net.minecraft.command.CommandSource; +import net.minecraft.command.DataCommandObject; +import net.minecraft.command.EntityDataObject; import net.minecraft.command.argument.NbtPathArgumentType; -import net.minecraft.component.ComponentMap; +import net.minecraft.command.argument.RegistryKeyArgumentType; +import net.minecraft.component.*; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; +import net.minecraft.nbt.NbtHelper; import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket; -import net.minecraft.text.ClickEvent; -import net.minecraft.text.HoverEvent; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; +import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.text.*; import net.minecraft.util.Formatting; +import net.minecraft.util.Unit; + +import java.util.List; +import java.util.Set; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; import static meteordevelopment.meteorclient.MeteorClient.mc; public class NbtCommand extends Command { + private static final DynamicCommandExceptionType MALFORMED_ITEM_EXCEPTION = new DynamicCommandExceptionType( + error -> Text.stringifiedTranslatable("arguments.item.malformed", error) + ); + private final Text copyButton = Text.literal("NBT").setStyle(Style.EMPTY + .withFormatting(Formatting.UNDERLINE) + .withClickEvent(new MeteorClickEvent( + ClickEvent.Action.RUN_COMMAND, + this.toString("copy") + )) + .withHoverEvent(new HoverEvent( + HoverEvent.Action.SHOW_TEXT, + Text.literal("Copy the NBT data to your clipboard.") + ))); + public NbtCommand() { super("nbt", "Modifies NBT data for an item, example: .nbt add {display:{Name:'{\"text\":\"$cRed Name\"}'}}"); } @Override public void build(LiteralArgumentBuilder builder) { - builder.executes(context -> { - error("This command is not yet updated for 1.20.5 and above!"); - return SINGLE_SUCCESS; - }); - - // TODO: Update using Components over NBT - /*builder.then(literal("add").then(argument("nbt", CompoundNbtTagArgumentType.create()).executes(s -> { + builder.then(literal("add").then(argument("component", ComponentMapArgumentType.componentMap(REGISTRY_ACCESS)).executes(ctx -> { ItemStack stack = mc.player.getInventory().getMainHandStack(); if (validBasic(stack)) { - NbtCompound tag = CompoundNbtTagArgumentType.get(s); + ComponentMap itemComponents = stack.getComponents(); + ComponentMap newComponents = ComponentMapArgumentType.getComponentMap(ctx, "component"); - if (tag != null) { - ItemStack newStack = ItemStack.fromNbtOrEmpty(mc.world.getRegistryManager(), tag); - newStack.applyComponentsFrom(stack.getComponents()); + ComponentMap testComponents = ComponentMap.of(itemComponents, newComponents); + DataResult dataResult = ItemStack.validateComponents(testComponents); + dataResult.getOrThrow(MALFORMED_ITEM_EXCEPTION::create); - setStack(newStack); - } else { - error("Some of the NBT data could not be found, try using: " + Config.get().prefix.get() + "nbt set {nbt}"); - } + stack.applyComponentsFrom(testComponents); + + setStack(stack); } return SINGLE_SUCCESS; }))); - builder.then(literal("set").then(argument("nbt", CompoundNbtTagArgumentType.create()).executes(context -> { + builder.then(literal("set").then(argument("component", ComponentMapArgumentType.componentMap(REGISTRY_ACCESS)).executes(ctx -> { ItemStack stack = mc.player.getInventory().getMainHandStack(); if (validBasic(stack)) { - stack = ItemStack.fromNbtOrEmpty(mc.world.getRegistryManager(), CompoundNbtTagArgumentType.get(context)); + ComponentMap components = ComponentMapArgumentType.getComponentMap(ctx, "component"); + ComponentMapImpl stackComponents = (ComponentMapImpl) stack.getComponents(); + + DataResult dataResult = ItemStack.validateComponents(components); + dataResult.getOrThrow(MALFORMED_ITEM_EXCEPTION::create); + + ComponentChanges.Builder changesBuilder = ComponentChanges.builder(); + Set> types = stackComponents.getTypes(); + + //set changes + for (Component entry : components) { + changesBuilder.add(entry); + types.remove(entry.type()); + } + + //remove the rest + for (DataComponentType type : types) { + changesBuilder.remove(type); + } + + stackComponents.applyChanges(changesBuilder.build()); + setStack(stack); } return SINGLE_SUCCESS; }))); - builder.then(literal("remove").then(argument("nbt_path", NbtPathArgumentType.nbtPath()).executes(context -> { + builder.then(literal("remove").then(argument("component", RegistryKeyArgumentType.registryKey(RegistryKeys.DATA_COMPONENT_TYPE)).executes(ctx -> { ItemStack stack = mc.player.getInventory().getMainHandStack(); if (validBasic(stack)) { - NbtPathArgumentType.NbtPath path = context.getArgument("nbt_path", NbtPathArgumentType.NbtPath.class); - path.remove(stack.encode(mc.world.getRegistryManager())); + @SuppressWarnings("unchecked") + RegistryKey> componentTypeKey = (RegistryKey>) ctx.getArgument("component", RegistryKey.class); + + DataComponentType componentType = Registries.DATA_COMPONENT_TYPE.get(componentTypeKey); + + ComponentMapImpl components = (ComponentMapImpl) stack.getComponents(); + components.applyChanges(ComponentChanges.builder().remove(componentType).build()); + + setStack(stack); } return SINGLE_SUCCESS; + }).suggests((ctx, suggestionsBuilder) -> { + ItemStack stack = mc.player.getInventory().getMainHandStack(); + if (stack != ItemStack.EMPTY) { + ComponentMap components = stack.getComponents(); + return CommandSource.suggestMatching(components.getTypes().stream().map(Registries.DATA_COMPONENT_TYPE::getEntry).map(RegistryEntry::getIdAsString), suggestionsBuilder); + } + return suggestionsBuilder.buildFuture(); }))); builder.then(literal("get").executes(context -> { - ItemStack stack = mc.player.getInventory().getMainHandStack(); + DataCommandObject dataCommandObject = new EntityDataObject(mc.player); + NbtPathArgumentType.NbtPath handPath = NbtPathArgumentType.NbtPath.parse("SelectedItem"); - if (stack == null) { - error("You must hold an item in your main hand."); - } else { - ComponentMap components = stack.getComponents(); + MutableText text = Text.empty().append(copyButton); - MutableText copyButton = Text.literal("NBT"); - copyButton.setStyle(copyButton.getStyle() - .withFormatting(Formatting.UNDERLINE) - .withClickEvent(new MeteorClickEvent( - ClickEvent.Action.RUN_COMMAND, - this.toString("copy") - )) - .withHoverEvent(new HoverEvent( - HoverEvent.Action.SHOW_TEXT, - Text.literal("Copy the NBT data to your clipboard.") - ))); - - MutableText text = Text.literal(""); - text.append(copyButton); - - if (components == null) text.append("{}"); - else text.append(" ").append(Text.of(components.toString())); - - info(text); + try { + List nbtElement = handPath.get(dataCommandObject.getNbt()); + if (!nbtElement.isEmpty()) { + text.append(" ").append(NbtHelper.toPrettyPrintedText(nbtElement.getFirst())); + } + } catch (CommandSyntaxException e) { + text.append("{}"); } + info(text); + return SINGLE_SUCCESS; })); builder.then(literal("copy").executes(context -> { - ItemStack stack = mc.player.getInventory().getMainHandStack(); - - if (stack == null) { - error("You must hold an item in your main hand."); - } else { - ComponentMap components = stack.getComponents(); - mc.keyboard.setClipboard(components.toString()); - MutableText nbt = Text.literal("NBT"); - nbt.setStyle(nbt.getStyle() - .withFormatting(Formatting.UNDERLINE) - .withHoverEvent(new HoverEvent( - HoverEvent.Action.SHOW_TEXT, - Text.of(components.toString()) - ))); - - MutableText text = Text.literal(""); - text.append(nbt); - text.append(Text.literal(" data copied!")); - - info(text); - } + DataCommandObject dataCommandObject = new EntityDataObject(mc.player); + NbtPathArgumentType.NbtPath handPath = NbtPathArgumentType.NbtPath.parse("SelectedItem"); - return SINGLE_SUCCESS; - })); + MutableText text = Text.empty().append(copyButton); + String nbt = "{}"; - builder.then(literal("paste").executes(context -> { - ItemStack stack = mc.player.getInventory().getMainHandStack(); - - if (validBasic(stack)) { - NbtCompound nbt = CompoundNbtTagArgumentType.create().parse(new StringReader(mc.keyboard.getClipboard())); + try { + List nbtElement = handPath.get(dataCommandObject.getNbt()); + if (!nbtElement.isEmpty()) { + text.append(" ").append(NbtHelper.toPrettyPrintedText(nbtElement.getFirst())); + nbt = nbtElement.getFirst().toString(); + } + } catch (CommandSyntaxException e) { + text.append("{}"); + } - stack = ItemStack.fromNbtOrEmpty(mc.world.getRegistryManager(), nbt); + mc.keyboard.setClipboard(nbt); - setStack(stack); - } + text.append(" data copied!"); + info(text); return SINGLE_SUCCESS; })); @@ -164,7 +190,7 @@ public void build(LiteralArgumentBuilder builder) { } return SINGLE_SUCCESS; - })));*/ + }))); } private void setStack(ItemStack stack) { @@ -177,7 +203,7 @@ private boolean validBasic(ItemStack stack) { return false; } - if (stack == null) { + if (stack == ItemStack.EMPTY) { error("You must hold an item in your main hand."); return false; } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/ComponentMapReader.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/ComponentMapReader.java new file mode 100644 index 0000000000..2ed916302c --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/ComponentMapReader.java @@ -0,0 +1,189 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.utils.misc; + +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.exceptions.Dynamic2CommandExceptionType; +import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import com.mojang.serialization.DataResult; +import com.mojang.serialization.DynamicOps; +import it.unimi.dsi.fastutil.objects.ReferenceArraySet; +import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.command.CommandSource; +import net.minecraft.component.ComponentMap; +import net.minecraft.component.DataComponentType; +import net.minecraft.nbt.NbtElement; +import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.StringNbtReader; +import net.minecraft.registry.Registries; +import net.minecraft.text.Text; +import net.minecraft.util.Identifier; + +import java.util.Locale; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; + +public class ComponentMapReader { + private static final DynamicCommandExceptionType UNKNOWN_COMPONENT_EXCEPTION = new DynamicCommandExceptionType( + id -> Text.stringifiedTranslatable("arguments.item.component.unknown", id) + ); + private static final SimpleCommandExceptionType COMPONENT_EXPECTED_EXCEPTION = new SimpleCommandExceptionType(Text.translatable("arguments.item.component.expected")); + private static final DynamicCommandExceptionType REPEATED_COMPONENT_EXCEPTION = new DynamicCommandExceptionType( + type -> Text.stringifiedTranslatable("arguments.item.component.repeated", type) + ); + private static final Dynamic2CommandExceptionType MALFORMED_COMPONENT_EXCEPTION = new Dynamic2CommandExceptionType( + (type, error) -> Text.stringifiedTranslatable("arguments.item.component.malformed", type, error) + ); + private final DynamicOps nbtOps; + + public ComponentMapReader(CommandRegistryAccess commandRegistryAccess) { + this.nbtOps = commandRegistryAccess.getOps(NbtOps.INSTANCE); + } + + public ComponentMap consume(StringReader reader) throws CommandSyntaxException { + int cursor = reader.getCursor(); + + try { + return new Reader(reader, nbtOps).read(); + } catch (CommandSyntaxException e) { + reader.setCursor(cursor); + throw e; + } + } + + public CompletableFuture getSuggestions(SuggestionsBuilder builder) { + StringReader stringReader = new StringReader(builder.getInput()); + stringReader.setCursor(builder.getStart()); + Reader reader = new Reader(stringReader, nbtOps); + + try { + reader.read(); + } catch (CommandSyntaxException ignored) { + } + + return reader.suggestor.apply(builder.createOffset(stringReader.getCursor())); + } + + private static class Reader { + private static final Function> SUGGEST_DEFAULT = SuggestionsBuilder::buildFuture; + private final StringReader reader; + private final DynamicOps nbtOps; + public Function> suggestor = this::suggestBracket; + + public Reader(StringReader reader, DynamicOps nbtOps) { + this.reader = reader; + this.nbtOps = nbtOps; + } + + public ComponentMap read() throws CommandSyntaxException { + ComponentMap.Builder builder = ComponentMap.builder(); + + reader.expect('['); + suggestor = this::suggestComponentType; + Set> set = new ReferenceArraySet<>(); + + while(reader.canRead() && reader.peek() != ']') { + reader.skipWhitespace(); + DataComponentType dataComponentType = readComponentType(reader); + if (!set.add(dataComponentType)) { + throw REPEATED_COMPONENT_EXCEPTION.create(dataComponentType); + } + + suggestor = this::suggestEqual; + reader.skipWhitespace(); + reader.expect('='); + suggestor = SUGGEST_DEFAULT; + reader.skipWhitespace(); + this.readComponentValue(reader, builder, dataComponentType); + reader.skipWhitespace(); + suggestor = this::suggestEndOfComponent; + if (!reader.canRead() || reader.peek() != ',') { + break; + } + + reader.skip(); + reader.skipWhitespace(); + suggestor = this::suggestComponentType; + if (!reader.canRead()) { + throw COMPONENT_EXPECTED_EXCEPTION.createWithContext(reader); + } + } + + reader.expect(']'); + suggestor = SUGGEST_DEFAULT; + + return builder.build(); + } + + public static DataComponentType readComponentType(StringReader reader) throws CommandSyntaxException { + if (!reader.canRead()) { + throw COMPONENT_EXPECTED_EXCEPTION.createWithContext(reader); + } else { + int i = reader.getCursor(); + Identifier identifier = Identifier.fromCommandInput(reader); + DataComponentType dataComponentType = Registries.DATA_COMPONENT_TYPE.get(identifier); + if (dataComponentType != null && !dataComponentType.shouldSkipSerialization()) { + return dataComponentType; + } else { + reader.setCursor(i); + throw UNKNOWN_COMPONENT_EXCEPTION.createWithContext(reader, identifier); + } + } + } + + private CompletableFuture suggestComponentType(SuggestionsBuilder builder) { + String string = builder.getRemaining().toLowerCase(Locale.ROOT); + CommandSource.forEachMatching(Registries.DATA_COMPONENT_TYPE.getEntrySet(), string, entry -> entry.getKey().getValue(), entry -> { + DataComponentType dataComponentType = entry.getValue(); + if (dataComponentType.getCodec() != null) { + Identifier identifier = entry.getKey().getValue(); + builder.suggest(identifier.toString() + "="); + } + }); + return builder.buildFuture(); + } + + private void readComponentValue(StringReader reader, ComponentMap.Builder builder, DataComponentType type) throws CommandSyntaxException { + int i = reader.getCursor(); + NbtElement nbtElement = new StringNbtReader(reader).parseElement(); + DataResult dataResult = type.getCodecOrThrow().parse(this.nbtOps, nbtElement); + builder.add(type, dataResult.getOrThrow(error -> { + reader.setCursor(i); + return MALFORMED_COMPONENT_EXCEPTION.createWithContext(reader, type.toString(), error); + })); + } + + private CompletableFuture suggestBracket(SuggestionsBuilder builder) { + if (builder.getRemaining().isEmpty()) { + builder.suggest(String.valueOf('[')); + } + + return builder.buildFuture(); + } + + private CompletableFuture suggestEndOfComponent(SuggestionsBuilder builder) { + if (builder.getRemaining().isEmpty()) { + builder.suggest(String.valueOf(',')); + builder.suggest(String.valueOf(']')); + } + + return builder.buildFuture(); + } + + private CompletableFuture suggestEqual(SuggestionsBuilder builder) { + if (builder.getRemaining().isEmpty()) { + builder.suggest(String.valueOf('=')); + } + + return builder.buildFuture(); + } + } +} From bb6428535aba894afc27e2024302dc1c3b94228b Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Thu, 20 Jun 2024 21:35:28 +0100 Subject: [PATCH 32/66] Fix suggestions for remove argument --- .../commands/commands/NbtCommand.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java index 3acda1c180..6fd7280ba6 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java @@ -26,12 +26,12 @@ import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; -import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.text.*; import net.minecraft.util.Formatting; import net.minecraft.util.Unit; import java.util.List; +import java.util.Locale; import java.util.Set; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; @@ -129,8 +129,21 @@ public void build(LiteralArgumentBuilder builder) { ItemStack stack = mc.player.getInventory().getMainHandStack(); if (stack != ItemStack.EMPTY) { ComponentMap components = stack.getComponents(); - return CommandSource.suggestMatching(components.getTypes().stream().map(Registries.DATA_COMPONENT_TYPE::getEntry).map(RegistryEntry::getIdAsString), suggestionsBuilder); + String remaining = suggestionsBuilder.getRemaining().toLowerCase(Locale.ROOT); + + CommandSource.forEachMatching(components.getTypes().stream().map(Registries.DATA_COMPONENT_TYPE::getEntry).toList(), remaining, entry -> { + if (entry.getKey().isPresent()) return entry.getKey().get().getValue(); + return null; + }, entry -> { + DataComponentType dataComponentType = entry.value(); + if (dataComponentType.getCodec() != null) { + if (entry.getKey().isPresent()) { + suggestionsBuilder.suggest(entry.getKey().get().getValue().toString()); + } + } + }); } + return suggestionsBuilder.buildFuture(); }))); From 5debbd3423882392a64f79fa1c49edf047e92a17 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Thu, 20 Jun 2024 21:52:06 +0100 Subject: [PATCH 33/66] Remove unused imports in commands --- .../meteorclient/commands/commands/BindsCommand.java | 2 -- .../meteorclient/commands/commands/CommandsCommand.java | 2 -- .../meteorclient/commands/commands/DamageCommand.java | 3 --- .../meteorclient/commands/commands/DisconnectCommand.java | 3 --- .../meteorclient/commands/commands/DismountCommand.java | 3 --- .../meteorclient/commands/commands/DropCommand.java | 3 --- .../meteorclient/commands/commands/EnchantCommand.java | 3 --- .../meteorclient/commands/commands/EnderChestCommand.java | 2 -- .../meteorclient/commands/commands/FakePlayerCommand.java | 2 -- .../meteorclient/commands/commands/FovCommand.java | 3 --- .../meteorclient/commands/commands/FriendsCommand.java | 2 -- .../meteorclient/commands/commands/GamemodeCommand.java | 3 --- .../meteorclient/commands/commands/GiveCommand.java | 3 --- .../meteorclient/commands/commands/HClipCommand.java | 3 --- .../meteorclient/commands/commands/InputCommand.java | 3 --- .../meteorclient/commands/commands/InventoryCommand.java | 2 -- .../meteorclient/commands/commands/LocateCommand.java | 3 --- .../meteorclient/commands/commands/MacroCommand.java | 2 -- .../meteorclient/commands/commands/ModulesCommand.java | 2 -- .../meteorclient/commands/commands/NameHistoryCommand.java | 3 --- .../meteorclient/commands/commands/NbtCommand.java | 3 --- .../meteorclient/commands/commands/NotebotCommand.java | 2 -- .../meteorclient/commands/commands/PeekCommand.java | 3 --- .../meteorclient/commands/commands/ProfilesCommand.java | 2 -- .../meteorclient/commands/commands/ReloadCommand.java | 2 -- .../meteorclient/commands/commands/ResetCommand.java | 2 -- .../meteorclient/commands/commands/RotationCommand.java | 3 --- .../meteorclient/commands/commands/SaveMapCommand.java | 3 --- .../meteorclient/commands/commands/SayCommand.java | 3 --- .../meteorclient/commands/commands/ServerCommand.java | 3 --- .../meteorclient/commands/commands/SettingCommand.java | 2 -- .../meteorclient/commands/commands/SpectateCommand.java | 3 --- .../meteorclient/commands/commands/SwarmCommand.java | 3 --- .../meteorclient/commands/commands/ToggleCommand.java | 2 -- .../meteorclient/commands/commands/VClipCommand.java | 3 --- .../meteorclient/commands/commands/WaypointCommand.java | 3 --- 36 files changed, 94 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/BindsCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/BindsCommand.java index fa4ee582b5..ee2fb642c5 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/BindsCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/BindsCommand.java @@ -19,8 +19,6 @@ import java.util.List; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class BindsCommand extends Command { public BindsCommand() { super("binds", "List of all bound modules."); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/CommandsCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/CommandsCommand.java index d58aed7a2f..63d6fb3ac2 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/CommandsCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/CommandsCommand.java @@ -18,8 +18,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class CommandsCommand extends Command { public CommandsCommand() { super("commands", "List of all commands.", "help"); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/DamageCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/DamageCommand.java index a334d17d67..1da52c8ca9 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/DamageCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/DamageCommand.java @@ -17,9 +17,6 @@ import net.minecraft.text.Text; import net.minecraft.util.math.Vec3d; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class DamageCommand extends Command { private final static SimpleCommandExceptionType INVULNERABLE = new SimpleCommandExceptionType(Text.literal("You are invulnerable.")); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/DisconnectCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/DisconnectCommand.java index f87c0ff178..f43585276a 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/DisconnectCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/DisconnectCommand.java @@ -13,9 +13,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class DisconnectCommand extends Command { public DisconnectCommand() { super("disconnect", "Disconnect from the server", "dc"); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/DismountCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/DismountCommand.java index d399f619ba..ece93ae0ec 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/DismountCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/DismountCommand.java @@ -10,9 +10,6 @@ import net.minecraft.command.CommandSource; import net.minecraft.network.packet.c2s.play.PlayerInputC2SPacket; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class DismountCommand extends Command { public DismountCommand() { super("dismount", "Dismounts you from entity you are riding."); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/DropCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/DropCommand.java index 976a47496f..b0eed195f6 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/DropCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/DropCommand.java @@ -17,9 +17,6 @@ import net.minecraft.item.Items; import net.minecraft.text.Text; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class DropCommand extends Command { private static final SimpleCommandExceptionType NOT_SPECTATOR = new SimpleCommandExceptionType(Text.literal("Can't drop items while in spectator.")); private static final SimpleCommandExceptionType NO_SUCH_ITEM = new SimpleCommandExceptionType(Text.literal("Could not find an item with that name!")); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/EnchantCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/EnchantCommand.java index f8b981b22a..cc2160d3ac 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/EnchantCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/EnchantCommand.java @@ -24,9 +24,6 @@ import java.util.function.ToIntFunction; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class EnchantCommand extends Command { private static final SimpleCommandExceptionType NOT_IN_CREATIVE = new SimpleCommandExceptionType(Text.literal("You must be in creative mode to use this.")); private static final SimpleCommandExceptionType NOT_HOLDING_ITEM = new SimpleCommandExceptionType(Text.literal("You need to hold some item to enchant.")); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/EnderChestCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/EnderChestCommand.java index f411ab5214..818bf8bb27 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/EnderChestCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/EnderChestCommand.java @@ -12,8 +12,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class EnderChestCommand extends Command { public EnderChestCommand() { super("ender-chest", "Allows you to preview memory of your ender chest.", "ec", "echest"); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/FakePlayerCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/FakePlayerCommand.java index 4a05f24d14..5374e1f503 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/FakePlayerCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/FakePlayerCommand.java @@ -16,8 +16,6 @@ import meteordevelopment.meteorclient.utils.player.ChatUtils; import net.minecraft.command.CommandSource; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class FakePlayerCommand extends Command { public FakePlayerCommand() { super("fake-player", "Manages fake players that you can use for testing."); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/FovCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/FovCommand.java index 1a1fce9bd9..225e015075 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/FovCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/FovCommand.java @@ -11,9 +11,6 @@ import meteordevelopment.meteorclient.mixininterface.ISimpleOption; import net.minecraft.command.CommandSource; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class FovCommand extends Command { public FovCommand() { super("fov", "Changes your fov."); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/FriendsCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/FriendsCommand.java index 66a1228f06..20c2996fbc 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/FriendsCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/FriendsCommand.java @@ -16,8 +16,6 @@ import net.minecraft.command.CommandSource; import net.minecraft.util.Formatting; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class FriendsCommand extends Command { public FriendsCommand() { super("friends", "Manages friends."); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/GamemodeCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/GamemodeCommand.java index f2ec5840ec..9069a4859b 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/GamemodeCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/GamemodeCommand.java @@ -10,9 +10,6 @@ import net.minecraft.command.CommandSource; import net.minecraft.world.GameMode; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class GamemodeCommand extends Command { public GamemodeCommand() { super("gamemode", "Changes your gamemode client-side.", "gm"); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/GiveCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/GiveCommand.java index 83ad311c21..ee25126aca 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/GiveCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/GiveCommand.java @@ -17,9 +17,6 @@ import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket; import net.minecraft.text.Text; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class GiveCommand extends Command { private final static SimpleCommandExceptionType NOT_IN_CREATIVE = new SimpleCommandExceptionType(Text.literal("You must be in creative mode to use this.")); private final static SimpleCommandExceptionType NO_SPACE = new SimpleCommandExceptionType(Text.literal("No space in hotbar.")); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/HClipCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/HClipCommand.java index 2898560650..2af1daa8f3 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/HClipCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/HClipCommand.java @@ -12,9 +12,6 @@ import net.minecraft.entity.Entity; import net.minecraft.util.math.Vec3d; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class HClipCommand extends Command { public HClipCommand() { super("hclip", "Lets you clip through blocks horizontally."); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/InputCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/InputCommand.java index bb6f281619..6d1041047b 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/InputCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/InputCommand.java @@ -18,9 +18,6 @@ import java.util.List; import java.util.Map; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class InputCommand extends Command { private static final List activeHandlers = new ArrayList<>(); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/InventoryCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/InventoryCommand.java index 63c488a41b..8ef230967c 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/InventoryCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/InventoryCommand.java @@ -12,8 +12,6 @@ import net.minecraft.client.gui.screen.ingame.InventoryScreen; import net.minecraft.command.CommandSource; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class InventoryCommand extends Command { public InventoryCommand() { super("inventory", "Allows you to see parts of another player's inventory.", "inv", "invsee"); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/LocateCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/LocateCommand.java index 82892f461f..a4c5325e3c 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/LocateCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/LocateCommand.java @@ -38,9 +38,6 @@ import java.util.List; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class LocateCommand extends Command { private Vec3d firstStart; private Vec3d firstEnd; diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/MacroCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/MacroCommand.java index b7feaa6d0c..564656c747 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/MacroCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/MacroCommand.java @@ -11,8 +11,6 @@ import meteordevelopment.meteorclient.systems.macros.Macro; import net.minecraft.command.CommandSource; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class MacroCommand extends Command { public MacroCommand() { super("macro", "Allows you to execute macros."); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/ModulesCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/ModulesCommand.java index da7b3ad220..3be1156fd1 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/ModulesCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/ModulesCommand.java @@ -16,8 +16,6 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class ModulesCommand extends Command { public ModulesCommand() { super("modules", "Displays a list of all modules.", "features"); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/NameHistoryCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/NameHistoryCommand.java index 144110182b..10ca1a99df 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/NameHistoryCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/NameHistoryCommand.java @@ -24,9 +24,6 @@ import java.util.Date; import java.util.UUID; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class NameHistoryCommand extends Command { public NameHistoryCommand() { super("name-history", "Provides a list of a players previous names from the laby.net api.", "history", "names"); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java index 6fd7280ba6..33e0f5356e 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java @@ -34,9 +34,6 @@ import java.util.Locale; import java.util.Set; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class NbtCommand extends Command { private static final DynamicCommandExceptionType MALFORMED_ITEM_EXCEPTION = new DynamicCommandExceptionType( error -> Text.stringifiedTranslatable("arguments.item.malformed", error) diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/NotebotCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/NotebotCommand.java index f506ec017b..a0d5c8740b 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/NotebotCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/NotebotCommand.java @@ -33,8 +33,6 @@ import java.util.List; import java.util.Map; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class NotebotCommand extends Command { private final static SimpleCommandExceptionType INVALID_SONG = new SimpleCommandExceptionType(Text.literal("Invalid song.")); private final static DynamicCommandExceptionType INVALID_PATH = new DynamicCommandExceptionType(object -> Text.literal("'%s' is not a valid path.".formatted(object))); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/PeekCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/PeekCommand.java index efffa35bd7..28d589165d 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/PeekCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/PeekCommand.java @@ -13,9 +13,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.text.Text; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class PeekCommand extends Command { private static final ItemStack[] ITEMS = new ItemStack[27]; private static final SimpleCommandExceptionType NOT_HOLDING_SHULKER_BOX = new SimpleCommandExceptionType(Text.literal("You must be holding a storage block with items in it.")); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/ProfilesCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/ProfilesCommand.java index baea74d22d..43c816f1c1 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/ProfilesCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/ProfilesCommand.java @@ -12,8 +12,6 @@ import meteordevelopment.meteorclient.systems.profiles.Profiles; import net.minecraft.command.CommandSource; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class ProfilesCommand extends Command { public ProfilesCommand() { diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/ReloadCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/ReloadCommand.java index 2f2a56d417..f299819854 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/ReloadCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/ReloadCommand.java @@ -15,8 +15,6 @@ import meteordevelopment.meteorclient.utils.network.MeteorExecutor; import net.minecraft.command.CommandSource; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class ReloadCommand extends Command { public ReloadCommand() { super("reload", "Reloads many systems."); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/ResetCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/ResetCommand.java index 4b080c4c2e..65ec6e21d6 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/ResetCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/ResetCommand.java @@ -17,8 +17,6 @@ import meteordevelopment.meteorclient.utils.player.ChatUtils; import net.minecraft.command.CommandSource; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class ResetCommand extends Command { public ResetCommand() { diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/RotationCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/RotationCommand.java index a0c513391d..0910a87379 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/RotationCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/RotationCommand.java @@ -13,9 +13,6 @@ import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class RotationCommand extends Command { public RotationCommand() { super("rotation", "Modifies your rotation."); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/SaveMapCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/SaveMapCommand.java index 75d71a301c..573cd90d23 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/SaveMapCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/SaveMapCommand.java @@ -32,9 +32,6 @@ import java.io.IOException; import java.nio.ByteBuffer; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class SaveMapCommand extends Command { private static final SimpleCommandExceptionType MAP_NOT_FOUND = new SimpleCommandExceptionType(Text.literal("You must be holding a filled map.")); private static final SimpleCommandExceptionType OOPS = new SimpleCommandExceptionType(Text.literal("Something went wrong.")); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/SayCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/SayCommand.java index 0c09971bbd..f9e868490a 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/SayCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/SayCommand.java @@ -21,9 +21,6 @@ import java.time.Instant; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class SayCommand extends Command { public SayCommand() { super("say", "Sends messages in chat."); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/ServerCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/ServerCommand.java index 0bb768307f..eeb22e5ffb 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/ServerCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/ServerCommand.java @@ -38,9 +38,6 @@ import java.util.Random; import java.util.Set; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class ServerCommand extends Command { private static final Set ANTICHEAT_LIST = Set.of("nocheatplus", "negativity", "warden", "horizon", "illegalstack", "coreprotect", "exploitsx", "vulcan", "abc", "spartan", "kauri", "anticheatreloaded", "witherac", "godseye", "matrix", "wraith", "antixrayheuristics", "grimac"); private static final Set VERSION_ALIASES = Set.of("version", "ver", "about", "bukkit:version", "bukkit:ver", "bukkit:about"); // aliases for bukkit:version diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/SettingCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/SettingCommand.java index 87b43478c8..ec95761519 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/SettingCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/SettingCommand.java @@ -19,8 +19,6 @@ import meteordevelopment.meteorclient.utils.Utils; import net.minecraft.command.CommandSource; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class SettingCommand extends Command { public SettingCommand() { super("settings", "Allows you to view and change module settings.", "s"); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/SpectateCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/SpectateCommand.java index 9b8d70ce16..a3e21115a0 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/SpectateCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/SpectateCommand.java @@ -14,9 +14,6 @@ import net.minecraft.command.CommandSource; import net.minecraft.text.Text; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class SpectateCommand extends Command { private final StaticListener shiftListener = new StaticListener(); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/SwarmCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/SwarmCommand.java index 748fb2d0a5..1a174501b5 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/SwarmCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/SwarmCommand.java @@ -38,9 +38,6 @@ import java.util.List; import java.util.Random; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class SwarmCommand extends Command { private final static SimpleCommandExceptionType SWARM_NOT_ACTIVE = new SimpleCommandExceptionType(Text.literal("The swarm module must be active to use this command.")); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/ToggleCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/ToggleCommand.java index 96ae914310..0f58000c0d 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/ToggleCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/ToggleCommand.java @@ -15,8 +15,6 @@ import java.util.ArrayList; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; - public class ToggleCommand extends Command { public ToggleCommand() { super("toggle", "Toggles a module.", "t"); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/VClipCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/VClipCommand.java index 19da05bab3..e4a04d056f 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/VClipCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/VClipCommand.java @@ -12,9 +12,6 @@ import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class VClipCommand extends Command { public VClipCommand() { super("vclip", "Lets you clip through blocks vertically."); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/WaypointCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/WaypointCommand.java index 598c4fd308..ac776f63c6 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/WaypointCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/WaypointCommand.java @@ -19,9 +19,6 @@ import net.minecraft.util.Formatting; import net.minecraft.util.math.BlockPos; -import static com.mojang.brigadier.Command.SINGLE_SUCCESS; -import static meteordevelopment.meteorclient.MeteorClient.mc; - public class WaypointCommand extends Command { public WaypointCommand() { super("waypoint", "Manages waypoints.", "wp"); From f68e3f3b219309325b0701ef9a147157d56d652a Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Thu, 20 Jun 2024 19:25:54 +0100 Subject: [PATCH 34/66] Add auto wasp module --- .../meteorclient/commands/Commands.java | 1 + .../commands/commands/WaspCommand.java | 40 ++++ .../meteorclient/systems/modules/Modules.java | 1 + .../systems/modules/movement/AutoWasp.java | 222 ++++++++++++++++++ 4 files changed, 264 insertions(+) create mode 100644 src/main/java/meteordevelopment/meteorclient/commands/commands/WaspCommand.java create mode 100644 src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWasp.java diff --git a/src/main/java/meteordevelopment/meteorclient/commands/Commands.java b/src/main/java/meteordevelopment/meteorclient/commands/Commands.java index 65325783f3..de498a625c 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/Commands.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/Commands.java @@ -60,6 +60,7 @@ public static void init() { add(new RotationCommand()); add(new WaypointCommand()); add(new InputCommand()); + add(new WaspCommand()); add(new LocateCommand()); COMMANDS.sort(Comparator.comparing(Command::getName)); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/WaspCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/WaspCommand.java new file mode 100644 index 0000000000..a4c16ae511 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/WaspCommand.java @@ -0,0 +1,40 @@ +package meteordevelopment.meteorclient.commands.commands; + +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; +import meteordevelopment.meteorclient.commands.Command; +import meteordevelopment.meteorclient.commands.arguments.PlayerArgumentType; +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.movement.AutoWasp; +import net.minecraft.command.CommandSource; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.text.Text; + +public class WaspCommand extends Command { + private static final SimpleCommandExceptionType CANT_WASP_SELF = new SimpleCommandExceptionType(Text.literal("You cannot target yourself!")); + + public WaspCommand() { + super("wasp", "Sets the auto wasp target."); + } + + @Override + public void build(LiteralArgumentBuilder builder) { + AutoWasp wasp = Modules.get().get(AutoWasp.class); + + builder.then(literal("reset").executes(context -> { + if (wasp.isActive()) wasp.toggle(); + return SINGLE_SUCCESS; + })); + + builder.then(argument("player", PlayerArgumentType.create()).executes(context -> { + PlayerEntity player = PlayerArgumentType.get(context); + + if (player == mc.player) throw CANT_WASP_SELF.create(); + + wasp.target = player; + if (!wasp.isActive()) wasp.toggle(); + info(player.getName().getString() + " set as target."); + return SINGLE_SUCCESS; + })); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java index e50ec6e586..602bd1ae6a 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java @@ -465,6 +465,7 @@ private void initMovement() { add(new AntiVoid()); add(new AutoJump()); add(new AutoWalk()); + add(new AutoWasp()); add(new Blink()); add(new BoatFly()); add(new ClickTP()); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWasp.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWasp.java new file mode 100644 index 0000000000..0e081d9f44 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWasp.java @@ -0,0 +1,222 @@ +package meteordevelopment.meteorclient.systems.modules.movement; + +import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent; +import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.mixininterface.IVec3d; +import meteordevelopment.meteorclient.settings.*; +import meteordevelopment.meteorclient.systems.friends.Friends; +import meteordevelopment.meteorclient.systems.modules.Categories; +import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.utils.entity.SortPriority; +import meteordevelopment.meteorclient.utils.entity.TargetUtils; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ElytraItem; +import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; +import net.minecraft.network.packet.s2c.common.DisconnectS2CPacket; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3d; +import org.joml.Vector3d; + +public class AutoWasp extends Module { + private final SettingGroup sgGeneral = settings.getDefaultGroup(); + + private final Setting horizontalSpeed = sgGeneral.add(new DoubleSetting.Builder() + .name("horizontal-speed") + .description("Horizontal elytra speed.") + .defaultValue(2.0) + .build() + ); + + private final Setting verticalSpeed = sgGeneral.add(new DoubleSetting.Builder() + .name("vertical-speed") + .description("Vertical elytra speed.") + .defaultValue(3.0) + .build() + ); + + private final Setting avoidLanding = sgGeneral.add(new BoolSetting.Builder() + .name("avoid-landing") + .description("Will try to avoid landing if your target is on the ground.") + .defaultValue(true) + .build() + ); + + private final Setting predictMovement = sgGeneral.add(new BoolSetting.Builder() + .name("predict-movement") + .description("Tries to predict the targets position according to their movement.") + .defaultValue(true) + .build() + ); + + private final Setting onlyFriends = sgGeneral.add(new BoolSetting.Builder() + .name("only-friends") + .description("Will only follow friends.") + .defaultValue(false) + .build() + ); + + private final Setting action = sgGeneral.add(new EnumSetting.Builder() + .name("action-on-target-loss") + .description("What to do if you lose the target.") + .defaultValue(Action.TOGGLE) + .build() + ); + + private final Setting offset = sgGeneral.add(new Vector3dSetting.Builder() + .name("offset") + .description("How many blocks offset to wasp at from the target.") + .defaultValue(0, 0, 0) + .build() + ); + + public PlayerEntity target; + private int jumpTimer = 0; + private boolean incrementJumpTimer = false; + + public AutoWasp() { + super(Categories.Movement, "auto-wasp", "Wasps for you. Unable to traverse around blocks, assumes a clear straight line to the target."); + } + + @Override + public void onActivate() { + if (target == null || target.isRemoved()) { + target = (PlayerEntity) TargetUtils.get(entity -> { + if (!(entity instanceof PlayerEntity) || entity == mc.player) return false; + if (((PlayerEntity) entity).isDead() || ((PlayerEntity) entity).getHealth() <= 0) return false; + return !onlyFriends.get() || Friends.get().get((PlayerEntity) entity) != null; + }, SortPriority.LowestDistance); + + if (target == null) { + error("No valid targets."); + toggle(); + return; + } else info(target.getName().getString() + " set as target."); + } + + jumpTimer = 0; + incrementJumpTimer = false; + } + + @Override + public void onDeactivate() { + target = null; + } + + @EventHandler + private void onTick(TickEvent.Pre event) { + if (target.isRemoved()) { + warning("Lost target!"); + + switch (action.get()) { + case CHOOSE_NEW_TARGET -> onActivate(); + case TOGGLE -> toggle(); + case DISCONNECT -> + mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(Text.literal("%s[%sAuto Wasp%s] Lost target.".formatted(Formatting.GRAY, Formatting.BLUE, Formatting.GRAY)))); + } + + if (!isActive()) return; + } + + if (!(mc.player.getEquippedStack(EquipmentSlot.CHEST).getItem() instanceof ElytraItem)) return; + + if (incrementJumpTimer) { + jumpTimer++; + } + + if (!mc.player.isFallFlying()) { + if (!incrementJumpTimer) incrementJumpTimer = true; + + if (mc.player.isOnGround() && incrementJumpTimer) { + mc.player.jump(); + return; + } + + if (jumpTimer >= 4) { + jumpTimer = 0; + mc.player.setJumping(false); + mc.player.setSprinting(true); + mc.getNetworkHandler().sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.START_FALL_FLYING)); + } + } else { + incrementJumpTimer = false; + jumpTimer = 0; + } + } + + @EventHandler + private void onMove(PlayerMoveEvent event) { + if (!(mc.player.getEquippedStack(EquipmentSlot.CHEST).getItem() instanceof ElytraItem)) return; + if (!mc.player.isFallFlying()) return; + + double xVel = 0, yVel = 0, zVel = 0; + + Vec3d targetPos = target.getPos().add(offset.get().x, offset.get().y, offset.get().z); + + if (predictMovement.get()) targetPos.add(PlayerEntity.adjustMovementForCollisions(target, target.getVelocity(), + target.getBoundingBox(), mc.world, mc.world.getEntityCollisions(target, target.getBoundingBox().stretch(target.getVelocity())))); + + if (avoidLanding.get()) { + double d = target.getBoundingBox().getLengthX() / 2; // x length = z length for players + + //get the block pos of the block underneath the corner of the targets bounding box + for (Direction dir : Direction.HORIZONTAL) { + BlockPos pos = BlockPos.ofFloored(targetPos.offset(dir, d).offset(dir.rotateYClockwise(), d)).down(); + if (mc.world.getBlockState(pos).getBlock().collidable && Math.abs(targetPos.getY() - (pos.getY() + 1)) <= 0.25) { + targetPos = new Vec3d(targetPos.x, pos.getY() + 1.25, targetPos.z); + break; + } + } + } + + double xDist = targetPos.getX() - mc.player.getX(); + double zDist = targetPos.getZ() - mc.player.getZ(); + + double absX = Math.abs(xDist); + double absZ = Math.abs(zDist); + + double diag = 0; + if (absX > 1.0E-5F && absZ > 1.0E-5F) diag = 1 / Math.sqrt(absX * absX + absZ * absZ); + + if (absX > 1.0E-5F) { + if (absX < horizontalSpeed.get()) xVel = xDist; + else xVel = horizontalSpeed.get() * Math.signum(xDist); + + if (diag != 0) xVel *= (absX * diag); + } + + if (absZ > 1.0E-5F) { + if (absZ < horizontalSpeed.get()) zVel = zDist; + else zVel = horizontalSpeed.get() * Math.signum(zDist); + + if (diag != 0) zVel *= (absZ * diag); + } + + double yDist = targetPos.getY() - mc.player.getY(); + if (Math.abs(yDist) > 1.0E-5F) { + if (Math.abs(yDist) < verticalSpeed.get()) yVel = yDist; + else yVel = verticalSpeed.get() * Math.signum(yDist); + } + + ((IVec3d) event.movement).set(xVel, yVel, zVel); + } + + public enum Action { + TOGGLE, + CHOOSE_NEW_TARGET, + DISCONNECT; + + @Override + public String toString() { + return switch (this) { + case TOGGLE -> "Toggle module"; + case CHOOSE_NEW_TARGET -> "Choose new target"; + case DISCONNECT -> "Disconnect"; + }; + } + } +} From 5b155609464d862888982deabb697133d83fd468 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Thu, 20 Jun 2024 19:33:04 +0100 Subject: [PATCH 35/66] Copyright notice --- .../meteorclient/commands/commands/WaspCommand.java | 5 +++++ .../meteorclient/systems/modules/movement/AutoWasp.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/WaspCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/WaspCommand.java index a4c16ae511..1b3fb81e6a 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/WaspCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/WaspCommand.java @@ -1,3 +1,8 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + package meteordevelopment.meteorclient.commands.commands; import com.mojang.brigadier.builder.LiteralArgumentBuilder; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWasp.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWasp.java index 0e081d9f44..851375e2ac 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWasp.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/AutoWasp.java @@ -1,3 +1,8 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + package meteordevelopment.meteorclient.systems.modules.movement; import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent; From 74b80cfc555620773f2090702baa749906e2393f Mon Sep 17 00:00:00 2001 From: 19MisterX98 <41451155+19MisterX98@users.noreply.github.com> Date: Fri, 21 Jun 2024 18:05:17 +0200 Subject: [PATCH 36/66] fixed keybind issue with linux/x11 #4581 (#4600) --- .../meteorclient/mixin/KeyboardMixin.java | 8 ++++++++ .../meteorclient/utils/misc/input/Input.java | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/KeyboardMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/KeyboardMixin.java index 47a64b8ce8..a174506f36 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/KeyboardMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/KeyboardMixin.java @@ -30,6 +30,14 @@ public abstract class KeyboardMixin { @Inject(method = "onKey", at = @At("HEAD"), cancellable = true) public void onKey(long window, int key, int scancode, int action, int modifiers, CallbackInfo info) { if (key != GLFW.GLFW_KEY_UNKNOWN) { + // on Linux/X11 the modifier is not active when the key is pressed and still active when the key is released + // https://github.com/glfw/glfw/issues/1630 + if (action == GLFW.GLFW_PRESS) { + modifiers |= Input.getModifier(key); + } else if (action == GLFW.GLFW_RELEASE) { + modifiers &= ~Input.getModifier(key); + } + if (client.currentScreen instanceof WidgetScreen && action == GLFW.GLFW_REPEAT) { ((WidgetScreen) client.currentScreen).keyRepeated(key, modifiers); } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/input/Input.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/input/Input.java index c556ae32b5..b723cc70ee 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/input/Input.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/input/Input.java @@ -60,4 +60,14 @@ public static void setCursorStyle(CursorStyle style) { lastCursorStyle = style; } } + + public static int getModifier(int key) { + return switch (key) { + case GLFW.GLFW_KEY_LEFT_SHIFT, GLFW.GLFW_KEY_RIGHT_SHIFT -> GLFW.GLFW_MOD_SHIFT; + case GLFW.GLFW_KEY_LEFT_CONTROL, GLFW.GLFW_KEY_RIGHT_CONTROL -> GLFW.GLFW_MOD_CONTROL; + case GLFW.GLFW_KEY_LEFT_ALT, GLFW.GLFW_KEY_RIGHT_ALT -> GLFW.GLFW_MOD_ALT; + case GLFW.GLFW_KEY_LEFT_SUPER, GLFW.GLFW_KEY_RIGHT_SUPER -> GLFW.GLFW_MOD_SUPER; + default -> 0; + }; + } } From 57f36cadbe2c680e3136b955fc245d8ed14b787c Mon Sep 17 00:00:00 2001 From: MineGame159 Date: Sun, 23 Jun 2024 22:09:48 +0200 Subject: [PATCH 37/66] Future version 0.5.8 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 8e046fac85..7a142ecaa8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ loader_version=0.15.10 fapi_version=0.97.8+1.20.6 # Mod Properties -mod_version=0.5.7 +mod_version=0.5.8 maven_group=meteordevelopment archives_base_name=meteor-client From 0ce909cc676a5b73961aafb8bfddf89985353dea Mon Sep 17 00:00:00 2001 From: Big Iron <52252627+Big-Iron-Cheems@users.noreply.github.com> Date: Sun, 23 Jun 2024 22:26:38 +0200 Subject: [PATCH 38/66] 1.21 update (#4640) --- build.gradle | 4 +- gradle.properties | 24 ++- gradle/wrapper/gradle-wrapper.properties | 2 +- .../meteorclient/MeteorClient.java | 5 + .../commands/commands/EnchantCommand.java | 13 +- .../commands/commands/NbtCommand.java | 10 +- .../commands/commands/NotebotCommand.java | 40 ++-- .../events/render/TooltipDataEvent.java | 2 +- .../gui/renderer/GuiRenderer.java | 14 +- .../settings/BlockListSettingScreen.java | 6 +- .../DynamicRegistryListSettingScreen.java | 182 ++++++++++++++++++ .../EnchantmentListSettingScreen.java | 15 +- .../settings/ItemListSettingScreen.java | 2 +- .../settings/ModuleListSettingScreen.java | 2 +- .../settings/PacketBoolSettingScreen.java | 2 +- .../ParticleTypeListSettingScreen.java | 2 +- ...en.java => RegistryListSettingScreen.java} | 4 +- .../settings/ScreenHandlerSettingScreen.java | 2 +- .../settings/SoundEventListSettingScreen.java | 2 +- .../StatusEffectListSettingScreen.java | 2 +- .../StorageBlockListSettingScreen.java | 60 +++--- .../meteorclient/mixin/ArmorTrimMixin.java | 2 +- .../mixin/BlockModelRendererMixin.java | 25 ++- .../mixin/BufferBuilderAccessor.java | 8 +- .../meteorclient/mixin/BundleItemMixin.java | 4 +- .../meteorclient/mixin/CameraMixin.java | 8 +- .../mixin/ChunkBorderDebugRendererMixin.java | 2 +- .../mixin/ClientPlayerEntityMixin.java | 2 +- .../ClientPlayerInteractionManagerMixin.java | 11 -- .../meteorclient/mixin/CrashReportMixin.java | 4 +- .../meteorclient/mixin/DrawContextMixin.java | 2 +- ...chantingTableBlockEntityRendererMixin.java | 4 +- .../mixin/EndCrystalEntityRendererMixin.java | 6 +- .../mixin/EntityRenderDispatcherMixin.java | 2 +- .../mixin/FluidRendererMixin.java | 6 +- .../mixin/FoliageColorsMixin.java | 20 +- .../meteorclient/mixin/GameRendererMixin.java | 5 +- .../mixin/HeldItemRendererMixin.java | 3 +- .../meteorclient/mixin/InGameHudMixin.java | 13 +- .../meteorclient/mixin/ItemMixin.java | 3 +- .../meteorclient/mixin/ItemStackMixin.java | 4 +- .../mixin/LightningEntityRendererMixin.java | 8 +- .../mixin/LivingEntityAccessor.java | 4 - .../mixin/LivingEntityRendererMixin.java | 2 +- .../mixin/PlayerArmorSlotMixin.java | 28 +-- .../mixin/PlayerEntityRendererMixin.java | 4 +- ...ava => RenderTickCounterDynamicMixin.java} | 11 +- .../mixin/ShulkerBoxBlockMixin.java | 3 +- .../meteorclient/mixin/VertexBufferMixin.java | 10 +- .../mixin/WorldRendererAccessor.java | 3 +- .../mixin/WorldRendererMixin.java | 18 +- .../mixin/baritone/ComeCommandMixin.java | 2 +- .../mixin/sodium/MeshVertexConsumerMixin.java | 1 - .../meteorclient/renderer/Shader.java | 3 +- .../renderer/text/VanillaTextRenderer.java | 4 +- .../settings/BlockDataSetting.java | 2 +- .../settings/BlockListSetting.java | 2 +- .../meteorclient/settings/BlockSetting.java | 2 +- .../settings/EnchantmentListSetting.java | 86 ++++++--- .../settings/EntityTypeListSetting.java | 2 +- .../settings/ItemListSetting.java | 2 +- .../meteorclient/settings/ItemSetting.java | 2 +- .../settings/ParticleTypeListSetting.java | 2 +- .../settings/ScreenHandlerListSetting.java | 2 +- .../meteorclient/settings/Setting.java | 6 +- .../settings/SoundEventListSetting.java | 2 +- .../StatusEffectAmplifierMapSetting.java | 2 +- .../settings/StatusEffectListSetting.java | 2 +- .../settings/StorageBlockListSetting.java | 25 ++- .../systems/hud/elements/CombatHud.java | 43 ++--- .../systems/hud/elements/InventoryHud.java | 6 +- .../systems/hud/elements/PlayerModelHud.java | 2 +- .../meteorclient/systems/modules/Modules.java | 3 +- .../systems/modules/combat/AutoArmor.java | 36 ++-- .../systems/modules/combat/AutoEXP.java | 4 +- .../systems/modules/combat/AutoWeapon.java | 5 +- .../systems/modules/combat/Surround.java | 2 +- .../systems/modules/misc/BetterChat.java | 6 +- .../systems/modules/misc/Notebot.java | 12 +- .../systems/modules/movement/Jesus.java | 7 +- .../modules/movement/speed/modes/Strafe.java | 2 +- .../systems/modules/player/AutoMend.java | 6 +- .../systems/modules/player/AutoTool.java | 16 +- .../systems/modules/player/GhostHand.java | 4 +- .../modules/render/BreakIndicators.java | 2 +- .../systems/modules/render/Chams.java | 4 +- .../systems/modules/render/Nametags.java | 23 ++- .../systems/modules/render/StorageESP.java | 2 +- .../systems/modules/render/Trajectories.java | 3 +- .../systems/modules/world/AutoSmelter.java | 4 +- .../systems/modules/world/EChestFarmer.java | 4 +- .../systems/modules/world/HighwayBuilder.java | 4 +- .../systems/modules/world/InfinityMiner.java | 4 +- .../meteorclient/utils/Utils.java | 68 +++++-- .../utils/entity/DamageUtils.java | 19 +- .../utils/misc/ComponentMapReader.java | 14 +- .../utils/misc/FakeClientPlayer.java | 2 +- .../utils/misc/MeteorIdentifier.java | 15 -- .../utils/misc/MeteorStarscript.java | 2 +- .../meteorclient/utils/misc/Names.java | 34 +++- .../meteorclient/utils/network/Capes.java | 15 +- .../utils/network/PacketUtils.java | 34 ++-- .../utils/network/PacketUtilsUtil.java | 17 +- .../utils/notebot/NotebotUtils.java | 46 ++--- .../utils/notebot/decoder/NBSSongDecoder.java | 38 ++-- .../utils/notebot/decoder/SongDecoders.java | 4 +- .../notebot/decoder/TextSongDecoder.java | 4 +- .../InstrumentDetectFunction.java | 4 +- .../meteorclient/utils/notebot/song/Note.java | 10 +- .../utils/render/IVertexConsumerProvider.java | 2 +- .../render/MeshVertexConsumerProvider.java | 43 ++--- .../utils/render/MeteorToast.java | 2 +- .../meteorclient/utils/render/PeekScreen.java | 2 +- .../utils/render/PlayerHeadTexture.java | 4 +- .../utils/render/RenderUtils.java | 2 +- .../utils/render/SimpleBlockRenderer.java | 10 +- .../utils/render/postprocess/ChamsShader.java | 3 +- .../utils/tooltip/BookTooltipComponent.java | 2 +- .../tooltip/ContainerTooltipComponent.java | 4 +- .../utils/tooltip/MapTooltipComponent.java | 2 +- .../utils/tooltip/MeteorTooltipData.java | 2 +- .../meteorclient/utils/world/BlockUtils.java | 6 +- src/main/resources/fabric.mod.json | 2 +- src/main/resources/meteor-client.mixins.json | 2 +- 124 files changed, 828 insertions(+), 559 deletions(-) create mode 100644 src/main/java/meteordevelopment/meteorclient/gui/screens/settings/DynamicRegistryListSettingScreen.java rename src/main/java/meteordevelopment/meteorclient/gui/screens/settings/{LeftRightListSettingScreen.java => RegistryListSettingScreen.java} (95%) rename src/main/java/meteordevelopment/meteorclient/mixin/{RenderTickCounterMixin.java => RenderTickCounterDynamicMixin.java} (65%) delete mode 100644 src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorIdentifier.java diff --git a/build.gradle b/build.gradle index b46ec23a52..d20cd70c33 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id "fabric-loom" version "1.6-SNAPSHOT" + id "fabric-loom" version "1.7-SNAPSHOT" id "maven-publish" id "com.github.johnrengelman.shadow" version "8.1.1" } @@ -74,7 +74,7 @@ dependencies { library "org.reflections:reflections:${project.reflections_version}" library("io.netty:netty-handler-proxy:${project.netty_version}") { transitive = false } library("io.netty:netty-codec-socks:${project.netty_version}") { transitive = false } - library "de.florianmichael:WaybackAuthLib:1.0.0" + library "de.florianmichael:WaybackAuthLib:${project.waybackauthlib_version}" // Launch sub project shadow project(":launch") diff --git a/gradle.properties b/gradle.properties index 7a142ecaa8..4ae76d382c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,10 @@ org.gradle.jvmargs=-Xmx2G # Fabric (https://fabricmc.net/develop) -minecraft_version=1.20.6 -yarn_mappings=1.20.6+build.1 -loader_version=0.15.10 -fapi_version=0.97.8+1.20.6 +minecraft_version=1.21 +yarn_mappings=1.21+build.2 +loader_version=0.15.11 +fapi_version=0.100.3+1.21 # Mod Properties mod_version=0.5.8 @@ -14,19 +14,20 @@ archives_base_name=meteor-client # Dependency Versions # Baritone (https://github.com/MeteorDevelopment/baritone) -baritone_version=1.20.4 +baritone_version=1.20.6 # Sodium (https://github.com/CaffeineMC/sodium-fabric) -sodium_version=mc1.20.6-0.5.8 +sodium_version=mc1.21-0.5.9 # Lithium (https://github.com/CaffeineMC/lithium-fabric) -lithium_version=mc1.20.6-0.12.3 +lithium_version=mc1.21-0.12.7 # Iris (https://github.com/IrisShaders/Iris) -iris_version=1.7.0+1.20.6 +iris_version=1.7.1+1.20.6 +# 1.7.1+1.21 seems to cause loom remapping issues atm # Indium (https://github.com/comp500/Indium) -indium_version=1.0.30+mc1.20.4 +indium_version=1.0.33+mc1.21 # Orbit (https://github.com/MeteorDevelopment/orbit) orbit_version=0.2.4 @@ -44,4 +45,7 @@ reflections_version=0.10.2 netty_version=4.1.90.Final # ViaFabricPlus (https://github.com/ViaVersion/ViaFabricPlus) -viafabricplus_version=3.2.1 +viafabricplus_version=3.4.1 + +# WaybackAuthLib (https://github.com/FlorianMichael/WaybackAuthLib) +waybackauthlib_version=1.0.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 48c0a02ca4..0d1842103b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/meteordevelopment/meteorclient/MeteorClient.java b/src/main/java/meteordevelopment/meteorclient/MeteorClient.java index 27507f9e0f..46f64dd540 100644 --- a/src/main/java/meteordevelopment/meteorclient/MeteorClient.java +++ b/src/main/java/meteordevelopment/meteorclient/MeteorClient.java @@ -36,6 +36,7 @@ import net.fabricmc.loader.api.metadata.ModMetadata; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ChatScreen; +import net.minecraft.util.Identifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -183,4 +184,8 @@ private void onOpenScreen(OpenScreenEvent event) { wasWidgetScreen = event.screen instanceof WidgetScreen; } + + public static Identifier identifier(String path) { + return Identifier.of(MeteorClient.MOD_ID, path); + } } diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/EnchantCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/EnchantCommand.java index cc2160d3ac..aaa3fc2962 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/EnchantCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/EnchantCommand.java @@ -17,7 +17,6 @@ import net.minecraft.command.argument.RegistryEntryReferenceArgumentType; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.ItemStack; -import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.text.Text; @@ -89,7 +88,7 @@ private void one(CommandContext context, ToIntFunction enchantment = context.getArgument("enchantment", RegistryEntry.Reference.class); - Utils.addEnchantment(itemStack, enchantment.value(), level.applyAsInt(enchantment.value())); + Utils.addEnchantment(itemStack, enchantment, level.applyAsInt(enchantment.value())); syncItem(); } @@ -97,11 +96,11 @@ private void one(CommandContext context, ToIntFunction level) throws CommandSyntaxException { ItemStack itemStack = tryGetItemStack(); - for (Enchantment enchantment : Registries.ENCHANTMENT) { - if (!onlyPossible || enchantment.isAcceptableItem(itemStack)) { - Utils.addEnchantment(itemStack, enchantment, level.applyAsInt(enchantment)); - } - } + REGISTRY_ACCESS.getOptionalWrapper(RegistryKeys.ENCHANTMENT).ifPresent(registry -> { + registry.streamEntries().forEach(enchantment -> { + Utils.addEnchantment(itemStack, enchantment, level.applyAsInt(enchantment.value())); + }); + }); syncItem(); } diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java index 33e0f5356e..c4f716aa07 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/NbtCommand.java @@ -85,7 +85,7 @@ public void build(LiteralArgumentBuilder builder) { dataResult.getOrThrow(MALFORMED_ITEM_EXCEPTION::create); ComponentChanges.Builder changesBuilder = ComponentChanges.builder(); - Set> types = stackComponents.getTypes(); + Set> types = stackComponents.getTypes(); //set changes for (Component entry : components) { @@ -94,7 +94,7 @@ public void build(LiteralArgumentBuilder builder) { } //remove the rest - for (DataComponentType type : types) { + for (ComponentType type : types) { changesBuilder.remove(type); } @@ -111,9 +111,9 @@ public void build(LiteralArgumentBuilder builder) { if (validBasic(stack)) { @SuppressWarnings("unchecked") - RegistryKey> componentTypeKey = (RegistryKey>) ctx.getArgument("component", RegistryKey.class); + RegistryKey> componentTypeKey = (RegistryKey>) ctx.getArgument("component", RegistryKey.class); - DataComponentType componentType = Registries.DATA_COMPONENT_TYPE.get(componentTypeKey); + ComponentType componentType = Registries.DATA_COMPONENT_TYPE.get(componentTypeKey); ComponentMapImpl components = (ComponentMapImpl) stack.getComponents(); components.applyChanges(ComponentChanges.builder().remove(componentType).build()); @@ -132,7 +132,7 @@ public void build(LiteralArgumentBuilder builder) { if (entry.getKey().isPresent()) return entry.getKey().get().getValue(); return null; }, entry -> { - DataComponentType dataComponentType = entry.value(); + ComponentType dataComponentType = entry.value(); if (dataComponentType.getCodec() != null) { if (entry.getKey().isPresent()) { suggestionsBuilder.suggest(entry.getKey().get().getValue().toString()); diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/NotebotCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/NotebotCommand.java index a0d5c8740b..f826c7db38 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/NotebotCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/NotebotCommand.java @@ -18,7 +18,7 @@ import meteordevelopment.meteorclient.systems.modules.misc.Notebot; import meteordevelopment.meteorclient.utils.notebot.song.Note; import meteordevelopment.orbit.EventHandler; -import net.minecraft.block.enums.Instrument; +import net.minecraft.block.enums.NoteBlockInstrument; import net.minecraft.command.CommandSource; import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket; import net.minecraft.sound.SoundEvent; @@ -168,7 +168,7 @@ private void saveRecording(Path path) { List notes = entry.getValue(); for (var note : notes) { - Instrument instrument = note.getInstrument(); + NoteBlockInstrument instrument = note.getInstrument(); int noteLevel = note.getNoteLevel(); file.write(String.format("%d:%d:%d\n", tick, noteLevel, instrument.ordinal())); @@ -202,7 +202,7 @@ private Note getNote(PlaySoundS2CPacket soundPacket) { return null; } - Instrument instrument = getInstrumentFromSound(soundPacket.getSound().value()); + NoteBlockInstrument instrument = getInstrumentFromSound(soundPacket.getSound().value()); if (instrument == null) { error("Can't find the instrument from sound! Sound: " + soundPacket.getSound().value()); return null; @@ -211,40 +211,40 @@ private Note getNote(PlaySoundS2CPacket soundPacket) { return new Note(instrument, noteLevel); } - private Instrument getInstrumentFromSound(SoundEvent sound) { + private NoteBlockInstrument getInstrumentFromSound(SoundEvent sound) { String path = sound.getId().getPath(); if (path.contains("harp")) - return Instrument.HARP; + return NoteBlockInstrument.HARP; else if (path.contains("basedrum")) - return Instrument.BASEDRUM; + return NoteBlockInstrument.BASEDRUM; else if (path.contains("snare")) - return Instrument.SNARE; + return NoteBlockInstrument.SNARE; else if (path.contains("hat")) - return Instrument.HAT; + return NoteBlockInstrument.HAT; else if (path.contains("bass")) - return Instrument.BASS; + return NoteBlockInstrument.BASS; else if (path.contains("flute")) - return Instrument.FLUTE; + return NoteBlockInstrument.FLUTE; else if (path.contains("bell")) - return Instrument.BELL; + return NoteBlockInstrument.BELL; else if (path.contains("guitar")) - return Instrument.GUITAR; + return NoteBlockInstrument.GUITAR; else if (path.contains("chime")) - return Instrument.CHIME; + return NoteBlockInstrument.CHIME; else if (path.contains("xylophone")) - return Instrument.XYLOPHONE; + return NoteBlockInstrument.XYLOPHONE; else if (path.contains("iron_xylophone")) - return Instrument.IRON_XYLOPHONE; + return NoteBlockInstrument.IRON_XYLOPHONE; else if (path.contains("cow_bell")) - return Instrument.COW_BELL; + return NoteBlockInstrument.COW_BELL; else if (path.contains("didgeridoo")) - return Instrument.DIDGERIDOO; + return NoteBlockInstrument.DIDGERIDOO; else if (path.contains("bit")) - return Instrument.BIT; + return NoteBlockInstrument.BIT; else if (path.contains("banjo")) - return Instrument.BANJO; + return NoteBlockInstrument.BANJO; else if (path.contains("pling")) - return Instrument.PLING; + return NoteBlockInstrument.PLING; return null; } } diff --git a/src/main/java/meteordevelopment/meteorclient/events/render/TooltipDataEvent.java b/src/main/java/meteordevelopment/meteorclient/events/render/TooltipDataEvent.java index c44b5667cc..f632f4fb88 100644 --- a/src/main/java/meteordevelopment/meteorclient/events/render/TooltipDataEvent.java +++ b/src/main/java/meteordevelopment/meteorclient/events/render/TooltipDataEvent.java @@ -5,7 +5,7 @@ package meteordevelopment.meteorclient.events.render; -import net.minecraft.client.item.TooltipData; +import net.minecraft.item.tooltip.TooltipData; import net.minecraft.item.ItemStack; diff --git a/src/main/java/meteordevelopment/meteorclient/gui/renderer/GuiRenderer.java b/src/main/java/meteordevelopment/meteorclient/gui/renderer/GuiRenderer.java index 08c9ff0527..915564e14f 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/renderer/GuiRenderer.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/renderer/GuiRenderer.java @@ -5,6 +5,7 @@ package meteordevelopment.meteorclient.gui.renderer; +import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.gui.GuiTheme; import meteordevelopment.meteorclient.gui.renderer.operations.TextOperation; import meteordevelopment.meteorclient.gui.renderer.packer.GuiTexture; @@ -14,7 +15,6 @@ import meteordevelopment.meteorclient.renderer.Renderer2D; import meteordevelopment.meteorclient.renderer.Texture; import meteordevelopment.meteorclient.utils.PostInit; -import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; import meteordevelopment.meteorclient.utils.misc.Pool; import meteordevelopment.meteorclient.utils.render.ByteTexture; import meteordevelopment.meteorclient.utils.render.RenderUtils; @@ -68,12 +68,12 @@ public static GuiTexture addTexture(Identifier id) { @PostInit public static void init() { - CIRCLE = addTexture(new MeteorIdentifier("textures/icons/gui/circle.png")); - TRIANGLE = addTexture(new MeteorIdentifier("textures/icons/gui/triangle.png")); - EDIT = addTexture(new MeteorIdentifier("textures/icons/gui/edit.png")); - RESET = addTexture(new MeteorIdentifier("textures/icons/gui/reset.png")); - FAVORITE_NO = addTexture(new MeteorIdentifier("textures/icons/gui/favorite_no.png")); - FAVORITE_YES = addTexture(new MeteorIdentifier("textures/icons/gui/favorite_yes.png")); + CIRCLE = addTexture(MeteorClient.identifier("textures/icons/gui/circle.png")); + TRIANGLE = addTexture(MeteorClient.identifier("textures/icons/gui/triangle.png")); + EDIT = addTexture(MeteorClient.identifier("textures/icons/gui/edit.png")); + RESET = addTexture(MeteorClient.identifier("textures/icons/gui/reset.png")); + FAVORITE_NO = addTexture(MeteorClient.identifier("textures/icons/gui/favorite_no.png")); + FAVORITE_YES = addTexture(MeteorClient.identifier("textures/icons/gui/favorite_yes.png")); TEXTURE = TEXTURE_PACKER.pack(); } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/BlockListSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/BlockListSettingScreen.java index 3409c87fd2..b0b5fa5173 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/BlockListSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/BlockListSettingScreen.java @@ -19,8 +19,8 @@ import java.util.List; import java.util.function.Predicate; -public class BlockListSettingScreen extends LeftRightListSettingScreen { - private static final Identifier ID = new Identifier("minecraft", ""); +public class BlockListSettingScreen extends RegistryListSettingScreen { + private static final Identifier ID = Identifier.of("minecraft", ""); public BlockListSettingScreen(GuiTheme theme, Setting> setting) { super(theme, "Select Blocks", setting, setting.get(), Registries.BLOCK); @@ -54,7 +54,7 @@ protected Block getAdditionalValue(Block value) { String path = Registries.BLOCK.getId(value).getPath(); if (!path.endsWith("_banner")) return null; - ((IdentifierAccessor) ID).setPath(path.substring(0, path.length() - 6) + "wall_banner"); + ((IdentifierAccessor) (Object) ID).setPath(path.substring(0, path.length() - 6) + "wall_banner"); return Registries.BLOCK.get(ID); } } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/DynamicRegistryListSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/DynamicRegistryListSettingScreen.java new file mode 100644 index 0000000000..65f40c4636 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/DynamicRegistryListSettingScreen.java @@ -0,0 +1,182 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.gui.screens.settings; + +import meteordevelopment.meteorclient.gui.GuiTheme; +import meteordevelopment.meteorclient.gui.WindowScreen; +import meteordevelopment.meteorclient.gui.utils.Cell; +import meteordevelopment.meteorclient.gui.widgets.WWidget; +import meteordevelopment.meteorclient.gui.widgets.containers.WHorizontalList; +import meteordevelopment.meteorclient.gui.widgets.containers.WTable; +import meteordevelopment.meteorclient.gui.widgets.input.WTextBox; +import meteordevelopment.meteorclient.gui.widgets.pressable.WPressable; +import meteordevelopment.meteorclient.settings.Setting; +import meteordevelopment.meteorclient.utils.Utils; +import net.minecraft.client.MinecraftClient; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.util.Identifier; +import net.minecraft.util.InvalidIdentifierException; +import net.minecraft.util.Pair; + +import java.util.*; +import java.util.function.Consumer; + +public abstract class DynamicRegistryListSettingScreen extends WindowScreen { + protected final Setting setting; + protected final Collection> collection; + private final RegistryKey> registryKey; + private final Optional> registry; + + private WTextBox filter; + private String filterText = ""; + + private WTable table; + + public DynamicRegistryListSettingScreen(GuiTheme theme, String title, Setting setting, Collection> collection, RegistryKey> registryKey) { + super(theme, title); + + this.registryKey = registryKey; + this.registry = Optional.ofNullable(MinecraftClient.getInstance().getNetworkHandler()) + .flatMap(networkHandler -> networkHandler.getRegistryManager().getOptional(registryKey)); + this.setting = setting; + this.collection = collection; + } + + @Override + public void initWidgets() { + // Filter + filter = add(theme.textBox("")).minWidth(400).expandX().widget(); + filter.setFocused(true); + filter.action = () -> { + filterText = filter.get().trim(); + + table.clear(); + generateWidgets(); + }; + + table = add(theme.table()).expandX().widget(); + + generateWidgets(); + } + + private void generateWidgets() { + // Left (all) + WTable left = abc(pairs -> registry.ifPresent(registry -> { + registry.streamEntries() + .map(RegistryEntry.Reference::getKey) + .filter(Optional::isPresent) + .map(Optional::get).forEach(t -> { + if (skipValue(t) || collection.contains(t)) return; + + int words = Utils.searchInWords(getValueName(t), filterText); + int diff = Utils.searchLevenshteinDefault(getValueName(t), filterText, false); + if (words > 0 || diff <= getValueName(t).length() / 2) pairs.add(new Pair<>(t, -diff)); + }); + }), true, t -> { + addValue(t); + + RegistryKey v = getAdditionalValue(t); + if (v != null) addValue(v); + } + ); + + if (!left.cells.isEmpty()) { + left.add(theme.horizontalSeparator()).expandX(); + left.row(); + } + + WHorizontalList manualEntry = left.add(theme.horizontalList()).expandX().widget(); + WTextBox textBox = manualEntry.add(theme.textBox("minecraft:")).expandX().minWidth(120d).widget(); + manualEntry.add(theme.plus()).expandCellX().right().widget().action = () -> { + String entry = textBox.get().trim(); + try { + Identifier id = entry.contains(":") ? Identifier.of(entry) : Identifier.ofVanilla(entry); + addValue(RegistryKey.of(registryKey, id)); + } catch (InvalidIdentifierException e) {} + }; + + table.add(theme.verticalSeparator()).expandWidgetY(); + + // Right (selected) + abc(pairs -> { + for (RegistryKey value : collection) { + if (skipValue(value)) continue; + + int words = Utils.searchInWords(getValueName(value), filterText); + int diff = Utils.searchLevenshteinDefault(getValueName(value), filterText, false); + if (words > 0 || diff <= getValueName(value).length() / 2) pairs.add(new Pair<>(value, -diff)); + } + }, false, t -> { + removeValue(t); + + RegistryKey v = getAdditionalValue(t); + if (v != null) removeValue(v); + }); + } + + private void addValue(RegistryKey value) { + if (!collection.contains(value)) { + collection.add(value); + + setting.onChanged(); + table.clear(); + generateWidgets(); + } + } + + private void removeValue(RegistryKey value) { + if (collection.remove(value)) { + setting.onChanged(); + table.clear(); + generateWidgets(); + } + } + + private WTable abc(Consumer, Integer>>> addValues, boolean isLeft, Consumer> buttonAction) { + // Create + Cell cell = this.table.add(theme.table()).top(); + WTable table = cell.widget(); + + Consumer> forEach = t -> { + if (!includeValue(t)) return; + + table.add(getValueWidget(t)); + + WPressable button = table.add(isLeft ? theme.plus() : theme.minus()).expandCellX().right().widget(); + button.action = () -> buttonAction.accept(t); + + table.row(); + }; + + // Sort + List, Integer>> values = new ArrayList<>(); + addValues.accept(values); + if (!filterText.isEmpty()) values.sort(Comparator.comparingInt(value -> -value.getRight())); + for (Pair, Integer> pair : values) forEach.accept(pair.getLeft()); + + if (!table.cells.isEmpty()) cell.expandX(); + + return table; + } + + protected boolean includeValue(RegistryKey value) { + return true; + } + + protected abstract WWidget getValueWidget(RegistryKey value); + + protected abstract String getValueName(RegistryKey value); + + protected boolean skipValue(RegistryKey value) { + return false; + } + + protected RegistryKey getAdditionalValue(RegistryKey value) { + return null; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/EnchantmentListSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/EnchantmentListSettingScreen.java index 7763433c32..7ffdddd6bc 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/EnchantmentListSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/EnchantmentListSettingScreen.java @@ -10,22 +10,23 @@ import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.utils.misc.Names; import net.minecraft.enchantment.Enchantment; -import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; -import java.util.List; +import java.util.Set; -public class EnchantmentListSettingScreen extends LeftRightListSettingScreen { - public EnchantmentListSettingScreen(GuiTheme theme, Setting> setting) { - super(theme, "Select Enchantments", setting, setting.get(), Registries.ENCHANTMENT); +public class EnchantmentListSettingScreen extends DynamicRegistryListSettingScreen { + public EnchantmentListSettingScreen(GuiTheme theme, Setting>> setting) { + super(theme, "Select Enchantments", setting, setting.get(), RegistryKeys.ENCHANTMENT); } @Override - protected WWidget getValueWidget(Enchantment value) { + protected WWidget getValueWidget(RegistryKey value) { return theme.label(getValueName(value)); } @Override - protected String getValueName(Enchantment value) { + protected String getValueName(RegistryKey value) { return Names.get(value); } } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ItemListSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ItemListSettingScreen.java index a630022d65..abad11b822 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ItemListSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ItemListSettingScreen.java @@ -15,7 +15,7 @@ import java.util.function.Predicate; -public class ItemListSettingScreen extends LeftRightListSettingScreen { +public class ItemListSettingScreen extends RegistryListSettingScreen { public ItemListSettingScreen(GuiTheme theme, ItemListSetting setting) { super(theme, "Select Items", setting, setting.get(), Registries.ITEM); } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ModuleListSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ModuleListSettingScreen.java index c4cbb1790e..29b8cce271 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ModuleListSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ModuleListSettingScreen.java @@ -13,7 +13,7 @@ import java.util.List; -public class ModuleListSettingScreen extends LeftRightListSettingScreen { +public class ModuleListSettingScreen extends RegistryListSettingScreen { public ModuleListSettingScreen(GuiTheme theme, Setting> setting) { super(theme, "Select Modules", setting, setting.get(), Modules.REGISTRY); } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/PacketBoolSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/PacketBoolSettingScreen.java index c88d59137f..0956b50a6a 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/PacketBoolSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/PacketBoolSettingScreen.java @@ -15,7 +15,7 @@ import java.util.Set; import java.util.function.Predicate; -public class PacketBoolSettingScreen extends LeftRightListSettingScreen>> { +public class PacketBoolSettingScreen extends RegistryListSettingScreen>> { public PacketBoolSettingScreen(GuiTheme theme, Setting>>> setting) { super(theme, "Select Packets", setting, setting.get(), PacketUtils.REGISTRY); } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ParticleTypeListSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ParticleTypeListSettingScreen.java index 9ec1b4ef92..15ffd0c6a9 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ParticleTypeListSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ParticleTypeListSettingScreen.java @@ -15,7 +15,7 @@ import java.util.List; -public class ParticleTypeListSettingScreen extends LeftRightListSettingScreen> { +public class ParticleTypeListSettingScreen extends RegistryListSettingScreen> { public ParticleTypeListSettingScreen(GuiTheme theme, Setting>> setting) { super(theme, "Select Particles", setting, setting.get(), Registries.PARTICLE_TYPE); } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/LeftRightListSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/RegistryListSettingScreen.java similarity index 95% rename from src/main/java/meteordevelopment/meteorclient/gui/screens/settings/LeftRightListSettingScreen.java rename to src/main/java/meteordevelopment/meteorclient/gui/screens/settings/RegistryListSettingScreen.java index 407bb72a74..1655839ce4 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/LeftRightListSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/RegistryListSettingScreen.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.function.Consumer; -public abstract class LeftRightListSettingScreen extends WindowScreen { +public abstract class RegistryListSettingScreen extends WindowScreen { protected final Setting setting; protected final Collection collection; private final Registry registry; @@ -33,7 +33,7 @@ public abstract class LeftRightListSettingScreen extends WindowScreen { private WTable table; - public LeftRightListSettingScreen(GuiTheme theme, String title, Setting setting, Collection collection, Registry registry) { + public RegistryListSettingScreen(GuiTheme theme, String title, Setting setting, Collection collection, Registry registry) { super(theme, title); this.registry = registry; diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ScreenHandlerSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ScreenHandlerSettingScreen.java index 8e6443b8b4..597ec2306e 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ScreenHandlerSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/ScreenHandlerSettingScreen.java @@ -13,7 +13,7 @@ import java.util.List; -public class ScreenHandlerSettingScreen extends LeftRightListSettingScreen> { +public class ScreenHandlerSettingScreen extends RegistryListSettingScreen> { public ScreenHandlerSettingScreen(GuiTheme theme, Setting>> setting) { super(theme, "Select Screen Handlers", setting, setting.get(), Registries.SCREEN_HANDLER); } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/SoundEventListSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/SoundEventListSettingScreen.java index 19dd04cbd0..992aab1d8d 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/SoundEventListSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/SoundEventListSettingScreen.java @@ -14,7 +14,7 @@ import java.util.List; -public class SoundEventListSettingScreen extends LeftRightListSettingScreen { +public class SoundEventListSettingScreen extends RegistryListSettingScreen { public SoundEventListSettingScreen(GuiTheme theme, Setting> setting) { super(theme, "Select Sounds", setting, setting.get(), Registries.SOUND_EVENT); } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StatusEffectListSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StatusEffectListSettingScreen.java index b2172ed11c..83862b286e 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StatusEffectListSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StatusEffectListSettingScreen.java @@ -19,7 +19,7 @@ import java.util.List; import java.util.Optional; -public class StatusEffectListSettingScreen extends LeftRightListSettingScreen { +public class StatusEffectListSettingScreen extends RegistryListSettingScreen { public StatusEffectListSettingScreen(GuiTheme theme, Setting> setting) { super(theme, "Select Effects", setting, setting.get(), Registries.STATUS_EFFECT); } diff --git a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StorageBlockListSettingScreen.java b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StorageBlockListSettingScreen.java index 38975e8f4d..34a3bde091 100644 --- a/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StorageBlockListSettingScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/gui/screens/settings/StorageBlockListSettingScreen.java @@ -5,6 +5,7 @@ package meteordevelopment.meteorclient.gui.screens.settings; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import meteordevelopment.meteorclient.gui.GuiTheme; import meteordevelopment.meteorclient.gui.widgets.WWidget; import meteordevelopment.meteorclient.settings.Setting; @@ -14,47 +15,46 @@ import net.minecraft.item.Items; import java.util.List; +import java.util.Map; + +public class StorageBlockListSettingScreen extends RegistryListSettingScreen> { + private static final Map, BlockEntityTypeInfo> BLOCK_ENTITY_TYPE_INFO_MAP = new Object2ObjectOpenHashMap<>(); + private static final BlockEntityTypeInfo UNKNOWN = new BlockEntityTypeInfo(Items.BARRIER, "Unknown"); + + static { + // Map of storage blocks + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.BARREL, new BlockEntityTypeInfo(Items.BARREL, "Barrel")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.BLAST_FURNACE, new BlockEntityTypeInfo(Items.BLAST_FURNACE, "Blast Furnace")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.BREWING_STAND, new BlockEntityTypeInfo(Items.BREWING_STAND, "Brewing Stand")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.CAMPFIRE, new BlockEntityTypeInfo(Items.CAMPFIRE, "Campfire")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.CHEST, new BlockEntityTypeInfo(Items.CHEST, "Chest")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.CHISELED_BOOKSHELF, new BlockEntityTypeInfo(Items.CHISELED_BOOKSHELF, "Chiseled Bookshelf")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.CRAFTER, new BlockEntityTypeInfo(Items.CRAFTER, "Crafter")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.DISPENSER, new BlockEntityTypeInfo(Items.DISPENSER, "Dispenser")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.DECORATED_POT, new BlockEntityTypeInfo(Items.DECORATED_POT, "Decorated Pot")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.DROPPER, new BlockEntityTypeInfo(Items.DROPPER, "Dropper")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.ENDER_CHEST, new BlockEntityTypeInfo(Items.ENDER_CHEST, "Ender Chest")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.FURNACE, new BlockEntityTypeInfo(Items.FURNACE, "Furnace")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.HOPPER, new BlockEntityTypeInfo(Items.HOPPER, "Hopper")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.SHULKER_BOX, new BlockEntityTypeInfo(Items.SHULKER_BOX, "Shulker Box")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.SMOKER, new BlockEntityTypeInfo(Items.SMOKER, "Smoker")); + BLOCK_ENTITY_TYPE_INFO_MAP.put(BlockEntityType.TRAPPED_CHEST, new BlockEntityTypeInfo(Items.TRAPPED_CHEST, "Trapped Chest")); + } -public class StorageBlockListSettingScreen extends LeftRightListSettingScreen> { public StorageBlockListSettingScreen(GuiTheme theme, Setting>> setting) { super(theme, "Select Storage Blocks", setting, setting.get(), StorageBlockListSetting.REGISTRY); } @Override protected WWidget getValueWidget(BlockEntityType value) { - Item item = Items.BARRIER; - - if (value == BlockEntityType.FURNACE) item = Items.FURNACE; - else if (value == BlockEntityType.CHEST) item = Items.CHEST; - else if (value == BlockEntityType.TRAPPED_CHEST) item = Items.TRAPPED_CHEST; - else if (value == BlockEntityType.ENDER_CHEST) item = Items.ENDER_CHEST; - else if (value == BlockEntityType.DISPENSER) item = Items.DISPENSER; - else if (value == BlockEntityType.DROPPER) item = Items.DROPPER; - else if (value == BlockEntityType.HOPPER) item = Items.HOPPER; - else if (value == BlockEntityType.SHULKER_BOX) item = Items.SHULKER_BOX; - else if (value == BlockEntityType.BARREL) item = Items.BARREL; - else if (value == BlockEntityType.SMOKER) item = Items.SMOKER; - else if (value == BlockEntityType.BLAST_FURNACE) item = Items.BLAST_FURNACE; - + Item item = BLOCK_ENTITY_TYPE_INFO_MAP.getOrDefault(value, UNKNOWN).item(); return theme.itemWithLabel(item.getDefaultStack(), getValueName(value)); } @Override protected String getValueName(BlockEntityType value) { - String name = "Unknown"; - - if (value == BlockEntityType.FURNACE) name = "Furnace"; - else if (value == BlockEntityType.CHEST) name = "Chest"; - else if (value == BlockEntityType.TRAPPED_CHEST) name = "Trapped Chest"; - else if (value == BlockEntityType.ENDER_CHEST) name = "Ender Chest"; - else if (value == BlockEntityType.DISPENSER) name = "Dispenser"; - else if (value == BlockEntityType.DROPPER) name = "Dropper"; - else if (value == BlockEntityType.HOPPER) name = "Hopper"; - else if (value == BlockEntityType.SHULKER_BOX) name = "Shulker Box"; - else if (value == BlockEntityType.BARREL) name = "Barrel"; - else if (value == BlockEntityType.SMOKER) name = "Smoker"; - else if (value == BlockEntityType.BLAST_FURNACE) name = "Blast Furnace"; - - return name; + return BLOCK_ENTITY_TYPE_INFO_MAP.getOrDefault(value, UNKNOWN).name(); } + + private record BlockEntityTypeInfo(Item item, String name) {} } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ArmorTrimMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ArmorTrimMixin.java index 582a918398..ee32aa90ac 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ArmorTrimMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ArmorTrimMixin.java @@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.At; @Mixin(ArmorTrim.class) -public class ArmorTrimMixin { +public abstract class ArmorTrimMixin { @ModifyExpressionValue(method = "appendTooltip", at = @At(value = "FIELD", target = "Lnet/minecraft/item/trim/ArmorTrim;showInTooltip:Z")) private boolean modifyShowInTooltip(boolean original) { BetterTooltips bt = Modules.get().get(BetterTooltips.class); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BlockModelRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BlockModelRendererMixin.java index cb90791d7d..af1fb3d3e4 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/BlockModelRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BlockModelRendererMixin.java @@ -7,11 +7,11 @@ import meteordevelopment.meteorclient.systems.modules.render.Xray; import net.minecraft.block.BlockState; -import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.block.BlockModelRenderer; import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.BakedQuad; +import net.minecraft.client.util.BufferAllocator; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; @@ -22,6 +22,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.nio.ByteBuffer; + @Mixin(BlockModelRenderer.class) public abstract class BlockModelRendererMixin { @Unique private final ThreadLocal alphas = new ThreadLocal<>(); @@ -42,20 +44,15 @@ private void onRenderQuad(BlockRenderView world, BlockState state, BlockPos pos, @Unique private void rewriteBuffer(VertexConsumer vertexConsumer, int alpha) { - if (vertexConsumer instanceof BufferBuilder bufferBuilder) { - BufferBuilderAccessor bufferBuilderAccessor = ((BufferBuilderAccessor) bufferBuilder); - - int prevOffset = bufferBuilderAccessor.getElementOffset(); - - if (prevOffset > 0) { - int i = bufferBuilderAccessor.getVertexFormat().getVertexSizeByte(); - - for (int l = 1; l <= 4; l++) { - bufferBuilderAccessor.setElementOffset(prevOffset - i * l); - bufferBuilder.putByte(15, (byte) (alpha)); + if (vertexConsumer instanceof BufferBuilderAccessor bufferBuilder) { + int i = bufferBuilder.getVertexFormat().getVertexSizeByte(); + try (BufferAllocator.CloseableBuffer allocatedBuffer = bufferBuilder.meteor$getAllocator().getAllocated()) { + if (allocatedBuffer != null) { + ByteBuffer buffer = allocatedBuffer.getBuffer(); + for (int l = 1; l <= 4; l++) { + buffer.put(buffer.capacity() - i * l + 15, (byte) (alpha)); + } } - - bufferBuilderAccessor.setElementOffset(prevOffset); } } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BufferBuilderAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/BufferBuilderAccessor.java index f1b9172238..ccd4fed141 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/BufferBuilderAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BufferBuilderAccessor.java @@ -7,16 +7,14 @@ import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.VertexFormat; +import net.minecraft.client.util.BufferAllocator; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(BufferBuilder.class) public interface BufferBuilderAccessor { - @Accessor("elementOffset") - int getElementOffset(); - - @Accessor("elementOffset") - void setElementOffset(int elementOffset); + @Accessor("allocator") + BufferAllocator meteor$getAllocator(); @Accessor("format") VertexFormat getVertexFormat(); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BundleItemMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BundleItemMixin.java index 52978a3062..30237e0225 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/BundleItemMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BundleItemMixin.java @@ -14,13 +14,13 @@ @Mixin(BundleItem.class) public class BundleItemMixin { - @ModifyExpressionValue(method = "getTooltipData", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/DataComponentType;)Z", ordinal = 0)) + @ModifyExpressionValue(method = "getTooltipData", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/ComponentType;)Z", ordinal = 0)) private boolean modifyContains1(boolean original) { BetterTooltips bt = Modules.get().get(BetterTooltips.class); return !(bt.isActive() && bt.tooltip.get()) && original; } - @ModifyExpressionValue(method = "getTooltipData", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/DataComponentType;)Z", ordinal = 1)) + @ModifyExpressionValue(method = "getTooltipData", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/ComponentType;)Z", ordinal = 1)) private boolean modifyContains2(boolean original) { BetterTooltips bt = Modules.get().get(BetterTooltips.class); return !(bt.isActive() && bt.additional.get()) && original; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/CameraMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/CameraMixin.java index c883d82570..08d8f03bc1 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/CameraMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/CameraMixin.java @@ -12,8 +12,8 @@ import meteordevelopment.meteorclient.systems.modules.render.Freecam; import meteordevelopment.meteorclient.systems.modules.render.NoRender; import meteordevelopment.meteorclient.systems.modules.world.HighwayBuilder; +import net.minecraft.block.enums.CameraSubmersionType; import net.minecraft.client.render.Camera; -import net.minecraft.client.render.CameraSubmersionType; import net.minecraft.entity.Entity; import net.minecraft.util.math.MathHelper; import net.minecraft.world.BlockView; @@ -46,12 +46,12 @@ private void getSubmergedFluidState(CallbackInfoReturnable } @ModifyVariable(method = "clipToSpace", at = @At("HEAD"), ordinal = 0, argsOnly = true) - private double modifyClipToSpace(double d) { - return (Modules.get().get(Freecam.class).isActive() ? 0 : Modules.get().get(CameraTweaks.class).getDistance()); + private float modifyClipToSpace(float d) { + return (Modules.get().get(Freecam.class).isActive() ? 0 : (float) Modules.get().get(CameraTweaks.class).getDistance()); } @Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true) - private void onClipToSpace(double desiredCameraDistance, CallbackInfoReturnable info) { + private void onClipToSpace(float desiredCameraDistance, CallbackInfoReturnable info) { if (Modules.get().get(CameraTweaks.class).clip()) { info.setReturnValue(desiredCameraDistance); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ChunkBorderDebugRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ChunkBorderDebugRendererMixin.java index 3481e15180..404a697e90 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ChunkBorderDebugRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ChunkBorderDebugRendererMixin.java @@ -29,7 +29,7 @@ public abstract class ChunkBorderDebugRendererMixin { Freecam freecam = Modules.get().get(Freecam.class); if (!freecam.isActive()) return chunkPos; - float delta = client.getTickDelta(); + float delta = client.getRenderTickCounter().getTickDelta(true); return new ChunkPos( ChunkSectionPos.getSectionCoord(MathHelper.floor(freecam.getX(delta))), diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java index 72e6d169cb..a05a576944 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java @@ -44,7 +44,7 @@ private void onDropSelectedItem(boolean dropEntireStack, CallbackInfoReturnable< if (MeteorClient.EVENT_BUS.post(DropItemsEvent.get(getMainHandStack())).isCancelled()) info.setReturnValue(false); } - @Redirect(method = "updateNausea", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;")) + @Redirect(method = "tickNausea", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;")) private Screen updateNauseaGetCurrentScreenProxy(MinecraftClient client) { if (Modules.get().isActive(Portals.class)) return null; return client.currentScreen; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java index feb31e918e..95535507e2 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java @@ -13,7 +13,6 @@ import meteordevelopment.meteorclient.systems.modules.misc.InventoryTweaks; import meteordevelopment.meteorclient.systems.modules.player.BreakDelay; import meteordevelopment.meteorclient.systems.modules.player.SpeedMine; -import meteordevelopment.meteorclient.utils.player.Rotations; import meteordevelopment.meteorclient.utils.world.BlockUtils; import net.minecraft.block.BlockState; import net.minecraft.client.network.ClientPlayNetworkHandler; @@ -38,11 +37,9 @@ 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.ModifyArgs; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; import static meteordevelopment.meteorclient.MeteorClient.mc; @@ -183,14 +180,6 @@ private void onCancelBlockBreaking(CallbackInfo info) { if (BlockUtils.breaking) info.cancel(); } - @ModifyArgs(method = "interactItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket$Full;(DDDFFZ)V")) - private void onInteractItem(Args args) { - if (Rotations.rotating) { - args.set(3, Rotations.serverYaw); - args.set(4, Rotations.serverPitch); - } - } - @Override public void meteor$syncSelected() { syncSelectedSlot(); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/CrashReportMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/CrashReportMixin.java index 33f82ea3d9..ea78ac2c8a 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/CrashReportMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/CrashReportMixin.java @@ -22,8 +22,8 @@ @Mixin(CrashReport.class) public abstract class CrashReportMixin { - @Inject(method = "addStackTrace", at = @At("TAIL")) - private void onAddStackTrace(StringBuilder sb, CallbackInfo info) { + @Inject(method = "addDetails", at = @At("TAIL")) + private void onAddDetails(StringBuilder sb, CallbackInfo info) { sb.append("\n\n-- Meteor Client --\n\n"); sb.append("Version: ").append(MeteorClient.VERSION).append("\n"); if (!MeteorClient.DEV_BUILD.isEmpty()) { diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/DrawContextMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/DrawContextMixin.java index 904d377e5c..12fdaccb62 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/DrawContextMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/DrawContextMixin.java @@ -10,7 +10,7 @@ import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.tooltip.TooltipComponent; -import net.minecraft.client.item.TooltipData; +import net.minecraft.item.tooltip.TooltipData; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/EnchantingTableBlockEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/EnchantingTableBlockEntityRendererMixin.java index d17f55bb69..04165de046 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/EnchantingTableBlockEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/EnchantingTableBlockEntityRendererMixin.java @@ -17,8 +17,8 @@ @Mixin(EnchantingTableBlockEntityRenderer.class) public abstract class EnchantingTableBlockEntityRendererMixin { - @WrapWithCondition(method = "render(Lnet/minecraft/block/entity/EnchantingTableBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/BookModel;renderBook(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V")) - private boolean onRenderBookModelRenderProxy(BookModel model, MatrixStack matrixStack, VertexConsumer vertexConsumer, int i, int j, float f, float g, float h, float k) { + @WrapWithCondition(method = "render(Lnet/minecraft/block/entity/EnchantingTableBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/BookModel;renderBook(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;III)V")) + private boolean onRenderBookModelRenderProxy(BookModel instance, MatrixStack matrices, VertexConsumer vertices, int light, int overlay, int i) { return !Modules.get().get(NoRender.class).noEnchTableBook(); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/EndCrystalEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/EndCrystalEntityRendererMixin.java index 4ff0ecba05..953d569ef9 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/EndCrystalEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/EndCrystalEntityRendererMixin.java @@ -95,7 +95,7 @@ private void modifyCore(ModelPart modelPart, MatrixStack matrices, VertexConsume if (module.renderCore.get()) { Color color = module.crystalsCoreColor.get(); - core.render(matrices, vertices, light, overlay, color.r/255f, color.g/255f, color.b/255f, color.a/255f); + core.render(matrices, vertices, light, overlay, color.getPacked()); } } @@ -110,7 +110,7 @@ private void modifyFrame1(ModelPart modelPart, MatrixStack matrices, VertexConsu if (module.renderFrame1.get()) { Color color = module.crystalsFrame1Color.get(); - frame.render(matrices, vertices, light, overlay, color.r/255f, color.g/255f, color.b/255f, color.a/255f); + frame.render(matrices, vertices, light, overlay, color.getPacked()); } } @@ -124,7 +124,7 @@ private void modifyFrame2(ModelPart modelPart, MatrixStack matrices, VertexConsu if (module.renderFrame2.get()) { Color color = module.crystalsFrame2Color.get(); - frame.render(matrices, vertices, light, overlay, color.r/255f, color.g/255f, color.b/255f, color.a/255f); + frame.render(matrices, vertices, light, overlay, color.getPacked()); } } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/EntityRenderDispatcherMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/EntityRenderDispatcherMixin.java index 6b0e3c4085..2f4aa08ac3 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/EntityRenderDispatcherMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/EntityRenderDispatcherMixin.java @@ -45,7 +45,7 @@ private void render(E entity, double x, double y, double z, f } @Inject(method = "renderHitbox", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;drawBox(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/util/math/Box;FFFF)V", ordinal = 0), locals = LocalCapture.CAPTURE_FAILSOFT) - private static void onRenderHitbox(MatrixStack matrices, VertexConsumer vertices, Entity entity, float tickDelta, CallbackInfo info, Box box) { + private static void onRenderHitbox(MatrixStack matrices, VertexConsumer vertices, Entity entity, float tickDelta, float red, float green, float blue, CallbackInfo ci, Box box) { double v = Modules.get().get(Hitboxes.class).getEntityValue(entity); if (v != 0) ((IBox) box).expand(v); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/FluidRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/FluidRendererMixin.java index 53dab9cadd..561c44e981 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/FluidRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/FluidRendererMixin.java @@ -43,7 +43,7 @@ private void onRender(BlockRenderView world, BlockPos pos, VertexConsumer vertex } @Inject(method = "vertex", at = @At("HEAD"), cancellable = true) - private void onVertex(VertexConsumer vertexConsumer, double x, double y, double z, float red, float green, float blue, float u, float v, int light, CallbackInfo info) { + private void onVertex(VertexConsumer vertexConsumer, float x, float y, float z, float red, float green, float blue, float u, float v, int light, CallbackInfo info) { int alpha = alphas.get(); if (alpha == -2) { @@ -58,7 +58,7 @@ else if (alpha != -1) { } @Unique - private void vertex(VertexConsumer vertexConsumer, double x, double y, double z, int red, int green, int blue, int alpha, float u, float v, int light) { - vertexConsumer.vertex(x, y, z).color(red, green, blue, alpha).texture(u, v).light(light).normal(0.0f, 1.0f, 0.0f).next(); + private void vertex(VertexConsumer vertexConsumer, float x, float y, float z, int red, int green, int blue, int alpha, float u, float v, int light) { + vertexConsumer.vertex(x, y, z).color(red, green, blue, alpha).texture(u, v).light(light).normal(0.0f, 1.0f, 0.0f); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/FoliageColorsMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/FoliageColorsMixin.java index bc1e7e2282..8985c560b9 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/FoliageColorsMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/FoliageColorsMixin.java @@ -8,8 +8,9 @@ import com.llamalad7.mixinextras.injector.ModifyReturnValue; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.world.Ambience; -import net.minecraft.client.color.world.FoliageColors; +import net.minecraft.world.biome.FoliageColors; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @Mixin(FoliageColors.class) @@ -17,16 +18,21 @@ public abstract class FoliageColorsMixin { @ModifyReturnValue(method = "getBirchColor", at = @At("RETURN")) private static int onGetBirchColor(int original) { - Ambience ambience = Modules.get().get(Ambience.class); - if (ambience.isActive() && ambience.customFoliageColor.get()) { - return ambience.foliageColor.get().getPacked(); - } - - return original; + return getModifiedColor(original); } @ModifyReturnValue(method = "getSpruceColor", at = @At("RETURN")) private static int onGetSpruceColor(int original) { + return getModifiedColor(original); + } + + @ModifyReturnValue(method = "getMangroveColor", at = @At("RETURN")) + private static int onGetMangroveColor(int original) { + return getModifiedColor(original); + } + + @Unique + private static int getModifiedColor(int original) { Ambience ambience = Modules.get().get(Ambience.class); if (ambience.isActive() && ambience.customFoliageColor.get()) { return ambience.foliageColor.get().getPacked(); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java index 5eeb4c42ad..f84d80e9b5 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/GameRendererMixin.java @@ -6,6 +6,7 @@ package meteordevelopment.meteorclient.mixin; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.sugar.Local; import com.mojang.blaze3d.systems.RenderSystem; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.render.Render3DEvent; @@ -25,6 +26,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.Camera; import net.minecraft.client.render.GameRenderer; +import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; @@ -69,9 +71,8 @@ public abstract class GameRendererMixin { @Unique private final MatrixStack matrices = new MatrixStack(); - // FIXME: unsure @Inject(method = "renderWorld", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", args = {"ldc=hand"}), locals = LocalCapture.CAPTURE_FAILEXCEPTION) - private void onRenderWorld(float tickDelta, long limitTime, CallbackInfo ci, boolean bl, Camera camera, Entity entity, double d, Matrix4f matrix4f, MatrixStack matrixStack, float f, float g, Matrix4f matrix4f2) { + private void onRenderWorld(RenderTickCounter tickCounter, CallbackInfo ci, @Local(ordinal = 1) Matrix4f matrix4f2, @Local(ordinal = 1) float tickDelta, @Local MatrixStack matrixStack) { if (!Utils.canUpdate()) return; client.getProfiler().push(MeteorClient.MOD_ID + "_render"); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/HeldItemRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/HeldItemRendererMixin.java index 72748fa436..3708700b23 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/HeldItemRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/HeldItemRendererMixin.java @@ -15,6 +15,7 @@ import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.HeldItemRenderer; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Arm; import net.minecraft.util.Hand; @@ -86,7 +87,7 @@ private void onRenderArm(AbstractClientPlayerEntity player, float tickDelta, flo } @Inject(method = "applyEatOrDrinkTransformation", at = @At(value = "INVOKE", target = "Ljava/lang/Math;pow(DD)D", shift = At.Shift.BEFORE), cancellable = true) - private void cancelTransformations(MatrixStack matrices, float tickDelta, Arm arm, ItemStack stack, CallbackInfo ci) { + private void cancelTransformations(MatrixStack matrices, float tickDelta, Arm arm, ItemStack stack, PlayerEntity player, CallbackInfo ci) { if (Modules.get().get(HandView.class).disableFoodAnimation()) ci.cancel(); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/InGameHudMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/InGameHudMixin.java index 768ba8c8e2..cff9d8363d 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/InGameHudMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/InGameHudMixin.java @@ -17,6 +17,7 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.render.RenderTickCounter; import net.minecraft.entity.Entity; import net.minecraft.scoreboard.ScoreboardObjective; import org.spongepowered.asm.mixin.Final; @@ -35,12 +36,12 @@ public abstract class InGameHudMixin { @Shadow public abstract void clear(); @Inject(method = "render", at = @At("TAIL")) - private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) { + private void onRender(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { client.getProfiler().push(MeteorClient.MOD_ID + "_render_2d"); Utils.unscaledProjection(); - MeteorClient.EVENT_BUS.post(Render2DEvent.get(context, context.getScaledWindowWidth(), context.getScaledWindowWidth(), tickDelta)); + MeteorClient.EVENT_BUS.post(Render2DEvent.get(context, context.getScaledWindowWidth(), context.getScaledWindowWidth(), tickCounter.getTickDelta(true))); Utils.scaledProjection(); RenderSystem.applyModelViewMatrix(); @@ -78,8 +79,8 @@ private void onRenderScoreboardSidebar(DrawContext context, ScoreboardObjective if (Modules.get().get(NoRender.class).noScoreboard()) ci.cancel(); } - @Inject(method = "renderScoreboardSidebar(Lnet/minecraft/client/gui/DrawContext;F)V", at = @At("HEAD"), cancellable = true) - private void onRenderScoreboardSidebar(DrawContext context, float tickDelta, CallbackInfo ci) { + @Inject(method = "renderScoreboardSidebar(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/client/render/RenderTickCounter;)V", at = @At("HEAD"), cancellable = true) + private void onRenderScoreboardSidebar(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { if (Modules.get().get(NoRender.class).noScoreboard()) ci.cancel(); } @@ -94,12 +95,12 @@ private boolean alwaysRenderCrosshairInFreecam(boolean firstPerson) { } @Inject(method = "renderCrosshair", at = @At("HEAD"), cancellable = true) - private void onRenderCrosshair(DrawContext context, float tickDelta, CallbackInfo ci) { + private void onRenderCrosshair(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { if (Modules.get().get(NoRender.class).noCrosshair()) ci.cancel(); } @Inject(method = "renderTitleAndSubtitle", at = @At("HEAD"), cancellable = true) - private void onRenderTitle(DrawContext context, float tickDelta, CallbackInfo ci) { + private void onRenderTitle(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { if (Modules.get().get(NoRender.class).noTitle()) ci.cancel(); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ItemMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ItemMixin.java index 9a0971069a..cfd2422820 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ItemMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ItemMixin.java @@ -7,9 +7,10 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.render.TooltipDataEvent; -import net.minecraft.client.item.TooltipData; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.tooltip.TooltipData; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ItemStackMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ItemStackMixin.java index 63fd0863ed..cc139b4f24 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ItemStackMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ItemStackMixin.java @@ -52,13 +52,13 @@ private boolean modifyCanPlaceText(boolean original) { return (bt.isActive() && bt.canPlaceOn.get()) || original; } - @ModifyExpressionValue(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/DataComponentType;)Z", ordinal = 0)) + @ModifyExpressionValue(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/ComponentType;)Z", ordinal = 0)) private boolean modifyContainsTooltip(boolean original) { BetterTooltips bt = Modules.get().get(BetterTooltips.class); return !(bt.isActive() && bt.tooltip.get()) && original; } - @ModifyExpressionValue(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/DataComponentType;)Z", ordinal = 3)) + @ModifyExpressionValue(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/ComponentType;)Z", ordinal = 3)) private boolean modifyContainsAdditional(boolean original) { BetterTooltips bt = Modules.get().get(BetterTooltips.class); return !(bt.isActive() && bt.additional.get()) && original; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/LightningEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/LightningEntityRendererMixin.java index a8bbb09df0..6db8399a10 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/LightningEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/LightningEntityRendererMixin.java @@ -28,10 +28,10 @@ private static void onSetLightningVertex(Matrix4f matrix4f, VertexConsumer verte if (ambience.isActive() && ambience.changeLightningColor.get()) { Color color = ambience.lightningColor.get(); - vertexConsumer.vertex(matrix4f, f + (bl ? o : -o), (float)(i * 16), g + (bl2 ? o : -o)).color(color.r / 255f, color.g / 255f, color.b / 255f, 0.3F).next(); - vertexConsumer.vertex(matrix4f, h + (bl ? n : -n), (float)((i + 1) * 16), j + (bl2 ? n : -n)).color(color.r / 255f, color.g / 255f, color.b / 255f, 0.3F).next(); - vertexConsumer.vertex(matrix4f, h + (bl3 ? n : -n), (float)((i + 1) * 16), j + (bl4 ? n : -n)).color(color.r / 255f, color.g / 255f, color.b / 255f, 0.3F).next(); - vertexConsumer.vertex(matrix4f, f + (bl3 ? o : -o), (float)(i * 16), g + (bl4 ? o : -o)).color(color.r / 255f, color.g / 255f, color.b / 255f, 0.3F).next(); + vertexConsumer.vertex(matrix4f, f + (bl ? o : -o), (float)(i * 16), g + (bl2 ? o : -o)).color(color.r / 255f, color.g / 255f, color.b / 255f, 0.3F); + vertexConsumer.vertex(matrix4f, h + (bl ? n : -n), (float)((i + 1) * 16), j + (bl2 ? n : -n)).color(color.r / 255f, color.g / 255f, color.b / 255f, 0.3F); + vertexConsumer.vertex(matrix4f, h + (bl3 ? n : -n), (float)((i + 1) * 16), j + (bl4 ? n : -n)).color(color.r / 255f, color.g / 255f, color.b / 255f, 0.3F); + vertexConsumer.vertex(matrix4f, f + (bl3 ? o : -o), (float)(i * 16), g + (bl4 ? o : -o)).color(color.r / 255f, color.g / 255f, color.b / 255f, 0.3F); ci.cancel(); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityAccessor.java index 2b8e2046d6..c7d4630c92 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityAccessor.java @@ -6,16 +6,12 @@ package meteordevelopment.meteorclient.mixin; import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.data.TrackedData; import net.minecraft.fluid.Fluid; -import net.minecraft.particle.ParticleEffect; import net.minecraft.registry.tag.TagKey; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; -import java.util.List; - @Mixin(LivingEntity.class) public interface LivingEntityAccessor { @Invoker("swimUpward") diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityRendererMixin.java index 8d86e3a5cf..1722122854 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityRendererMixin.java @@ -108,7 +108,7 @@ private void modifyScale(Args args, T livingEntity, float f, float g, MatrixStac args.set(2, module.playersScale.get().floatValue()); } - @ModifyArgs(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/EntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V")) + @ModifyArgs(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/EntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;III)V")) private void modifyColor(Args args, T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { Chams module = Modules.get().get(Chams.class); if (!module.isActive() || !module.players.get() || !(livingEntity instanceof PlayerEntity)) return; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerArmorSlotMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerArmorSlotMixin.java index d4f3bac608..bfa36adcae 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerArmorSlotMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerArmorSlotMixin.java @@ -5,31 +5,35 @@ package meteordevelopment.meteorclient.mixin; -import com.llamalad7.mixinextras.injector.ModifyReturnValue; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.misc.InventoryTweaks; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; +import net.minecraft.screen.slot.Slot; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; @Mixin(targets = "net/minecraft/screen/PlayerScreenHandler$1") -public abstract class PlayerArmorSlotMixin { - @ModifyReturnValue(method = "getMaxItemCount", at = @At("RETURN")) - private int onGetMaxItemCount(int original) { +public abstract class PlayerArmorSlotMixin extends Slot { + public PlayerArmorSlotMixin(Inventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } + + @Override + public int getMaxItemCount() { if (Modules.get().get(InventoryTweaks.class).armorStorage()) return 64; - return original; + return super.getMaxItemCount(); } - @ModifyReturnValue(method = "canInsert", at = @At("RETURN")) - private boolean onCanInsert(boolean original, ItemStack stack) { + @Override + public boolean canInsert(ItemStack stack) { if (Modules.get().get(InventoryTweaks.class).armorStorage()) return true; - return original; + return super.canInsert(stack); } - @ModifyReturnValue(method = "canTakeItems", at = @At("RETURN")) - private boolean onCanTakeItems(boolean original, PlayerEntity playerEntity) { + @Override + public boolean canTakeItems(PlayerEntity playerEntity) { if (Modules.get().get(InventoryTweaks.class).armorStorage()) return true; - return original; + return super.canTakeItems(playerEntity); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java index 4932ab2a91..42f87312f0 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java @@ -41,7 +41,7 @@ private void redirectRenderMain(ModelPart modelPart, MatrixStack matrices, Verte if (chams.isActive() && chams.hand.get()) { Color color = chams.handColor.get(); - modelPart.render(matrices, vertices, light, overlay, color.r/255f, color.g/255f, color.b/255f, color.a/255f); + modelPart.render(matrices, vertices, light, overlay, color.getPacked()); } else { modelPart.render(matrices, vertices, light, overlay); } @@ -55,7 +55,7 @@ private void redirectRenderSleeve(ModelPart modelPart, MatrixStack matrices, Ver if (chams.isActive() && chams.hand.get()) { Color color = chams.handColor.get(); - modelPart.render(matrices, vertices, light, overlay, color.r/255f, color.g/255f, color.b/255f, color.a/255f); + modelPart.render(matrices, vertices, light, overlay, color.getPacked()); } else { modelPart.render(matrices, vertices, light, overlay); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/RenderTickCounterMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/RenderTickCounterDynamicMixin.java similarity index 65% rename from src/main/java/meteordevelopment/meteorclient/mixin/RenderTickCounterMixin.java rename to src/main/java/meteordevelopment/meteorclient/mixin/RenderTickCounterDynamicMixin.java index 97bd3f4dde..78161d34f5 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/RenderTickCounterMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/RenderTickCounterDynamicMixin.java @@ -15,12 +15,13 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(RenderTickCounter.class) -public abstract class RenderTickCounterMixin { - @Shadow public float lastFrameDuration; +@Mixin(RenderTickCounter.Dynamic.class) +public abstract class RenderTickCounterDynamicMixin { + @Shadow + private float lastFrameDuration; - @Inject(method = "beginRenderTick", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/RenderTickCounter;prevTimeMillis:J", opcode = Opcodes.PUTFIELD)) + @Inject(method = "beginRenderTick(J)I", at = @At(value = "FIELD", target = "Lnet/minecraft/client/render/RenderTickCounter$Dynamic;prevTimeMillis:J", opcode = Opcodes.PUTFIELD)) private void onBeingRenderTick(long a, CallbackInfoReturnable info) { - lastFrameDuration *= Modules.get().get(Timer.class).getMultiplier(); + lastFrameDuration *= (float) Modules.get().get(Timer.class).getMultiplier(); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ShulkerBoxBlockMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ShulkerBoxBlockMixin.java index 0d5c17c436..5fc370ce06 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ShulkerBoxBlockMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ShulkerBoxBlockMixin.java @@ -8,9 +8,10 @@ import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.render.BetterTooltips; import net.minecraft.block.ShulkerBoxBlock; -import net.minecraft.client.item.TooltipType; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.tooltip.TooltipType; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/VertexBufferMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/VertexBufferMixin.java index c0f052beaa..1f02d3cd4e 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/VertexBufferMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/VertexBufferMixin.java @@ -5,10 +5,10 @@ package meteordevelopment.meteorclient.mixin; +import com.mojang.blaze3d.systems.RenderSystem; import meteordevelopment.meteorclient.renderer.GL; import net.minecraft.client.gl.VertexBuffer; -import net.minecraft.client.render.BufferBuilder; -import net.minecraft.client.render.VertexFormat; +import net.minecraft.client.render.BuiltBuffer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -21,9 +21,9 @@ public abstract class VertexBufferMixin { @Shadow private int indexBufferId; - @Inject(method = "uploadIndexBuffer", at = @At("RETURN")) - private void onConfigureIndexBuffer(BufferBuilder.DrawParameters parameters, ByteBuffer vertexBuffer, CallbackInfoReturnable info) { + @Inject(method = "uploadIndexBuffer(Lnet/minecraft/client/render/BuiltBuffer$DrawParameters;Ljava/nio/ByteBuffer;)Lcom/mojang/blaze3d/systems/RenderSystem$ShapeIndexBuffer;", at = @At("RETURN")) + private void onConfigureIndexBuffer(BuiltBuffer.DrawParameters parameters, ByteBuffer indexBuffer, CallbackInfoReturnable info) { if (info.getReturnValue() == null) GL.CURRENT_IBO = this.indexBufferId; - else GL.CURRENT_IBO = ((ShapeIndexBufferAccessor) info.getReturnValue()).getId(); + else GL.CURRENT_IBO = ((ShapeIndexBufferAccessor) (Object) info.getReturnValue()).getId(); } } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererAccessor.java index e072224aa1..ed353303d3 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererAccessor.java @@ -7,8 +7,9 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import net.minecraft.client.gl.Framebuffer; -import net.minecraft.client.render.BlockBreakingInfo; + import net.minecraft.client.render.WorldRenderer; +import net.minecraft.entity.player.BlockBreakingInfo; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererMixin.java index bba18185e9..a8f4f543cf 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/WorldRendererMixin.java @@ -75,7 +75,7 @@ private void hasBlindnessOrDarkness(Camera camera, CallbackInfoReturnable load(NbtCompound tag) { NbtCompound valueTag = tag.getCompound("value"); for (String key : valueTag.getKeys()) { - get().put(Registries.BLOCK.get(new Identifier(key)), defaultData.get().copy().fromTag(valueTag.getCompound(key))); + get().put(Registries.BLOCK.get(Identifier.of(key)), defaultData.get().copy().fromTag(valueTag.getCompound(key))); } return get(); diff --git a/src/main/java/meteordevelopment/meteorclient/settings/BlockListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/BlockListSetting.java index 569730c3c2..8bd8419bc8 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/BlockListSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/BlockListSetting.java @@ -75,7 +75,7 @@ protected List load(NbtCompound tag) { NbtList valueTag = tag.getList("value", 8); for (NbtElement tagI : valueTag) { - Block block = Registries.BLOCK.get(new Identifier(tagI.asString())); + Block block = Registries.BLOCK.get(Identifier.of(tagI.asString())); if (filter == null || filter.test(block)) get().add(block); } diff --git a/src/main/java/meteordevelopment/meteorclient/settings/BlockSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/BlockSetting.java index 2a4b0b55c7..9500e14260 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/BlockSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/BlockSetting.java @@ -46,7 +46,7 @@ protected NbtCompound save(NbtCompound tag) { @Override protected Block load(NbtCompound tag) { - value = Registries.BLOCK.get(new Identifier(tag.getString("value"))); + value = Registries.BLOCK.get(Identifier.of(tag.getString("value"))); if (filter != null && !filter.test(value)) { for (Block block : Registries.BLOCK) { diff --git a/src/main/java/meteordevelopment/meteorclient/settings/EnchantmentListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/EnchantmentListSetting.java index 97615417ee..295d39fb77 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/EnchantmentListSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/EnchantmentListSetting.java @@ -5,60 +5,69 @@ package meteordevelopment.meteorclient.settings; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import net.minecraft.client.MinecraftClient; import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.Enchantments; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtList; import net.minecraft.nbt.NbtString; -import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.util.Identifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.lang.reflect.AccessFlag; +import java.util.*; import java.util.function.Consumer; +import java.util.stream.Collectors; -public class EnchantmentListSetting extends Setting> { - public EnchantmentListSetting(String name, String description, List defaultValue, Consumer> onChanged, Consumer>> onModuleActivated, IVisible visible) { +public class EnchantmentListSetting extends Setting>> { + public EnchantmentListSetting(String name, String description, Set> defaultValue, Consumer>> onChanged, Consumer>>> onModuleActivated, IVisible visible) { super(name, description, defaultValue, onChanged, onModuleActivated, visible); } @Override public void resetImpl() { - value = new ArrayList<>(defaultValue); + value = new ObjectOpenHashSet<>(defaultValue); } @Override - protected List parseImpl(String str) { + protected Set> parseImpl(String str) { String[] values = str.split(","); - List enchs = new ArrayList<>(values.length); + Set> enchs = new ObjectOpenHashSet<>(values.length); - try { - for (String value : values) { - Enchantment ench = parseId(Registries.ENCHANTMENT, value); - if (ench != null) enchs.add(ench); - } - } catch (Exception ignored) {} + for (String value : values) { + String name = value.trim(); + + Identifier id; + if (name.contains(":")) id = Identifier.of(name); + else id = Identifier.ofVanilla(name); + + enchs.add(RegistryKey.of(RegistryKeys.ENCHANTMENT, id)); + } return enchs; } @Override - protected boolean isValueValid(List value) { + protected boolean isValueValid(Set> value) { return true; } @Override public Iterable getIdentifierSuggestions() { - return Registries.ENCHANTMENT.getIds(); + return Optional.ofNullable(MinecraftClient.getInstance().getNetworkHandler()) + .flatMap(networkHandler -> networkHandler.getRegistryManager().getOptional(RegistryKeys.ENCHANTMENT)) + .map(Registry::getIds).orElse(Set.of()); } @Override public NbtCompound save(NbtCompound tag) { NbtList valueTag = new NbtList(); - for (Enchantment ench : get()) { - Identifier id = Registries.ENCHANTMENT.getId(ench); - if (id != null) valueTag.add(NbtString.of(id.toString())); + for (RegistryKey ench : get()) { + valueTag.add(NbtString.of(ench.getValue().toString())); } tag.put("value", valueTag); @@ -66,30 +75,53 @@ public NbtCompound save(NbtCompound tag) { } @Override - public List load(NbtCompound tag) { + public Set> load(NbtCompound tag) { get().clear(); NbtList valueTag = tag.getList("value", 8); for (NbtElement tagI : valueTag) { - Enchantment enchantment = Registries.ENCHANTMENT.get(new Identifier(tagI.asString())); - if (enchantment != null) get().add(enchantment); + get().add(RegistryKey.of(RegistryKeys.ENCHANTMENT, Identifier.of(tagI.asString()))); } return get(); } - public static class Builder extends SettingBuilder, EnchantmentListSetting> { + public static class Builder extends SettingBuilder>, EnchantmentListSetting> { + private static final Set> VANILLA_DEFAULTS; + public Builder() { - super(new ArrayList<>(0)); + super(new ObjectOpenHashSet<>()); } - public Builder defaultValue(Enchantment... defaults) { - return defaultValue(defaults != null ? Arrays.asList(defaults) : new ArrayList<>()); + public Builder vanillaDefaults() { + return defaultValue(VANILLA_DEFAULTS); + } + + @SafeVarargs + public final Builder defaultValue(RegistryKey... defaults) { + return defaultValue(defaults != null ? new ObjectOpenHashSet<>(defaults) : new ObjectOpenHashSet<>()); } @Override public EnchantmentListSetting build() { return new EnchantmentListSetting(name, description, defaultValue, onChanged, onModuleActivated, visible); } + + static { + //noinspection unchecked,rawtypes + VANILLA_DEFAULTS = (Set) Arrays.stream(Enchantments.class.getDeclaredFields()) + .filter(field -> field.accessFlags().containsAll(List.of(AccessFlag.PUBLIC, AccessFlag.STATIC, AccessFlag.FINAL))) + .filter(field -> field.getType() == RegistryKey.class) + .map(field -> { + try { + return field.get(null); + } catch (IllegalAccessException e) { + return null; + } + }).filter(Objects::nonNull) + .map(RegistryKey.class::cast) + .filter(registryKey -> registryKey.getRegistryRef() == RegistryKeys.ENCHANTMENT) + .collect(Collectors.toSet()); + } } } diff --git a/src/main/java/meteordevelopment/meteorclient/settings/EntityTypeListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/EntityTypeListSetting.java index 9fface86c9..1b867478d5 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/EntityTypeListSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/EntityTypeListSetting.java @@ -112,7 +112,7 @@ public Set> load(NbtCompound tag) { NbtList valueTag = tag.getList("value", 8); for (NbtElement tagI : valueTag) { - EntityType type = Registries.ENTITY_TYPE.get(new Identifier(tagI.asString())); + EntityType type = Registries.ENTITY_TYPE.get(Identifier.of(tagI.asString())); if (filter == null || filter.test(type)) get().add(type); } diff --git a/src/main/java/meteordevelopment/meteorclient/settings/ItemListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/ItemListSetting.java index 17e4de9d5c..e9f0c4b4a3 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/ItemListSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/ItemListSetting.java @@ -77,7 +77,7 @@ public List load(NbtCompound tag) { NbtList valueTag = tag.getList("value", 8); for (NbtElement tagI : valueTag) { - Item item = Registries.ITEM.get(new Identifier(tagI.asString())); + Item item = Registries.ITEM.get(Identifier.of(tagI.asString())); if (bypassFilterWhenSavingAndLoading || (filter == null || filter.test(item))) get().add(item); } diff --git a/src/main/java/meteordevelopment/meteorclient/settings/ItemSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/ItemSetting.java index 37e8d4721e..10db4d513c 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/ItemSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/ItemSetting.java @@ -46,7 +46,7 @@ public NbtCompound save(NbtCompound tag) { @Override public Item load(NbtCompound tag) { - value = Registries.ITEM.get(new Identifier(tag.getString("value"))); + value = Registries.ITEM.get(Identifier.of(tag.getString("value"))); if (filter != null && !filter.test(value)) { for (Item item : Registries.ITEM) { diff --git a/src/main/java/meteordevelopment/meteorclient/settings/ParticleTypeListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/ParticleTypeListSetting.java index cd73f6de15..8fe6fc8097 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/ParticleTypeListSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/ParticleTypeListSetting.java @@ -72,7 +72,7 @@ public List> load(NbtCompound tag) { NbtList valueTag = tag.getList("value", 8); for (NbtElement tagI : valueTag) { - ParticleType particleType = Registries.PARTICLE_TYPE.get(new Identifier(tagI.asString())); + ParticleType particleType = Registries.PARTICLE_TYPE.get(Identifier.of(tagI.asString())); if (particleType != null) get().add(particleType); } diff --git a/src/main/java/meteordevelopment/meteorclient/settings/ScreenHandlerListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/ScreenHandlerListSetting.java index 30f624c9c0..c4e55d3134 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/ScreenHandlerListSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/ScreenHandlerListSetting.java @@ -72,7 +72,7 @@ public List> load(NbtCompound tag) { NbtList valueTag = tag.getList("value", 8); for (NbtElement tagI : valueTag) { - ScreenHandlerType type = Registries.SCREEN_HANDLER.get(new Identifier(tagI.asString())); + ScreenHandlerType type = Registries.SCREEN_HANDLER.get(Identifier.of(tagI.asString())); if (type != null) get().add(type); } diff --git a/src/main/java/meteordevelopment/meteorclient/settings/Setting.java b/src/main/java/meteordevelopment/meteorclient/settings/Setting.java index 6c95cca30d..cbe2437111 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/Setting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/Setting.java @@ -12,6 +12,7 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -151,12 +152,13 @@ public int hashCode() { return Objects.hash(name); } + @Nullable public static T parseId(Registry registry, String name) { name = name.trim(); Identifier id; - if (name.contains(":")) id = new Identifier(name); - else id = new Identifier("minecraft", name); + if (name.contains(":")) id = Identifier.of(name); + else id = Identifier.of("minecraft", name); if (registry.containsId(id)) return registry.get(id); return null; diff --git a/src/main/java/meteordevelopment/meteorclient/settings/SoundEventListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/SoundEventListSetting.java index b656b6ffef..7b79c9acf9 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/SoundEventListSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/SoundEventListSetting.java @@ -71,7 +71,7 @@ public List load(NbtCompound tag) { NbtList valueTag = tag.getList("value", 8); for (NbtElement tagI : valueTag) { - SoundEvent soundEvent = Registries.SOUND_EVENT.get(new Identifier(tagI.asString())); + SoundEvent soundEvent = Registries.SOUND_EVENT.get(Identifier.of(tagI.asString())); if (soundEvent != null) get().add(soundEvent); } diff --git a/src/main/java/meteordevelopment/meteorclient/settings/StatusEffectAmplifierMapSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/StatusEffectAmplifierMapSetting.java index cd2f90c5fe..682a55f822 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/StatusEffectAmplifierMapSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/StatusEffectAmplifierMapSetting.java @@ -77,7 +77,7 @@ public Reference2IntMap load(NbtCompound tag) { NbtCompound valueTag = tag.getCompound("value"); for (String key : valueTag.getKeys()) { - StatusEffect statusEffect = Registries.STATUS_EFFECT.get(new Identifier(key)); + StatusEffect statusEffect = Registries.STATUS_EFFECT.get(Identifier.of(key)); if (statusEffect != null) get().put(statusEffect, valueTag.getInt(key)); } diff --git a/src/main/java/meteordevelopment/meteorclient/settings/StatusEffectListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/StatusEffectListSetting.java index c2434785ba..268f7325ab 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/StatusEffectListSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/StatusEffectListSetting.java @@ -72,7 +72,7 @@ public List load(NbtCompound tag) { NbtList valueTag = tag.getList("value", 8); for (NbtElement tagI : valueTag) { - StatusEffect effect = Registries.STATUS_EFFECT.get(new Identifier(tagI.asString())); + StatusEffect effect = Registries.STATUS_EFFECT.get(Identifier.of(tagI.asString())); if (effect != null) get().add(effect); } diff --git a/src/main/java/meteordevelopment/meteorclient/settings/StorageBlockListSetting.java b/src/main/java/meteordevelopment/meteorclient/settings/StorageBlockListSetting.java index 7b364efde6..36d9b39feb 100644 --- a/src/main/java/meteordevelopment/meteorclient/settings/StorageBlockListSetting.java +++ b/src/main/java/meteordevelopment/meteorclient/settings/StorageBlockListSetting.java @@ -8,7 +8,7 @@ import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Lifecycle; import it.unimi.dsi.fastutil.objects.ObjectIterators; -import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; +import meteordevelopment.meteorclient.MeteorClient; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; @@ -30,7 +30,24 @@ import java.util.stream.Stream; public class StorageBlockListSetting extends Setting>> { - public static final BlockEntityType[] STORAGE_BLOCKS = { BlockEntityType.FURNACE, BlockEntityType.CHEST, BlockEntityType.TRAPPED_CHEST, BlockEntityType.ENDER_CHEST, BlockEntityType.DISPENSER, BlockEntityType.DROPPER, BlockEntityType.HOPPER, BlockEntityType.SHULKER_BOX, BlockEntityType.BARREL, BlockEntityType.SMOKER, BlockEntityType.BLAST_FURNACE, BlockEntityType.CAMPFIRE }; + public static final BlockEntityType[] STORAGE_BLOCKS = new BlockEntityType[]{ + BlockEntityType.BARREL, + BlockEntityType.BLAST_FURNACE, + BlockEntityType.BREWING_STAND, + BlockEntityType.CAMPFIRE, + BlockEntityType.CHEST, + BlockEntityType.CHISELED_BOOKSHELF, + BlockEntityType.CRAFTER, + BlockEntityType.DISPENSER, + BlockEntityType.DECORATED_POT, + BlockEntityType.DROPPER, + BlockEntityType.ENDER_CHEST, + BlockEntityType.FURNACE, + BlockEntityType.HOPPER, + BlockEntityType.SHULKER_BOX, + BlockEntityType.SMOKER, + BlockEntityType.TRAPPED_CHEST, + }; public static final Registry> REGISTRY = new SRegistry(); @@ -86,7 +103,7 @@ public List> load(NbtCompound tag) { NbtList valueTag = tag.getList("value", 8); for (NbtElement tagI : valueTag) { - BlockEntityType type = Registries.BLOCK_ENTITY_TYPE.get(new Identifier(tagI.asString())); + BlockEntityType type = Registries.BLOCK_ENTITY_TYPE.get(Identifier.of(tagI.asString())); if (type != null) get().add(type); } @@ -110,7 +127,7 @@ public StorageBlockListSetting build() { private static class SRegistry extends SimpleRegistry> { public SRegistry() { - super(RegistryKey.ofRegistry(new MeteorIdentifier("storage-blocks")), Lifecycle.stable()); + super(RegistryKey.ofRegistry(MeteorClient.identifier("storage-blocks")), Lifecycle.stable()); } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/CombatHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/CombatHud.java index 77d66f3206..f2b4d7be41 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/CombatHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/CombatHud.java @@ -6,6 +6,9 @@ package meteordevelopment.meteorclient.systems.hud.elements; import com.mojang.blaze3d.systems.RenderSystem; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.ObjectIntImmutablePair; +import it.unimi.dsi.fastutil.objects.ObjectIntPair; import meteordevelopment.meteorclient.renderer.Renderer2D; import meteordevelopment.meteorclient.renderer.text.TextRenderer; import meteordevelopment.meteorclient.settings.*; @@ -31,14 +34,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.SwordItem; -import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.EnchantmentTags; import net.minecraft.util.math.MathHelper; import org.joml.Matrix4fStack; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import static meteordevelopment.meteorclient.MeteorClient.mc; @@ -85,10 +87,10 @@ public class CombatHud extends HudElement { .build() ); - private final Setting> displayedEnchantments = sgGeneral.add(new EnchantmentListSetting.Builder() + private final Setting>> displayedEnchantments = sgGeneral.add(new EnchantmentListSetting.Builder() .name("displayed-enchantments") .description("The enchantments that are shown on nametags.") - .defaultValue(getDefaultEnchantments()) + .vanillaDefaults() .build() ); @@ -225,7 +227,7 @@ public void render(HudRenderer renderer) { (int) (y + (66 * scale.get())), (int) (30 * scale.get()), 0, - -MathHelper.wrapDegrees(playerEntity.prevYaw + (playerEntity.getYaw() - playerEntity.prevYaw) * mc.getTickDelta()), + -MathHelper.wrapDegrees(playerEntity.prevYaw + (playerEntity.getYaw() - playerEntity.prevYaw) * mc.getRenderTickCounter().getTickDelta(true)), -playerEntity.getPitch(), playerEntity ); @@ -355,20 +357,19 @@ public void render(HudRenderer renderer) { armorY += 18; ItemEnchantmentsComponent enchantments = EnchantmentHelper.getEnchantments(itemStack); - Map enchantmentsToShow = new HashMap<>(); + List>> enchantmentsToShow = new ArrayList<>(); - for (Enchantment enchantment : displayedEnchantments.get()) { - if (enchantments.getEnchantments().contains(Registries.ENCHANTMENT.getEntry(enchantment))) { - enchantmentsToShow.put(enchantment, enchantments.getLevel(enchantment)); + for (Object2IntMap.Entry> entry : enchantments.getEnchantmentEntries()) { + if (entry.getKey().matches(displayedEnchantments.get()::contains)) { + enchantmentsToShow.add(new ObjectIntImmutablePair<>(entry.getKey(), entry.getIntValue())); } } - for (Enchantment enchantment : enchantmentsToShow.keySet()) { - String enchantName = Utils.getEnchantSimpleName(enchantment, 3) + " " + enchantmentsToShow.get(enchantment); + for (ObjectIntPair> entry : enchantmentsToShow) { + String enchantName = Utils.getEnchantSimpleName(entry.left(), 3) + " " + entry.rightInt(); double enchX = (armorX + 8) - (TextRenderer.get().getWidth(enchantName) / 2); - - TextRenderer.get().render(enchantName, enchX, armorY, enchantment.isCursed() ? RED : enchantmentTextColor.get()); + TextRenderer.get().render(enchantName, enchX, armorY, entry.left().isIn(EnchantmentTags.CURSE) ? RED : enchantmentTextColor.get()); armorY += TextRenderer.get().getHeight(); } slot--; @@ -440,14 +441,4 @@ private ItemStack getItem(int i) { default -> playerEntity.getInventory().getArmorStack(i); }; } - - public static List getDefaultEnchantments() { - List enchantments = new ArrayList<>(); - - for (Enchantment enchantment : Registries.ENCHANTMENT) { - enchantments.add(enchantment); - } - - return enchantments; - } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/InventoryHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/InventoryHud.java index d4ae09dffa..2509cb271f 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/InventoryHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/InventoryHud.java @@ -5,13 +5,13 @@ package meteordevelopment.meteorclient.systems.hud.elements; +import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.hud.Hud; import meteordevelopment.meteorclient.systems.hud.HudElement; import meteordevelopment.meteorclient.systems.hud.HudElementInfo; import meteordevelopment.meteorclient.systems.hud.HudRenderer; import meteordevelopment.meteorclient.utils.Utils; -import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import net.minecraft.item.ItemStack; @@ -23,8 +23,8 @@ public class InventoryHud extends HudElement { public static final HudElementInfo INFO = new HudElementInfo<>(Hud.GROUP, "inventory", "Displays your inventory.", InventoryHud::new); - private static final Identifier TEXTURE = new MeteorIdentifier("textures/container.png"); - private static final Identifier TEXTURE_TRANSPARENT = new MeteorIdentifier("textures/container-transparent.png"); + private static final Identifier TEXTURE = MeteorClient.identifier("textures/container.png"); + private static final Identifier TEXTURE_TRANSPARENT = MeteorClient.identifier("textures/container-transparent.png"); private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerModelHud.java b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerModelHud.java index a311bb135f..69ed1a9595 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerModelHud.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/hud/elements/PlayerModelHud.java @@ -111,7 +111,7 @@ public void render(HudRenderer renderer) { float offset = centerOrientation.get() == CenterOrientation.North ? 180 : 0; - float yaw = copyYaw.get() ? MathHelper.wrapDegrees(player.prevYaw + (player.getYaw() - player.prevYaw) * mc.getTickDelta() + offset) : (float) customYaw.get(); + float yaw = copyYaw.get() ? MathHelper.wrapDegrees(player.prevYaw + (player.getYaw() - player.prevYaw) * mc.getRenderTickCounter().getTickDelta(true) + offset) : (float) customYaw.get(); float pitch = copyPitch.get() ? player.getPitch() : (float) customPitch.get(); drawEntity(renderer.drawContext, x, y, (int) (30 * scale.get()), -yaw, -pitch, player); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java index 602bd1ae6a..c5583011a5 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java @@ -35,7 +35,6 @@ import meteordevelopment.meteorclient.systems.modules.world.*; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.misc.Keybind; -import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; import meteordevelopment.meteorclient.utils.misc.ValueComparableMap; import meteordevelopment.meteorclient.utils.misc.input.Input; import meteordevelopment.meteorclient.utils.misc.input.KeyAction; @@ -591,7 +590,7 @@ private void initMisc() { public static class ModuleRegistry extends SimpleRegistry { public ModuleRegistry() { - super(RegistryKey.ofRegistry(new MeteorIdentifier("modules")), Lifecycle.stable()); + super(RegistryKey.ofRegistry(MeteorClient.identifier("modules")), Lifecycle.stable()); } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoArmor.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoArmor.java index 40906739c9..7e30c169f6 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoArmor.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoArmor.java @@ -22,10 +22,12 @@ import net.minecraft.item.ElytraItem; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.entry.RegistryEntry; import java.util.Arrays; import java.util.Comparator; -import java.util.List; +import java.util.Set; public class AutoArmor extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); @@ -46,7 +48,7 @@ public class AutoArmor extends Module { .build() ); - private final Setting> avoidedEnchantments = sgGeneral.add(new EnchantmentListSetting.Builder() + private final Setting>> avoidedEnchantments = sgGeneral.add(new EnchantmentListSetting.Builder() .name("avoided-enchantments") .description("Enchantments that should be avoided.") .defaultValue(Enchantments.BINDING_CURSE, Enchantments.FROST_WALKER) @@ -74,7 +76,7 @@ public class AutoArmor extends Module { .build() ); - private final Object2IntMap enchantments = new Object2IntOpenHashMap<>(); + private final Object2IntMap> enchantments = new Object2IntOpenHashMap<>(); private final ArmorPiece[] armorPieces = new ArmorPiece[4]; private final ArmorPiece helmet = new ArmorPiece(3); private final ArmorPiece chestplate = new ArmorPiece(2); @@ -139,8 +141,10 @@ private void onPreTick(TickEvent.Pre event) { } private boolean hasAvoidedEnchantment() { - for (Enchantment enchantment : avoidedEnchantments.get()) { - if (enchantments.containsKey(enchantment)) return true; + for (RegistryEntry enchantment : enchantments.keySet()) { + if (enchantment.matches(avoidedEnchantments.get()::contains)) { + return true; + } } return false; @@ -158,18 +162,18 @@ private int getScore(ItemStack itemStack) { int score = 0; // Prefer blast protection on leggings if enabled - Enchantment protection = preferredProtection.get().enchantment; + RegistryKey protection = preferredProtection.get().enchantment; if (itemStack.getItem() instanceof ArmorItem && blastLeggings.get() && getItemSlotId(itemStack) == 1) { protection = Enchantments.BLAST_PROTECTION; } - score += 3 * enchantments.getInt(protection); - score += enchantments.getInt(Enchantments.PROTECTION); - score += enchantments.getInt(Enchantments.BLAST_PROTECTION); - score += enchantments.getInt(Enchantments.FIRE_PROTECTION); - score += enchantments.getInt(Enchantments.PROJECTILE_PROTECTION); - score += enchantments.getInt(Enchantments.UNBREAKING); - score += 2 * enchantments.getInt(Enchantments.MENDING); + score += 3 * Utils.getEnchantmentLevel(enchantments, protection); + score += Utils.getEnchantmentLevel(enchantments, Enchantments.PROTECTION); + score += Utils.getEnchantmentLevel(enchantments, Enchantments.BLAST_PROTECTION); + score += Utils.getEnchantmentLevel(enchantments, Enchantments.FIRE_PROTECTION); + score += Utils.getEnchantmentLevel(enchantments, Enchantments.PROJECTILE_PROTECTION); + score += Utils.getEnchantmentLevel(enchantments, Enchantments.UNBREAKING); + score += 2 * Utils.getEnchantmentLevel(enchantments, Enchantments.MENDING); score += itemStack.getItem() instanceof ArmorItem armorItem ? armorItem.getProtection() : 0; score += itemStack.getItem() instanceof ArmorItem armorItem ? (int) armorItem.getToughness() : 0; @@ -206,9 +210,9 @@ public enum Protection { FireProtection(Enchantments.FIRE_PROTECTION), ProjectileProtection(Enchantments.PROJECTILE_PROTECTION); - private final Enchantment enchantment; + private final RegistryKey enchantment; - Protection(Enchantment enchantment) { + Protection(RegistryKey enchantment) { this.enchantment = enchantment; } } @@ -291,7 +295,7 @@ else if (antiBreak.get() && durability <= 10) { } private int decreaseScoreByAvoidedEnchantments(int score) { - for (Enchantment enchantment : avoidedEnchantments.get()) { + for (RegistryKey enchantment : avoidedEnchantments.get()) { score -= 2 * enchantments.getInt(enchantment); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoEXP.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoEXP.java index 09eecd9c2a..2cc325afeb 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoEXP.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoEXP.java @@ -9,12 +9,12 @@ import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.meteorclient.utils.player.Rotations; import meteordevelopment.meteorclient.utils.player.SlotUtils; import meteordevelopment.orbit.EventHandler; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -127,7 +127,7 @@ private void onTick(TickEvent.Pre event) { } private boolean needsRepair(ItemStack itemStack, double threshold) { - if (itemStack.isEmpty() || EnchantmentHelper.getLevel(Enchantments.MENDING, itemStack) < 1) return false; + if (itemStack.isEmpty() || !Utils.hasEnchantments(itemStack, Enchantments.MENDING)) return false; return (itemStack.getMaxDamage() - itemStack.getDamage()) / (double) itemStack.getMaxDamage() * 100 <= threshold; } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoWeapon.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoWeapon.java index c8341f6e25..e1326e99b2 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoWeapon.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoWeapon.java @@ -12,7 +12,6 @@ import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.orbit.EventHandler; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityType; import net.minecraft.item.AxeItem; import net.minecraft.item.ItemStack; @@ -62,14 +61,14 @@ private int getBestWeapon(EntityType group) { ItemStack stack = mc.player.getInventory().getStack(i); if (stack.getItem() instanceof SwordItem swordItem && (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamage()) > 10)) { - currentDamageS = swordItem.getMaterial().getAttackDamage() + EnchantmentHelper.getAttackDamage(stack, group) + 2; + currentDamageS = swordItem.getMaterial().getAttackDamage() /*fixme + EnchantmentHelper.getAttackDamage(stack, group)*/ + 2; if (currentDamageS > damageS) { damageS = currentDamageS; slotS = i; } } else if (stack.getItem() instanceof AxeItem axeItem && (!antiBreak.get() || (stack.getMaxDamage() - stack.getDamage()) > 10)) { - currentDamageA = axeItem.getMaterial().getAttackDamage() + EnchantmentHelper.getAttackDamage(stack, group) + 2; + currentDamageA = axeItem.getMaterial().getAttackDamage() /*fixme + EnchantmentHelper.getAttackDamage(stack, group)*/ + 2; if (currentDamageA > damageA) { damageA = currentDamageA; slotA = i; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Surround.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Surround.java index 6e41fcdd76..84e8310273 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Surround.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Surround.java @@ -24,7 +24,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.client.render.BlockBreakingInfo; +import net.minecraft.entity.player.BlockBreakingInfo; import net.minecraft.entity.Entity; import net.minecraft.entity.decoration.EndCrystalEntity; import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java index 297e6bfbb1..0400733503 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/BetterChat.java @@ -11,6 +11,7 @@ import it.unimi.dsi.fastutil.chars.Char2CharOpenHashMap; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; +import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.commands.Commands; import meteordevelopment.meteorclient.events.game.ReceiveMessageEvent; import meteordevelopment.meteorclient.events.game.SendMessageEvent; @@ -21,7 +22,6 @@ import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.Utils; -import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; import meteordevelopment.meteorclient.utils.misc.text.MeteorClickEvent; import meteordevelopment.meteorclient.utils.misc.text.TextVisitor; import meteordevelopment.meteorclient.utils.player.ChatUtils; @@ -388,8 +388,8 @@ public static void registerCustomHead(String prefix, Identifier texture) { } static { - registerCustomHead("[Meteor]", new MeteorIdentifier("textures/icons/chat/meteor.png")); - registerCustomHead("[Baritone]", new MeteorIdentifier("textures/icons/chat/baritone.png")); + registerCustomHead("[Meteor]", MeteorClient.identifier("textures/icons/chat/meteor.png")); + registerCustomHead("[Baritone]", MeteorClient.identifier("textures/icons/chat/baritone.png")); } public int modifyChatWidth(int width) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java index 44363f7421..0544a13ed3 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/Notebot.java @@ -35,7 +35,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.NoteBlock; -import net.minecraft.block.enums.Instrument; +import net.minecraft.block.enums.NoteBlockInstrument; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket; import net.minecraft.sound.SoundEvents; @@ -254,7 +254,7 @@ public class Notebot extends Module { public Notebot() { super(Categories.Misc, "notebot", "Plays noteblock nicely"); - for (Instrument inst : Instrument.values()) { + for (NoteBlockInstrument inst : NoteBlockInstrument.values()) { NotebotUtils.OptionalInstrument optionalInstrument = NotebotUtils.OptionalInstrument.fromMinecraftInstrument(inst); if (optionalInstrument != null) { sgNoteMap.add(new EnumSetting.Builder() @@ -473,7 +473,7 @@ private void setupNoteblocksMap() { // Modifiable list of unique notes List uniqueNotesToUse = new ArrayList<>(song.getRequirements()); // A map with noteblocks that have incorrect note level - Map> incorrectNoteBlocks = new HashMap<>(); + Map> incorrectNoteBlocks = new HashMap<>(); // Check if there are already tuned noteblocks for (var entry : scannedNoteblocks.asMap().entrySet()) { @@ -502,7 +502,7 @@ private void setupNoteblocksMap() { List positions = entry.getValue(); if (mode.get() == NotebotUtils.NotebotMode.ExactInstruments) { - Instrument inst = entry.getKey(); + NoteBlockInstrument inst = entry.getKey(); List foundNotes = uniqueNotesToUse.stream() .filter(note -> note.getInstrument() == inst) @@ -936,13 +936,13 @@ private boolean isValidScanSpot(BlockPos pos) { } /** - * Gets an Instrument from Note Map + * Gets an NoteBlockInstrument from Note Map * * @param inst An instrument * @return A new instrument mapped by instrument given in parameters */ @Nullable - public Instrument getMappedInstrument(@NotNull Instrument inst) { + public NoteBlockInstrument getMappedInstrument(@NotNull NoteBlockInstrument inst) { if (mode.get() == NotebotUtils.NotebotMode.ExactInstruments) { NotebotUtils.OptionalInstrument optionalInstrument = (NotebotUtils.OptionalInstrument) sgNoteMap.getByIndex(inst.ordinal()).get(); return optionalInstrument.toMinecraftInstrument(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.java index a3d6a73ba2..a78ecda49c 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.java @@ -21,8 +21,8 @@ import meteordevelopment.orbit.EventHandler; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.enchantment.ProtectionEnchantment; import net.minecraft.entity.EntityType; +import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.fluid.Fluids; import net.minecraft.network.packet.Packet; @@ -323,15 +323,14 @@ private boolean lavaShouldBeSolid() { private boolean lavaIsSafe() { if (!dipIfFireResistant.get()) return false; - return mc.player.hasStatusEffect(StatusEffects.FIRE_RESISTANCE) && (mc.player.getStatusEffect(StatusEffects.FIRE_RESISTANCE).getDuration() > ProtectionEnchantment.transformFireDuration(mc.player, 15 * 20)); + return mc.player.hasStatusEffect(StatusEffects.FIRE_RESISTANCE) && (mc.player.getStatusEffect(StatusEffects.FIRE_RESISTANCE).getDuration() > (15 * 20 * mc.player.getAttributeValue(EntityAttributes.GENERIC_BURNING_TIME))); + // todo verify } private boolean isOverLiquid() { boolean foundLiquid = false; boolean foundSolid = false; - - List blockCollisions = Streams.stream(mc.world.getBlockCollisions(mc.player, mc.player.getBoundingBox().offset(0, -0.5, 0))) .map(VoxelShape::getBoundingBox) .collect(Collectors.toCollection(ArrayList::new)); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/speed/modes/Strafe.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/speed/modes/Strafe.java index e3630a9fc2..194e23811d 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/speed/modes/Strafe.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/speed/modes/Strafe.java @@ -73,7 +73,7 @@ public void onMove(PlayerMoveEvent event) { private Vector2d transformStrafe(double speed) { float forward = mc.player.input.movementForward; float side = mc.player.input.movementSideways; - float yaw = mc.player.prevYaw + (mc.player.getYaw() - mc.player.prevYaw) * mc.getTickDelta(); + float yaw = mc.player.prevYaw + (mc.player.getYaw() - mc.player.prevYaw) * mc.getRenderTickCounter().getTickDelta(true); double velX, velZ; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoMend.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoMend.java index 243e67a35a..209838989a 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoMend.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoMend.java @@ -12,10 +12,10 @@ import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.orbit.EventHandler; import net.minecraft.component.DataComponentTypes; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -85,7 +85,7 @@ private boolean shouldWait() { if (itemStack.isEmpty()) return false; - if (EnchantmentHelper.getLevel(Enchantments.MENDING, itemStack) > 0) { + if (Utils.hasEnchantments(itemStack, Enchantments.MENDING)) { return itemStack.getDamage() != 0; } @@ -97,7 +97,7 @@ private int getSlot() { ItemStack itemStack = mc.player.getInventory().getStack(i); if (blacklist.get().contains(itemStack.getItem())) continue; - if (EnchantmentHelper.getLevel(Enchantments.MENDING, itemStack) > 0 && itemStack.getDamage() > 0) { + if (Utils.hasEnchantments(itemStack, Enchantments.MENDING) && itemStack.getDamage() > 0) { return i; } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java index c8cd0e1287..8c9ff700fb 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java @@ -14,13 +14,13 @@ import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.render.Xray; import meteordevelopment.meteorclient.systems.modules.world.InfinityMiner; +import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.meteorclient.utils.world.BlockUtils; import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventPriority; import net.minecraft.block.*; import net.minecraft.component.DataComponentTypes; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.item.*; import net.minecraft.registry.tag.BlockTags; @@ -195,25 +195,25 @@ public static double getScore(ItemStack itemStack, BlockState state, boolean sil if (silkTouchEnderChest && state.getBlock() == Blocks.ENDER_CHEST - && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, itemStack) == 0) { + && !Utils.hasEnchantments(itemStack, Enchantments.SILK_TOUCH)) { return -1; } if (fortuneOre && isFortunable(state.getBlock()) - && EnchantmentHelper.getLevel(Enchantments.FORTUNE, itemStack) == 0) { + && !Utils.hasEnchantments(itemStack, Enchantments.FORTUNE)) { return -1; } double score = 0; score += itemStack.getMiningSpeedMultiplier(state) * 1000; - score += EnchantmentHelper.getLevel(Enchantments.UNBREAKING, itemStack); - score += EnchantmentHelper.getLevel(Enchantments.EFFICIENCY, itemStack); - score += EnchantmentHelper.getLevel(Enchantments.MENDING, itemStack); + score += Utils.getEnchantmentLevel(itemStack, Enchantments.UNBREAKING); + score += Utils.getEnchantmentLevel(itemStack, Enchantments.EFFICIENCY); + score += Utils.getEnchantmentLevel(itemStack, Enchantments.MENDING); - if (enchantPreference == EnchantPreference.Fortune) score += EnchantmentHelper.getLevel(Enchantments.FORTUNE, itemStack); - if (enchantPreference == EnchantPreference.SilkTouch) score += EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, itemStack); + if (enchantPreference == EnchantPreference.Fortune) score += Utils.getEnchantmentLevel(itemStack, Enchantments.FORTUNE); + if (enchantPreference == EnchantPreference.SilkTouch) score += Utils.getEnchantmentLevel(itemStack, Enchantments.SILK_TOUCH); if (itemStack.getItem() instanceof SwordItem item && (state.getBlock() instanceof BambooBlock || state.getBlock() instanceof BambooShootBlock)) score += 9000 + (item.getComponents().get(DataComponentTypes.TOOL).getSpeed(state) * 1000); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/GhostHand.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/GhostHand.java index 1e9f5a7a42..010e6c2c30 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/GhostHand.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/GhostHand.java @@ -29,7 +29,7 @@ public GhostHand() { private void onTick(TickEvent.Pre event) { if (!mc.options.useKey.isPressed() || mc.player.isSneaking()) return; - if (mc.world.getBlockState(BlockPos.ofFloored(mc.player.raycast(mc.player.getBlockInteractionRange(), mc.getTickDelta(), false).getPos())).hasBlockEntity()) return; + if (mc.world.getBlockState(BlockPos.ofFloored(mc.player.raycast(mc.player.getBlockInteractionRange(), mc.getRenderTickCounter().getTickDelta(true), false).getPos())).hasBlockEntity()) return; Vec3d direction = new Vec3d(0, 0, 0.1) .rotateX(-(float) Math.toRadians(mc.player.getPitch())) @@ -38,7 +38,7 @@ private void onTick(TickEvent.Pre event) { posList.clear(); for (int i = 1; i < mc.player.getBlockInteractionRange() * 10; i++) { - BlockPos pos = BlockPos.ofFloored(mc.player.getCameraPosVec(mc.getTickDelta()).add(direction.multiply(i))); + BlockPos pos = BlockPos.ofFloored(mc.player.getCameraPosVec(mc.getRenderTickCounter().getTickDelta(true)).add(direction.multiply(i))); if (posList.contains(pos)) continue; posList.add(pos); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BreakIndicators.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BreakIndicators.java index ebf448ca16..8ba041839c 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BreakIndicators.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BreakIndicators.java @@ -18,7 +18,7 @@ import meteordevelopment.meteorclient.utils.render.color.SettingColor; import meteordevelopment.orbit.EventHandler; import net.minecraft.block.BlockState; -import net.minecraft.client.render.BlockBreakingInfo; +import net.minecraft.entity.player.BlockBreakingInfo; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.util.shape.VoxelShape; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Chams.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Chams.java index c015780748..1d2bcbef5a 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Chams.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Chams.java @@ -5,11 +5,11 @@ package meteordevelopment.meteorclient.systems.modules.render; +import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.Utils; -import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import meteordevelopment.meteorclient.utils.render.postprocess.PostProcessShaders; import net.minecraft.entity.Entity; @@ -215,7 +215,7 @@ public class Chams extends Module { .build() ); - public static final Identifier BLANK = new MeteorIdentifier("textures/blank.png"); + public static final Identifier BLANK = MeteorClient.identifier("textures/blank.png"); public Chams() { super(Categories.Render, "chams", "Tweaks rendering of entities."); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Nametags.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Nametags.java index 77bf49b9aa..2057f9009a 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Nametags.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Nametags.java @@ -5,6 +5,9 @@ package meteordevelopment.meteorclient.systems.modules.render; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntMaps; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import meteordevelopment.meteorclient.events.render.Render2DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.renderer.Renderer2D; @@ -33,7 +36,9 @@ import net.minecraft.entity.decoration.ItemFrameEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.registry.RegistryKey; import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.EnchantmentTags; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameMode; @@ -182,7 +187,7 @@ public class Nametags extends Module { .build() ); - private final Setting> shownEnchantments = sgPlayers.add(new EnchantmentListSetting.Builder() + private final Setting>> shownEnchantments = sgPlayers.add(new EnchantmentListSetting.Builder() .name("shown-enchantments") .description("The enchantments that are shown on nametags.") .visible(() -> displayItems.get() && displayEnchants.get()) @@ -485,8 +490,8 @@ private void renderNametagPlayer(Render2DEvent event, PlayerEntity player, boole int size = 0; for (RegistryEntry enchantment : enchantments.getEnchantments()) { - if (!shownEnchantments.get().contains(enchantment.value())) continue; - String enchantName = Utils.getEnchantSimpleName(enchantment.value(), enchantLength.get()) + " " + enchantments.getLevel(enchantment.value()); + if (enchantment.getKey().isPresent() && !shownEnchantments.get().contains(enchantment.getKey().get())) continue; + String enchantName = Utils.getEnchantSimpleName(enchantment, enchantLength.get()) + " " + enchantments.getLevel(enchantment); itemWidths[i] = Math.max(itemWidths[i], (text.getWidth(enchantName, shadow) / 2)); size++; } @@ -527,11 +532,11 @@ private void renderNametagPlayer(Render2DEvent event, PlayerEntity player, boole text.begin(0.5 * enchantTextScale.get(), false, true); ItemEnchantmentsComponent enchantments = EnchantmentHelper.getEnchantments(stack); - Map enchantmentsToShow = new HashMap<>(); + Object2IntMap> enchantmentsToShow = new Object2IntOpenHashMap<>(); for (RegistryEntry enchantment : enchantments.getEnchantments()) { - if (shownEnchantments.get().contains(enchantment.value())) { - enchantmentsToShow.put(enchantment.value(), enchantments.getLevel(enchantment.value())); + if (enchantment.matches(shownEnchantments.get()::contains)) { + enchantmentsToShow.put(enchantment, enchantments.getLevel(enchantment)); } } @@ -545,11 +550,11 @@ private void renderNametagPlayer(Render2DEvent event, PlayerEntity player, boole double enchantX; - for (Enchantment enchantment : enchantmentsToShow.keySet()) { - String enchantName = Utils.getEnchantSimpleName(enchantment, enchantLength.get()) + " " + enchantmentsToShow.get(enchantment); + for (Object2IntMap.Entry> entry : Object2IntMaps.fastIterable(enchantmentsToShow)) { + String enchantName = Utils.getEnchantSimpleName(entry.getKey(), enchantLength.get()) + " " + entry.getIntValue(); Color enchantColor = WHITE; - if (enchantment.isCursed()) enchantColor = RED; + if (entry.getKey().isIn(EnchantmentTags.CURSE)) enchantColor = RED; enchantX = switch (enchantPos.get()) { case Above -> x + (aW / 2) - (text.getWidth(enchantName, shadow) / 2); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/StorageESP.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/StorageESP.java index 9655ef5215..667942491e 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/StorageESP.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/StorageESP.java @@ -192,7 +192,7 @@ private void getBlockEntityColor(BlockEntity blockEntity) { else if (blockEntity instanceof BarrelBlockEntity) lineColor.set(barrel.get()); else if (blockEntity instanceof ShulkerBoxBlockEntity) lineColor.set(shulker.get()); else if (blockEntity instanceof EnderChestBlockEntity) lineColor.set(enderChest.get()); - else if (blockEntity instanceof AbstractFurnaceBlockEntity || blockEntity instanceof DispenserBlockEntity || blockEntity instanceof HopperBlockEntity) lineColor.set(other.get()); + else if (blockEntity instanceof AbstractFurnaceBlockEntity || blockEntity instanceof BrewingStandBlockEntity || blockEntity instanceof ChiseledBookshelfBlockEntity || blockEntity instanceof CrafterBlockEntity || blockEntity instanceof DispenserBlockEntity || blockEntity instanceof DecoratedPotBlockEntity || blockEntity instanceof HopperBlockEntity) lineColor.set(other.get()); else return; render = true; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Trajectories.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Trajectories.java index c20c13dba3..b5f4aba8f2 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Trajectories.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Trajectories.java @@ -15,7 +15,6 @@ import meteordevelopment.meteorclient.utils.misc.Pool; import meteordevelopment.meteorclient.utils.render.color.SettingColor; import meteordevelopment.orbit.EventHandler; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -149,7 +148,7 @@ private void calculatePath(PlayerEntity player, double tickDelta) { if (!simulator.set(player, itemStack, 0, accurate.get(), tickDelta)) return; getEmptyPath().calculate(); - if (itemStack.getItem() instanceof CrossbowItem && EnchantmentHelper.getLevel(Enchantments.MULTISHOT, itemStack) > 0) { + if (itemStack.getItem() instanceof CrossbowItem && Utils.hasEnchantment(itemStack, Enchantments.MULTISHOT)) { if (!simulator.set(player, itemStack, MULTISHOT_OFFSET, accurate.get(), tickDelta)) return; // left multishot arrow getEmptyPath().calculate(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoSmelter.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoSmelter.java index fd07a778bf..4c6fd693f4 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoSmelter.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoSmelter.java @@ -15,11 +15,11 @@ import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.InvUtils; import net.minecraft.block.entity.AbstractFurnaceBlockEntity; -import net.minecraft.inventory.SimpleInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.recipe.RecipeType; +import net.minecraft.recipe.input.SingleStackRecipeInput; import net.minecraft.screen.AbstractFurnaceScreenHandler; import java.util.List; @@ -67,7 +67,7 @@ private boolean fuelItemFilter(Item item) { } private boolean smeltableItemFilter(Item item) { - return mc.world != null && mc.world.getRecipeManager().getFirstMatch(RecipeType.SMELTING, new SimpleInventory(item.getDefaultStack()), mc.world).isPresent(); + return mc.world != null && mc.world.getRecipeManager().getFirstMatch(RecipeType.SMELTING, new SingleStackRecipeInput(item.getDefaultStack()), mc.world).isPresent(); } public void tick(AbstractFurnaceScreenHandler c) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/EChestFarmer.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/EChestFarmer.java index 0f6667e89c..f2455ea334 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/EChestFarmer.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/EChestFarmer.java @@ -12,6 +12,7 @@ import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.meteorclient.utils.player.PlayerUtils; @@ -21,7 +22,6 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -153,7 +153,7 @@ private void onTick(TickEvent.Pre event) { for (int i = 0; i < 9; i++) { ItemStack itemStack = mc.player.getInventory().getStack(i); - if (EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, itemStack) > 0) continue; + if (Utils.hasEnchantment(itemStack, Enchantments.SILK_TOUCH)) continue; double score = itemStack.getMiningSpeedMultiplier(Blocks.ENDER_CHEST.getDefaultState()); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java index 657525a1dd..fdb0a1d6d3 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/HighwayBuilder.java @@ -17,6 +17,7 @@ import meteordevelopment.meteorclient.systems.modules.player.AutoGap; import meteordevelopment.meteorclient.systems.modules.player.AutoTool; import meteordevelopment.meteorclient.systems.modules.player.InstantRebreak; +import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.misc.HorizontalDirection; import meteordevelopment.meteorclient.utils.misc.MBlockPos; import meteordevelopment.meteorclient.utils.player.CustomPlayerInput; @@ -33,7 +34,6 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.input.Input; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; @@ -1065,7 +1065,7 @@ protected int findAndMoveBestToolToHotbar(HighwayBuilder b, BlockState blockStat for (int i = 0; i < b.mc.player.getInventory().main.size(); i++) { double score = AutoTool.getScore(b.mc.player.getInventory().getStack(i), blockState, false, false, AutoTool.EnchantPreference.None, itemStack -> { - if (noSilkTouch && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, itemStack) != 0) return false; + if (noSilkTouch && Utils.hasEnchantment(itemStack, Enchantments.SILK_TOUCH)) return false; return !b.dontBreakTools.get() || itemStack.getMaxDamage() - itemStack.getDamage() > 1; }); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/InfinityMiner.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/InfinityMiner.java index b1618bb819..1e6e5f768b 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/InfinityMiner.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/InfinityMiner.java @@ -184,8 +184,8 @@ private boolean needsRepair() { private boolean findPickaxe() { Predicate pickaxePredicate = (stack -> stack.getItem() instanceof PickaxeItem - && Utils.hasEnchantments(stack, Enchantments.MENDING) - && !Utils.hasEnchantments(stack, Enchantments.SILK_TOUCH)); + && Utils.hasEnchantment(stack, Enchantments.MENDING) + && !Utils.hasEnchantment(stack, Enchantments.SILK_TOUCH)); FindItemResult bestPick = InvUtils.findInHotbar(pickaxePredicate); if (bestPick.isOffhand()) InvUtils.shiftClick().fromOffhand().toHotbar(mc.player.getInventory().selectedSlot); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/Utils.java b/src/main/java/meteordevelopment/meteorclient/utils/Utils.java index 182b33176e..7da482b09a 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/Utils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/Utils.java @@ -7,10 +7,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.VertexSorter; -import it.unimi.dsi.fastutil.objects.Object2IntArrayMap; -import it.unimi.dsi.fastutil.objects.Object2IntMap; -import it.unimi.dsi.fastutil.objects.Reference2IntArrayMap; -import it.unimi.dsi.fastutil.objects.Reference2IntMap; +import it.unimi.dsi.fastutil.objects.*; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.gui.tabs.TabScreen; @@ -20,6 +17,7 @@ import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.render.BetterTooltips; import meteordevelopment.meteorclient.systems.modules.world.Timer; +import meteordevelopment.meteorclient.utils.misc.Names; import meteordevelopment.meteorclient.utils.player.EChestMemory; import meteordevelopment.meteorclient.utils.render.PeekScreen; import meteordevelopment.meteorclient.utils.render.color.Color; @@ -35,7 +33,6 @@ import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; import net.minecraft.client.gui.screen.world.SelectWorldScreen; import net.minecraft.client.resource.ResourceReloadLogger; -import net.minecraft.client.resource.language.I18n; import net.minecraft.component.ComponentMap; import net.minecraft.component.DataComponentTypes; import net.minecraft.component.type.ItemEnchantmentsComponent; @@ -47,6 +44,7 @@ import net.minecraft.item.*; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtList; +import net.minecraft.registry.RegistryKey; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.DyeColor; import net.minecraft.util.collection.DefaultedList; @@ -145,30 +143,60 @@ public static Iterable blockEntities() { return BlockEntityIterator::new; } - public static void getEnchantments(ItemStack itemStack, Object2IntMap enchantments) { + public static void getEnchantments(ItemStack itemStack, Object2IntMap> enchantments) { enchantments.clear(); if (!itemStack.isEmpty()) { - Set> itemEnchantments = itemStack.getItem() == Items.ENCHANTED_BOOK - ? itemStack.get(DataComponentTypes.STORED_ENCHANTMENTS).getEnchantments() - : itemStack.getEnchantments().getEnchantments(); + Set>> itemEnchantments = itemStack.getItem() == Items.ENCHANTED_BOOK + ? itemStack.get(DataComponentTypes.STORED_ENCHANTMENTS).getEnchantmentEntries() + : itemStack.getEnchantments().getEnchantmentEntries(); - for (RegistryEntry itemEnchantment : itemEnchantments) { - enchantments.put(itemEnchantment.value(), itemStack.getEnchantments().getLevel(itemEnchantment.value())); + for (Object2IntMap.Entry> entry : itemEnchantments) { + enchantments.put(entry.getKey(), entry.getIntValue()); } } } - public static boolean hasEnchantments(ItemStack itemStack, Enchantment... enchantments) { - if (itemStack.isEmpty()) return false; + public static int getEnchantmentLevel(ItemStack itemStack, RegistryKey enchantment) { + if (itemStack.isEmpty()) return 0; + Object2IntMap> itemEnchantments = new Object2IntArrayMap<>(); + getEnchantments(itemStack, itemEnchantments); + return getEnchantmentLevel(itemEnchantments, enchantment); + } + + public static int getEnchantmentLevel(Object2IntMap> itemEnchantments, RegistryKey enchantment) { + for (Object2IntMap.Entry> entry : Object2IntMaps.fastIterable(itemEnchantments)) { + if (entry.getKey().matchesKey(enchantment)) return entry.getIntValue(); + } + return 0; + } - Object2IntMap itemEnchantments = new Object2IntArrayMap<>(); + @SafeVarargs + public static boolean hasEnchantments(ItemStack itemStack, RegistryKey... enchantments) { + if (itemStack.isEmpty()) return false; + Object2IntMap> itemEnchantments = new Object2IntArrayMap<>(); getEnchantments(itemStack, itemEnchantments); - for (Enchantment enchantment : enchantments) if (!itemEnchantments.containsKey(enchantment)) return false; + for (RegistryKey enchantment : enchantments) { + if (!hasEnchantment(itemEnchantments, enchantment)) return false; + } return true; } + public static boolean hasEnchantment(ItemStack itemStack, RegistryKey enchantmentKey) { + if (itemStack.isEmpty()) return false; + Object2IntMap> itemEnchantments = new Object2IntArrayMap<>(); + getEnchantments(itemStack, itemEnchantments); + return hasEnchantment(itemEnchantments, enchantmentKey); + } + + private static boolean hasEnchantment(Object2IntMap> itemEnchantments, RegistryKey enchantmentKey) { + for (RegistryEntry enchantment : itemEnchantments.keySet()) { + if (enchantment.matchesKey(enchantmentKey)) return true; + } + return false; + } + public static int getRenderDistance() { return Math.max(mc.options.getViewDistance().getValue(), ((ClientPlayNetworkHandlerAccessor) mc.getNetworkHandler()).getChunkLoadDistance()); } @@ -249,8 +277,8 @@ public static Color getShulkerColor(ItemStack shulkerItem) { if (block instanceof ShulkerBoxBlock shulkerBlock) { DyeColor dye = shulkerBlock.getColor(); if (dye == null) return WHITE; - final float[] colors = dye.getColorComponents(); - return new Color(colors[0], colors[1], colors[2], 1f); + final int color = dye.getEntityColor(); + return new Color((color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF, 1f); } } return WHITE; @@ -268,8 +296,8 @@ public static Reference2IntMap createStatusEffectMap() { return new Reference2IntArrayMap<>(StatusEffectAmplifierMapSetting.EMPTY_STATUS_EFFECT_MAP); } - public static String getEnchantSimpleName(Enchantment enchantment, int length) { - String name = I18n.translate(enchantment.getTranslationKey()); + public static String getEnchantSimpleName(RegistryEntry enchantment, int length) { + String name = Names.get(enchantment); return name.length() > length ? name.substring(0, length) : name; } @@ -508,7 +536,7 @@ public static boolean isThrowable(Item item) { return item instanceof ExperienceBottleItem || item instanceof BowItem || item instanceof CrossbowItem || item instanceof SnowballItem || item instanceof EggItem || item instanceof EnderPearlItem || item instanceof SplashPotionItem || item instanceof LingeringPotionItem || item instanceof FishingRodItem || item instanceof TridentItem; } - public static void addEnchantment(ItemStack itemStack, Enchantment enchantment, int level) { + public static void addEnchantment(ItemStack itemStack, RegistryEntry enchantment, int level) { ItemEnchantmentsComponent.Builder b = new ItemEnchantmentsComponent.Builder(EnchantmentHelper.getEnchantments(itemStack)); b.add(enchantment, level); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/DamageUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/DamageUtils.java index fe0a0d2855..e2f65ee36b 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/DamageUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/entity/DamageUtils.java @@ -9,7 +9,6 @@ import meteordevelopment.meteorclient.utils.player.PlayerUtils; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.*; import net.minecraft.entity.attribute.*; import net.minecraft.entity.damage.DamageSource; @@ -136,10 +135,11 @@ public static RaycastFactory getOverridingHitFactory(BlockPos overridePos, Block */ public static float getAttackDamage(LivingEntity attacker, LivingEntity target) { float itemDamage = (float) attacker.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE); + DamageSource damageSource = attacker instanceof PlayerEntity player ? mc.world.getDamageSources().playerAttack(player) : mc.world.getDamageSources().mobAttack(attacker); // Get enchant damage - ItemStack stack = attacker.getStackInHand(attacker.getActiveHand()); - float enchantDamage = EnchantmentHelper.getAttackDamage(stack, target.getType()); + ItemStack stack = attacker.getWeaponStack(); + float enchantDamage = /*fixme EnchantmentHelper.getDamage(attacker.getWorld() instanceof ServerWorld serverWorld ? serverWorld : null, stack, target, damageSource, itemDamage) - itemDamage*/ 0; // Factor charge if (attacker instanceof PlayerEntity playerEntity) { @@ -155,12 +155,7 @@ public static float getAttackDamage(LivingEntity attacker, LivingEntity target) float damage = itemDamage + enchantDamage; - damage = calculateReductions(damage, target, attacker instanceof PlayerEntity player ? mc.world.getDamageSources().playerAttack(player) : mc.world.getDamageSources().mobAttack(attacker)); - - // Factor Fire Aspect - if (EnchantmentHelper.getFireAspect(attacker) > 0 && !target.hasStatusEffect(StatusEffects.FIRE_RESISTANCE)) { - damage++; - } + damage = calculateReductions(damage, target, damageSource); return damage; } @@ -207,7 +202,7 @@ public static float calculateReductions(float damage, LivingEntity entity, Damag } // Armor reduction - damage = DamageUtil.getDamageLeft(damage, damageSource, getArmor(entity), (float) entity.getAttributeValue(EntityAttributes.GENERIC_ARMOR_TOUGHNESS)); + damage = DamageUtil.getDamageLeft(entity, damage, damageSource, getArmor(entity), (float) entity.getAttributeValue(EntityAttributes.GENERIC_ARMOR_TOUGHNESS)); // Resistance reduction damage = resistanceReduction(entity, damage); @@ -226,8 +221,8 @@ private static float getArmor(LivingEntity entity) { * @see LivingEntity#modifyAppliedDamage(DamageSource, float) */ private static float protectionReduction(LivingEntity player, float damage, DamageSource source) { - int protLevel = EnchantmentHelper.getProtectionAmount(player.getArmorItems(), source); - return DamageUtil.getInflictedDamage(damage, protLevel); + //fixme float protLevel = EnchantmentHelper.getProtectionAmount(player.getWorld() instanceof ServerWorld serverWorld ? serverWorld : null, player, source); + return DamageUtil.getInflictedDamage(damage, /*protLevel*/ 0); } /** diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/ComponentMapReader.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/ComponentMapReader.java index 2ed916302c..950ffff52c 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/ComponentMapReader.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/ComponentMapReader.java @@ -18,7 +18,7 @@ import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.CommandSource; import net.minecraft.component.ComponentMap; -import net.minecraft.component.DataComponentType; +import net.minecraft.component.ComponentType; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.StringNbtReader; @@ -88,11 +88,11 @@ public ComponentMap read() throws CommandSyntaxException { reader.expect('['); suggestor = this::suggestComponentType; - Set> set = new ReferenceArraySet<>(); + Set> set = new ReferenceArraySet<>(); while(reader.canRead() && reader.peek() != ']') { reader.skipWhitespace(); - DataComponentType dataComponentType = readComponentType(reader); + ComponentType dataComponentType = readComponentType(reader); if (!set.add(dataComponentType)) { throw REPEATED_COMPONENT_EXCEPTION.create(dataComponentType); } @@ -123,13 +123,13 @@ public ComponentMap read() throws CommandSyntaxException { return builder.build(); } - public static DataComponentType readComponentType(StringReader reader) throws CommandSyntaxException { + public static ComponentType readComponentType(StringReader reader) throws CommandSyntaxException { if (!reader.canRead()) { throw COMPONENT_EXPECTED_EXCEPTION.createWithContext(reader); } else { int i = reader.getCursor(); Identifier identifier = Identifier.fromCommandInput(reader); - DataComponentType dataComponentType = Registries.DATA_COMPONENT_TYPE.get(identifier); + ComponentType dataComponentType = Registries.DATA_COMPONENT_TYPE.get(identifier); if (dataComponentType != null && !dataComponentType.shouldSkipSerialization()) { return dataComponentType; } else { @@ -142,7 +142,7 @@ public static DataComponentType readComponentType(StringReader reader) throws private CompletableFuture suggestComponentType(SuggestionsBuilder builder) { String string = builder.getRemaining().toLowerCase(Locale.ROOT); CommandSource.forEachMatching(Registries.DATA_COMPONENT_TYPE.getEntrySet(), string, entry -> entry.getKey().getValue(), entry -> { - DataComponentType dataComponentType = entry.getValue(); + ComponentType dataComponentType = entry.getValue(); if (dataComponentType.getCodec() != null) { Identifier identifier = entry.getKey().getValue(); builder.suggest(identifier.toString() + "="); @@ -151,7 +151,7 @@ private CompletableFuture suggestComponentType(SuggestionsBuilder b return builder.buildFuture(); } - private void readComponentValue(StringReader reader, ComponentMap.Builder builder, DataComponentType type) throws CommandSyntaxException { + private void readComponentValue(StringReader reader, ComponentMap.Builder builder, ComponentType type) throws CommandSyntaxException { int i = reader.getCursor(); NbtElement nbtElement = new StringNbtReader(reader).parseElement(); DataResult dataResult = type.getCodecOrThrow().parse(this.nbtOps, nbtElement); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/FakeClientPlayer.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/FakeClientPlayer.java index db117d1fab..163e09151f 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/FakeClientPlayer.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/FakeClientPlayer.java @@ -44,7 +44,7 @@ public static PlayerEntity getPlayer() { if (player == null || (!id.equals(lastId))) { if (world == null) { world = new ClientWorld( - new ClientPlayNetworkHandler(mc, new ClientConnection(NetworkSide.CLIENTBOUND), new ClientConnectionState(new GameProfile(mc.getSession().getUuidOrNull(), mc.getSession().getUsername()), null, null, null, null, mc.getCurrentServerEntry(), null, null, null, false)), + new ClientPlayNetworkHandler(mc, new ClientConnection(NetworkSide.CLIENTBOUND), new ClientConnectionState(new GameProfile(mc.getSession().getUuidOrNull(), mc.getSession().getUsername()), null, null, null, null, mc.getCurrentServerEntry(), null, null, null, false, null, null)), new ClientWorld.Properties(Difficulty.NORMAL, false, false), world.getRegistryKey(), world.getDimensionEntry(), diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorIdentifier.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorIdentifier.java deleted file mode 100644 index 513215cf9f..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorIdentifier.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.utils.misc; - -import meteordevelopment.meteorclient.MeteorClient; -import net.minecraft.util.Identifier; - -public class MeteorIdentifier extends Identifier { - public MeteorIdentifier(String path) { - super(MeteorClient.MOD_ID, path); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorStarscript.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorStarscript.java index ecb8802c57..1f8d352ea4 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorStarscript.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/MeteorStarscript.java @@ -584,7 +584,7 @@ private static Value crosshairValue() { public static Identifier popIdentifier(Starscript ss, String errorMessage) { try { - return new Identifier(ss.popString(errorMessage)); + return Identifier.of(ss.popString(errorMessage)); } catch (InvalidIdentifierException e) { ss.error(e.getMessage()); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/misc/Names.java b/src/main/java/meteordevelopment/meteorclient/utils/misc/Names.java index cd84260b38..eb569cfc82 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/misc/Names.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/misc/Names.java @@ -11,6 +11,8 @@ import meteordevelopment.meteorclient.utils.PreInit; import meteordevelopment.orbit.EventHandler; import net.minecraft.block.Block; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.resource.language.I18n; import net.minecraft.client.sound.WeightedSoundSet; import net.minecraft.enchantment.Enchantment; @@ -21,6 +23,9 @@ import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleType; import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.StringHelper; @@ -28,6 +33,8 @@ import java.util.HashMap; import java.util.Map; +import java.util.Optional; +import java.util.WeakHashMap; import static meteordevelopment.meteorclient.MeteorClient.mc; @@ -35,7 +42,8 @@ public class Names { private static final Map statusEffectNames = new Reference2ObjectOpenHashMap<>(16); private static final Map itemNames = new Reference2ObjectOpenHashMap<>(128); private static final Map blockNames = new Reference2ObjectOpenHashMap<>(128); - private static final Map enchantmentNames = new Reference2ObjectOpenHashMap<>(16); + private static final Map, String> enchantmentKeyNames = new WeakHashMap<>(16); + private static final Map, String> enchantmentEntryNames = new Reference2ObjectOpenHashMap<>(16); private static final Map, String> entityTypeNames = new Reference2ObjectOpenHashMap<>(64); private static final Map, String> particleTypesNames = new Reference2ObjectOpenHashMap<>(64); private static final Map soundNames = new HashMap<>(64); @@ -53,7 +61,7 @@ private static void onResourcePacksReloaded(ResourcePacksReloadedEvent event) { statusEffectNames.clear(); itemNames.clear(); blockNames.clear(); - enchantmentNames.clear(); + enchantmentEntryNames.clear(); entityTypeNames.clear(); particleTypesNames.clear(); soundNames.clear(); @@ -71,8 +79,26 @@ public static String get(Block block) { return blockNames.computeIfAbsent(block, block1 -> StringHelper.stripTextFormat(I18n.translate(block1.getTranslationKey()))); } - public static String get(Enchantment enchantment) { - return enchantmentNames.computeIfAbsent(enchantment, enchantment1 -> StringHelper.stripTextFormat(I18n.translate(enchantment1.getTranslationKey()))); + /** + * key -> entry, else key -> translation, else key -> identifier toString() + * @author Crosby + */ + @SuppressWarnings("StringEquality") + public static String get(RegistryKey enchantment) { + return enchantmentKeyNames.computeIfAbsent(enchantment, enchantment1 -> Optional.ofNullable(MinecraftClient.getInstance().getNetworkHandler()) + .map(ClientPlayNetworkHandler::getRegistryManager) + .flatMap(registryManager -> registryManager.getOptional(RegistryKeys.ENCHANTMENT)) + .flatMap(registry -> registry.getEntry(enchantment)) + .map(Names::get) + .orElseGet(() -> { + String key = "enchantment." + enchantment1.getValue().toTranslationKey(); + String translated = I18n.translate(key); + return translated == key ? enchantment1.getValue().toString() : translated; + })); + } + + public static String get(RegistryEntry enchantment) { + return enchantmentEntryNames.computeIfAbsent(enchantment, enchantment1 -> StringHelper.stripTextFormat(enchantment.value().description().getString())); } public static String get(EntityType entityType) { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/network/Capes.java b/src/main/java/meteordevelopment/meteorclient/utils/network/Capes.java index 36020a2b15..372f296374 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/network/Capes.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/network/Capes.java @@ -8,7 +8,6 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.utils.PreInit; -import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; import meteordevelopment.orbit.EventHandler; import net.minecraft.client.texture.NativeImage; import net.minecraft.client.texture.NativeImageBackedTexture; @@ -101,7 +100,7 @@ public static Identifier get(PlayerEntity player) { Cape cape = TEXTURES.get(capeName); if (cape == null) return null; - if (cape.isDownloaded()) return cape; + if (cape.isDownloaded()) return cape.getIdentifier(); cape.download(); return null; @@ -110,10 +109,11 @@ public static Identifier get(PlayerEntity player) { return null; } - private static class Cape extends MeteorIdentifier { + private static class Cape { private static int COUNT = 0; private final String name; + private final Identifier identifier; private boolean downloaded; private boolean downloading; @@ -123,11 +123,14 @@ private static class Cape extends MeteorIdentifier { private int retryTimer; public Cape(String name) { - super("capes/" + COUNT++); - + this.identifier = MeteorClient.identifier("capes/" + COUNT++); this.name = name; } + public Identifier getIdentifier() { + return identifier; + } + public void download() { if (downloaded || downloading || retryTimer > 0) return; downloading = true; @@ -165,7 +168,7 @@ public void download() { } public void register() { - mc.getTextureManager().registerTexture(this, new NativeImageBackedTexture(img)); + mc.getTextureManager().registerTexture(identifier, new NativeImageBackedTexture(img)); img = null; downloading = false; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtils.java index 37e406956c..9a014f2705 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtils.java @@ -7,7 +7,9 @@ import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Lifecycle; -import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; +import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap; +import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; +import meteordevelopment.meteorclient.MeteorClient; import net.minecraft.network.packet.Packet; import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; @@ -24,11 +26,11 @@ public class PacketUtils { public static final Registry>> REGISTRY = new PacketRegistry(); - private static final Map>, String> S2C_PACKETS = new HashMap<>(); - private static final Map>, String> C2S_PACKETS = new HashMap<>(); + private static final Map>, String> S2C_PACKETS = new Reference2ObjectOpenHashMap<>(); + private static final Map>, String> C2S_PACKETS = new Reference2ObjectOpenHashMap<>(); - private static final Map>> S2C_PACKETS_R = new HashMap<>(); - private static final Map>> C2S_PACKETS_R = new HashMap<>(); + private static final Map>> S2C_PACKETS_R = new Object2ReferenceOpenHashMap<>(); + private static final Map>> C2S_PACKETS_R = new Object2ReferenceOpenHashMap<>(); static { C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.ClientStatusC2SPacket.class, "ClientStatusC2SPacket"); @@ -37,10 +39,10 @@ public class PacketUtils { C2S_PACKETS_R.put("PlayerInteractItemC2SPacket", net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.login.EnterConfigurationC2SPacket.class, "EnterConfigurationC2SPacket"); C2S_PACKETS_R.put("EnterConfigurationC2SPacket", net.minecraft.network.packet.c2s.login.EnterConfigurationC2SPacket.class); - C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.SelectMerchantTradeC2SPacket.class, "SelectMerchantTradeC2SPacket"); - C2S_PACKETS_R.put("SelectMerchantTradeC2SPacket", net.minecraft.network.packet.c2s.play.SelectMerchantTradeC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket.class, "PlayerActionC2SPacket"); C2S_PACKETS_R.put("PlayerActionC2SPacket", net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket.class); + C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.SelectMerchantTradeC2SPacket.class, "SelectMerchantTradeC2SPacket"); + C2S_PACKETS_R.put("SelectMerchantTradeC2SPacket", net.minecraft.network.packet.c2s.play.SelectMerchantTradeC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket.class, "CommandExecutionC2SPacket"); C2S_PACKETS_R.put("CommandExecutionC2SPacket", net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket.class); C2S_PACKETS.put(net.minecraft.network.packet.c2s.play.RenameItemC2SPacket.class, "RenameItemC2SPacket"); @@ -246,10 +248,10 @@ public class PacketUtils { S2C_PACKETS_R.put("CooldownUpdateS2CPacket", net.minecraft.network.packet.s2c.play.CooldownUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket.class, "OpenScreenS2CPacket"); S2C_PACKETS_R.put("OpenScreenS2CPacket", net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket.class, "EntityAnimationS2CPacket"); - S2C_PACKETS_R.put("EntityAnimationS2CPacket", net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ExperienceOrbSpawnS2CPacket.class, "ExperienceOrbSpawnS2CPacket"); S2C_PACKETS_R.put("ExperienceOrbSpawnS2CPacket", net.minecraft.network.packet.s2c.play.ExperienceOrbSpawnS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket.class, "EntityAnimationS2CPacket"); + S2C_PACKETS_R.put("EntityAnimationS2CPacket", net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket.class, "PlayerAbilitiesS2CPacket"); S2C_PACKETS_R.put("PlayerAbilitiesS2CPacket", net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.config.ResetChatS2CPacket.class, "ResetChatS2CPacket"); @@ -260,8 +262,6 @@ public class PacketUtils { S2C_PACKETS_R.put("EntitiesDestroyS2CPacket", net.minecraft.network.packet.s2c.play.EntitiesDestroyS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket.class, "PlayerRemoveS2CPacket"); S2C_PACKETS_R.put("PlayerRemoveS2CPacket", net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.UnlockRecipesS2CPacket.class, "UnlockRecipesS2CPacket"); - S2C_PACKETS_R.put("UnlockRecipesS2CPacket", net.minecraft.network.packet.s2c.play.UnlockRecipesS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.LightUpdateS2CPacket.class, "LightUpdateS2CPacket"); S2C_PACKETS_R.put("LightUpdateS2CPacket", net.minecraft.network.packet.s2c.play.LightUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket.class, "OverlayMessageS2CPacket"); @@ -296,14 +296,16 @@ public class PacketUtils { S2C_PACKETS_R.put("DeathMessageS2CPacket", net.minecraft.network.packet.s2c.play.DeathMessageS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.MapUpdateS2CPacket.class, "MapUpdateS2CPacket"); S2C_PACKETS_R.put("MapUpdateS2CPacket", net.minecraft.network.packet.s2c.play.MapUpdateS2CPacket.class); - S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket.class, "BlockEntityUpdateS2CPacket"); - S2C_PACKETS_R.put("BlockEntityUpdateS2CPacket", net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket.class, "ScreenHandlerSlotUpdateS2CPacket"); S2C_PACKETS_R.put("ScreenHandlerSlotUpdateS2CPacket", net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket.class, "BlockEntityUpdateS2CPacket"); + S2C_PACKETS_R.put("BlockEntityUpdateS2CPacket", net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlayerSpawnPositionS2CPacket.class, "PlayerSpawnPositionS2CPacket"); S2C_PACKETS_R.put("PlayerSpawnPositionS2CPacket", net.minecraft.network.packet.s2c.play.PlayerSpawnPositionS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.EntityStatusEffectS2CPacket.class, "EntityStatusEffectS2CPacket"); S2C_PACKETS_R.put("EntityStatusEffectS2CPacket", net.minecraft.network.packet.s2c.play.EntityStatusEffectS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.common.CustomReportDetailsS2CPacket.class, "CustomReportDetailsS2CPacket"); + S2C_PACKETS_R.put("CustomReportDetailsS2CPacket", net.minecraft.network.packet.s2c.common.CustomReportDetailsS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ClearTitleS2CPacket.class, "ClearTitleS2CPacket"); S2C_PACKETS_R.put("ClearTitleS2CPacket", net.minecraft.network.packet.s2c.play.ClearTitleS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.login.LoginCompressionS2CPacket.class, "LoginCompressionS2CPacket"); @@ -334,10 +336,14 @@ public class PacketUtils { S2C_PACKETS_R.put("EntityDamageS2CPacket", net.minecraft.network.packet.s2c.play.EntityDamageS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ChatMessageS2CPacket.class, "ChatMessageS2CPacket"); S2C_PACKETS_R.put("ChatMessageS2CPacket", net.minecraft.network.packet.s2c.play.ChatMessageS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.common.ServerLinksS2CPacket.class, "ServerLinksS2CPacket"); + S2C_PACKETS_R.put("ServerLinksS2CPacket", net.minecraft.network.packet.s2c.common.ServerLinksS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.common.KeepAliveS2CPacket.class, "KeepAliveS2CPacket"); S2C_PACKETS_R.put("KeepAliveS2CPacket", net.minecraft.network.packet.s2c.common.KeepAliveS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.OpenWrittenBookS2CPacket.class, "OpenWrittenBookS2CPacket"); S2C_PACKETS_R.put("OpenWrittenBookS2CPacket", net.minecraft.network.packet.s2c.play.OpenWrittenBookS2CPacket.class); + S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.ChangeUnlockedRecipesS2CPacket.class, "ChangeUnlockedRecipesS2CPacket"); + S2C_PACKETS_R.put("ChangeUnlockedRecipesS2CPacket", net.minecraft.network.packet.s2c.play.ChangeUnlockedRecipesS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.common.ResourcePackRemoveS2CPacket.class, "ResourcePackRemoveS2CPacket"); S2C_PACKETS_R.put("ResourcePackRemoveS2CPacket", net.minecraft.network.packet.s2c.common.ResourcePackRemoveS2CPacket.class); S2C_PACKETS.put(net.minecraft.network.packet.s2c.play.PlaySoundFromEntityS2CPacket.class, "PlaySoundFromEntityS2CPacket"); @@ -463,7 +469,7 @@ public static Set>> getC2SPackets() { private static class PacketRegistry extends SimpleRegistry>> { public PacketRegistry() { - super(RegistryKey.ofRegistry(new MeteorIdentifier("packets")), Lifecycle.stable()); + super(RegistryKey.ofRegistry(MeteorClient.identifier("packets")), Lifecycle.stable()); } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtilsUtil.java b/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtilsUtil.java index 2c983f232a..a1c7327cb8 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtilsUtil.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/network/PacketUtilsUtil.java @@ -6,6 +6,7 @@ package meteordevelopment.meteorclient.utils.network; import net.minecraft.network.packet.BundlePacket; +import net.minecraft.network.packet.BundleSplitterPacket; import net.minecraft.network.packet.Packet; import org.reflections.Reflections; import org.reflections.scanners.Scanners; @@ -20,7 +21,7 @@ public class PacketUtilsUtil { private static final String packetRegistryClass = """ private static class PacketRegistry extends SimpleRegistry>> { public PacketRegistry() { - super(RegistryKey.ofRegistry(new MeteorIdentifier("packets")), Lifecycle.stable()); + super(RegistryKey.ofRegistry(MeteorClient.identifier("packets")), Lifecycle.stable()); } @Override @@ -183,7 +184,9 @@ public static void init() throws IOException { // Write imports writer.write("import com.mojang.datafixers.util.Pair;\n"); writer.write("import com.mojang.serialization.Lifecycle;\n"); - writer.write("import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier;\n"); + writer.write("import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap;\n"); + writer.write("import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;\n"); + writer.write("import meteordevelopment.meteorclient.MeteorClient;\n"); writer.write("import net.minecraft.network.packet.Packet;\n"); writer.write("import net.minecraft.registry.Registry;\n"); writer.write("import net.minecraft.registry.RegistryKey;\n"); @@ -203,10 +206,10 @@ public static void init() throws IOException { // Write fields writer.write(" public static final Registry>> REGISTRY = new PacketRegistry();\n\n"); - writer.write(" private static final Map>, String> S2C_PACKETS = new HashMap<>();\n"); - writer.write(" private static final Map>, String> C2S_PACKETS = new HashMap<>();\n\n"); - writer.write(" private static final Map>> S2C_PACKETS_R = new HashMap<>();\n"); - writer.write(" private static final Map>> C2S_PACKETS_R = new HashMap<>();\n\n"); + writer.write(" private static final Map>, String> S2C_PACKETS = new Reference2ObjectOpenHashMap<>();\n"); + writer.write(" private static final Map>, String> C2S_PACKETS = new Reference2ObjectOpenHashMap<>();\n\n"); + writer.write(" private static final Map>> S2C_PACKETS_R = new Object2ReferenceOpenHashMap<>();\n"); + writer.write(" private static final Map>> C2S_PACKETS_R = new Object2ReferenceOpenHashMap<>();\n\n"); // Write static block writer.write(" static {\n"); @@ -231,7 +234,7 @@ public static void init() throws IOException { Set> s2cPackets = s2c.getSubTypesOf(Packet.class); for (Class s2cPacket : s2cPackets) { - if (s2cPacket == BundlePacket.class) continue; + if (s2cPacket == BundlePacket.class || s2cPacket == BundleSplitterPacket.class) continue; String name = s2cPacket.getName(); String className = name.substring(name.lastIndexOf('.') + 1).replace('$', '.'); String fullName = name.replace('$', '.'); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/NotebotUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/NotebotUtils.java index e0383f20c0..2491f894f5 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/notebot/NotebotUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/NotebotUtils.java @@ -9,7 +9,7 @@ import meteordevelopment.meteorclient.utils.notebot.song.Note; import net.minecraft.block.BlockState; import net.minecraft.block.NoteBlock; -import net.minecraft.block.enums.Instrument; +import net.minecraft.block.enums.NoteBlockInstrument; import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.Nullable; @@ -19,7 +19,7 @@ public class NotebotUtils { public static Note getNoteFromNoteBlock(BlockState noteBlock, BlockPos blockPos, NotebotMode mode, InstrumentDetectFunction instrumentDetectFunction) { - Instrument instrument = null; + NoteBlockInstrument instrument = null; int level = noteBlock.get(NoteBlock.NOTE); if (mode == NotebotMode.ExactInstruments) { instrument = instrumentDetectFunction.detectInstrument(noteBlock, blockPos); @@ -34,24 +34,24 @@ public enum NotebotMode { public enum OptionalInstrument { None(null), - Harp(Instrument.HARP), - Basedrum(Instrument.BASEDRUM), - Snare(Instrument.SNARE), - Hat(Instrument.HAT), - Bass(Instrument.BASS), - Flute(Instrument.FLUTE), - Bell(Instrument.BELL), - Guitar(Instrument.GUITAR), - Chime(Instrument.CHIME), - Xylophone(Instrument.XYLOPHONE), - IronXylophone(Instrument.IRON_XYLOPHONE), - CowBell(Instrument.COW_BELL), - Didgeridoo(Instrument.DIDGERIDOO), - Bit(Instrument.BIT), - Banjo(Instrument.BANJO), - Pling(Instrument.PLING) + Harp(NoteBlockInstrument.HARP), + Basedrum(NoteBlockInstrument.BASEDRUM), + Snare(NoteBlockInstrument.SNARE), + Hat(NoteBlockInstrument.HAT), + Bass(NoteBlockInstrument.BASS), + Flute(NoteBlockInstrument.FLUTE), + Bell(NoteBlockInstrument.BELL), + Guitar(NoteBlockInstrument.GUITAR), + Chime(NoteBlockInstrument.CHIME), + Xylophone(NoteBlockInstrument.XYLOPHONE), + IronXylophone(NoteBlockInstrument.IRON_XYLOPHONE), + CowBell(NoteBlockInstrument.COW_BELL), + Didgeridoo(NoteBlockInstrument.DIDGERIDOO), + Bit(NoteBlockInstrument.BIT), + Banjo(NoteBlockInstrument.BANJO), + Pling(NoteBlockInstrument.PLING) ; - public static final Map BY_MINECRAFT_INSTRUMENT = new HashMap<>(); + public static final Map BY_MINECRAFT_INSTRUMENT = new HashMap<>(); static { for (OptionalInstrument optionalInstrument : values()) { @@ -59,17 +59,17 @@ public enum OptionalInstrument { } } - private final Instrument minecraftInstrument; + private final NoteBlockInstrument minecraftInstrument; - OptionalInstrument(@Nullable Instrument minecraftInstrument) { + OptionalInstrument(@Nullable NoteBlockInstrument minecraftInstrument) { this.minecraftInstrument = minecraftInstrument; } - public Instrument toMinecraftInstrument() { + public NoteBlockInstrument toMinecraftInstrument() { return minecraftInstrument; } - public static OptionalInstrument fromMinecraftInstrument(Instrument instrument) { + public static OptionalInstrument fromMinecraftInstrument(NoteBlockInstrument instrument) { if (instrument != null) { return BY_MINECRAFT_INSTRUMENT.get(instrument); } else { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/NBSSongDecoder.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/NBSSongDecoder.java index 222cd5991e..c0ad563bc0 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/NBSSongDecoder.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/NBSSongDecoder.java @@ -9,7 +9,7 @@ import com.google.common.collect.MultimapBuilder; import meteordevelopment.meteorclient.utils.notebot.song.Note; import meteordevelopment.meteorclient.utils.notebot.song.Song; -import net.minecraft.block.enums.Instrument; +import net.minecraft.block.enums.NoteBlockInstrument; import org.jetbrains.annotations.NotNull; import java.io.*; @@ -103,7 +103,7 @@ private Song parse(InputStream inputStream) throws Exception { readShort(dataInputStream); // note block pitch } - Instrument inst = fromNBSInstrument(instrument); + NoteBlockInstrument inst = fromNBSInstrument(instrument); // Probably a custom instrument. Ignore this note if (inst == null) continue; @@ -161,24 +161,24 @@ private static String readString(DataInputStream dataInputStream) throws IOExcep } // Magic Values (https://opennbs.org/nbs) - private static Instrument fromNBSInstrument(int instrument) { + private static NoteBlockInstrument fromNBSInstrument(int instrument) { return switch (instrument) { - case 0 -> Instrument.HARP; - case 1 -> Instrument.BASS; - case 2 -> Instrument.BASEDRUM; - case 3 -> Instrument.SNARE; - case 4 -> Instrument.HAT; - case 5 -> Instrument.GUITAR; - case 6 -> Instrument.FLUTE; - case 7 -> Instrument.BELL; - case 8 -> Instrument.CHIME; - case 9 -> Instrument.XYLOPHONE; - case 10 -> Instrument.IRON_XYLOPHONE; - case 11 -> Instrument.COW_BELL; - case 12 -> Instrument.DIDGERIDOO; - case 13 -> Instrument.BIT; - case 14 -> Instrument.BANJO; - case 15 -> Instrument.PLING; + case 0 -> NoteBlockInstrument.HARP; + case 1 -> NoteBlockInstrument.BASS; + case 2 -> NoteBlockInstrument.BASEDRUM; + case 3 -> NoteBlockInstrument.SNARE; + case 4 -> NoteBlockInstrument.HAT; + case 5 -> NoteBlockInstrument.GUITAR; + case 6 -> NoteBlockInstrument.FLUTE; + case 7 -> NoteBlockInstrument.BELL; + case 8 -> NoteBlockInstrument.CHIME; + case 9 -> NoteBlockInstrument.XYLOPHONE; + case 10 -> NoteBlockInstrument.IRON_XYLOPHONE; + case 11 -> NoteBlockInstrument.COW_BELL; + case 12 -> NoteBlockInstrument.DIDGERIDOO; + case 13 -> NoteBlockInstrument.BIT; + case 14 -> NoteBlockInstrument.BANJO; + case 15 -> NoteBlockInstrument.PLING; default -> null; }; } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/SongDecoders.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/SongDecoders.java index 2233b3bc6c..6404610394 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/SongDecoders.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/SongDecoders.java @@ -10,7 +10,7 @@ import meteordevelopment.meteorclient.utils.notebot.NotebotUtils; import meteordevelopment.meteorclient.utils.notebot.song.Note; import meteordevelopment.meteorclient.utils.notebot.song.Song; -import net.minecraft.block.enums.Instrument; +import net.minecraft.block.enums.NoteBlockInstrument; import org.apache.commons.io.FilenameUtils; import org.jetbrains.annotations.NotNull; @@ -89,7 +89,7 @@ private static void fixSong(Song song) { } if (notebot.mode.get() == NotebotUtils.NotebotMode.ExactInstruments) { - Instrument newInstrument = notebot.getMappedInstrument(note.getInstrument()); + NoteBlockInstrument newInstrument = notebot.getMappedInstrument(note.getInstrument()); if (newInstrument != null) { note.setInstrument(newInstrument); } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/TextSongDecoder.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/TextSongDecoder.java index cfe0be8233..f629360e59 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/TextSongDecoder.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/decoder/TextSongDecoder.java @@ -9,7 +9,7 @@ import com.google.common.collect.MultimapBuilder; import meteordevelopment.meteorclient.utils.notebot.song.Note; import meteordevelopment.meteorclient.utils.notebot.song.Song; -import net.minecraft.block.enums.Instrument; +import net.minecraft.block.enums.NoteBlockInstrument; import org.apache.commons.io.FilenameUtils; import java.io.File; @@ -57,7 +57,7 @@ public Song parse(File file) throws Exception { continue; } - Note note = new Note(Instrument.values()[type], val); + Note note = new Note(NoteBlockInstrument.values()[type], val); notesMap.put(key, note); } return new Song(notesMap, title, author); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/instrumentdetect/InstrumentDetectFunction.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/instrumentdetect/InstrumentDetectFunction.java index 96a6fbfe15..e554e80dab 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/notebot/instrumentdetect/InstrumentDetectFunction.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/instrumentdetect/InstrumentDetectFunction.java @@ -6,7 +6,7 @@ package meteordevelopment.meteorclient.utils.notebot.instrumentdetect; import net.minecraft.block.BlockState; -import net.minecraft.block.enums.Instrument; +import net.minecraft.block.enums.NoteBlockInstrument; import net.minecraft.util.math.BlockPos; public interface InstrumentDetectFunction { @@ -17,5 +17,5 @@ public interface InstrumentDetectFunction { * @param blockPos Noteblock position * @return Detected instrument */ - Instrument detectInstrument(BlockState noteBlock, BlockPos blockPos); + NoteBlockInstrument detectInstrument(BlockState noteBlock, BlockPos blockPos); } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/notebot/song/Note.java b/src/main/java/meteordevelopment/meteorclient/utils/notebot/song/Note.java index b6604b77c4..4fd87df501 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/notebot/song/Note.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/notebot/song/Note.java @@ -5,25 +5,25 @@ package meteordevelopment.meteorclient.utils.notebot.song; -import net.minecraft.block.enums.Instrument; +import net.minecraft.block.enums.NoteBlockInstrument; import java.util.Objects; public class Note { - private Instrument instrument; + private NoteBlockInstrument instrument; private int noteLevel; - public Note(Instrument instrument, int noteLevel) { + public Note(NoteBlockInstrument instrument, int noteLevel) { this.instrument = instrument; this.noteLevel = noteLevel; } - public Instrument getInstrument() { + public NoteBlockInstrument getInstrument() { return this.instrument; } - public void setInstrument(Instrument instrument) { + public void setInstrument(NoteBlockInstrument instrument) { this.instrument = instrument; } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/IVertexConsumerProvider.java b/src/main/java/meteordevelopment/meteorclient/utils/render/IVertexConsumerProvider.java index 9f991ad27a..4a41ab5e7c 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/IVertexConsumerProvider.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/IVertexConsumerProvider.java @@ -8,5 +8,5 @@ import net.minecraft.client.render.VertexConsumerProvider; public interface IVertexConsumerProvider extends VertexConsumerProvider { - void setOffset(double offsetX, double offsetY, double offsetZ); + void setOffset(float offsetX, float offsetY, float offsetZ); } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/MeshVertexConsumerProvider.java b/src/main/java/meteordevelopment/meteorclient/utils/render/MeshVertexConsumerProvider.java index fec0384191..b28366abf9 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/MeshVertexConsumerProvider.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/MeshVertexConsumerProvider.java @@ -27,18 +27,18 @@ public void setColor(Color color) { } @Override - public void setOffset(double offsetX, double offsetY, double offsetZ) { + public void setOffset(float offsetX, float offsetY, float offsetZ) { vertexConsumer.setOffset(offsetX, offsetY, offsetZ); } public static class MeshVertexConsumer implements VertexConsumer { private final Mesh mesh; - private double offsetX, offsetY, offsetZ; + private float offsetX, offsetY, offsetZ; - private final double[] xs = new double[4]; - private final double[] ys = new double[4]; - private final double[] zs = new double[4]; + private final float[] xs = new float[4]; + private final float[] ys = new float[4]; + private final float[] zs = new float[4]; private final Color color = new Color(); private int i; @@ -47,18 +47,29 @@ public MeshVertexConsumer(Mesh mesh) { this.mesh = mesh; } - public void setOffset(double offsetX, double offsetY, double offsetZ) { + public void setOffset(float offsetX, float offsetY, float offsetZ) { this.offsetX = offsetX; this.offsetY = offsetY; this.offsetZ = offsetZ; } @Override - public VertexConsumer vertex(double x, double y, double z) { + public VertexConsumer vertex(float x, float y, float z) { xs[i] = offsetX + x; ys[i] = offsetY + y; zs[i] = offsetZ + z; + if (++i >= 4) { + mesh.quad( + mesh.vec3(xs[0], ys[0], zs[0]).color(color).next(), + mesh.vec3(xs[1], ys[1], zs[1]).color(color).next(), + mesh.vec3(xs[2], ys[2], zs[2]).color(color).next(), + mesh.vec3(xs[3], ys[3], zs[3]).color(color).next() + ); + + i = 0; + } + return this; } @@ -87,26 +98,8 @@ public VertexConsumer normal(float x, float y, float z) { return null; } - @Override - public void next() { - if (++i >= 4) { - mesh.quad( - mesh.vec3(xs[0], ys[0], zs[0]).color(color).next(), - mesh.vec3(xs[1], ys[1], zs[1]).color(color).next(), - mesh.vec3(xs[2], ys[2], zs[2]).color(color).next(), - mesh.vec3(xs[3], ys[3], zs[3]).color(color).next() - ); - - i = 0; - } - } - - @Override public void fixedColor(int red, int green, int blue, int alpha) { color.set(red, green, blue, alpha); } - - @Override - public void unfixColor() {} } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/MeteorToast.java b/src/main/java/meteordevelopment/meteorclient/utils/render/MeteorToast.java index 731f31401d..277a94490a 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/MeteorToast.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/MeteorToast.java @@ -28,7 +28,7 @@ public class MeteorToast implements Toast { public static final int TITLE_COLOR = Color.fromRGBA(145, 61, 226, 255); public static final int TEXT_COLOR = Color.fromRGBA(220, 220, 220, 255); - private static final Identifier TEXTURE = new Identifier("textures/gui/sprites/toast/advancement.png"); + private static final Identifier TEXTURE = Identifier.of("textures/gui/sprites/toast/advancement.png"); private ItemStack icon; private Text title, text; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/PeekScreen.java b/src/main/java/meteordevelopment/meteorclient/utils/render/PeekScreen.java index 59de0030a1..5e546e6797 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/PeekScreen.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/PeekScreen.java @@ -25,7 +25,7 @@ import static meteordevelopment.meteorclient.MeteorClient.mc; public class PeekScreen extends ShulkerBoxScreen { - private final Identifier TEXTURE = new Identifier("textures/gui/container/shulker_box.png"); + private final Identifier TEXTURE = Identifier.of("textures/gui/container/shulker_box.png"); private final ItemStack[] contents; private final ItemStack storageBlock; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadTexture.java b/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadTexture.java index 34a451889d..455e6bae3b 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadTexture.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadTexture.java @@ -2,8 +2,8 @@ import com.mojang.blaze3d.platform.TextureUtil; import com.mojang.blaze3d.systems.RenderSystem; +import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.renderer.Texture; -import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; import meteordevelopment.meteorclient.utils.network.Http; import org.lwjgl.BufferUtils; import org.lwjgl.stb.STBImage; @@ -67,7 +67,7 @@ public PlayerHeadTexture(String url) { } public PlayerHeadTexture() { - try (InputStream inputStream = mc.getResourceManager().getResource(new MeteorIdentifier("textures/steve.png")).get().getInputStream()) { + try (InputStream inputStream = mc.getResourceManager().getResource(MeteorClient.identifier("textures/steve.png")).get().getInputStream()) { ByteBuffer data = TextureUtil.readResource(inputStream); data.rewind(); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/RenderUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/render/RenderUtils.java index b6896e02f8..1d255be2df 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/RenderUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/RenderUtils.java @@ -87,7 +87,7 @@ private static void bobView(MatrixStack matrices) { Entity cameraEntity = MinecraftClient.getInstance().getCameraEntity(); if (cameraEntity instanceof PlayerEntity playerEntity) { - float f = MinecraftClient.getInstance().getTickDelta(); + float f = mc.getRenderTickCounter().getTickDelta(true); float g = playerEntity.horizontalSpeed - playerEntity.prevHorizontalSpeed; float h = -(playerEntity.horizontalSpeed + g * f); float i = MathHelper.lerp(f, playerEntity.prevStrideDistance, playerEntity.strideDistance); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/SimpleBlockRenderer.java b/src/main/java/meteordevelopment/meteorclient/utils/render/SimpleBlockRenderer.java index dcd40f1e96..92fc06d2e5 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/SimpleBlockRenderer.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/SimpleBlockRenderer.java @@ -47,9 +47,9 @@ public static void render(BlockPos pos, BlockState state, VertexConsumerProvider BakedModel model = mc.getBlockRenderManager().getModel(state); Vec3d offset = state.getModelOffset(mc.world, pos); - double offsetX = pos.getX() + offset.x; - double offsetY = pos.getY() + offset.y; - double offsetZ = pos.getZ() + offset.z; + float offsetX = (float) (pos.getX() + offset.x); + float offsetY = (float) (pos.getY() + offset.y); + float offsetZ = (float) (pos.getZ() + offset.z); //noinspection ForLoopReplaceableByForEach for (int i = 0; i < DIRECTIONS.length; i++) { @@ -61,7 +61,7 @@ public static void render(BlockPos pos, BlockState state, VertexConsumerProvider if (!list.isEmpty()) renderQuads(list, offsetX, offsetY, offsetZ, consumer); } - private static void renderQuads(List quads, double offsetX, double offsetY, double offsetZ, VertexConsumer consumer) { + private static void renderQuads(List quads, float offsetX, float offsetY, float offsetZ, VertexConsumer consumer) { //noinspection ForLoopReplaceableByForEach for (int i = 0; i < quads.size(); i++) { IBakedQuad quad = (IBakedQuad) quads.get(i); @@ -71,7 +71,7 @@ private static void renderQuads(List quads, double offsetX, double of float y = quad.meteor$getY(j); float z = quad.meteor$getZ(j); - consumer.vertex(offsetX + x, offsetY + y, offsetZ + z).next(); + consumer.vertex(offsetX + x, offsetY + y, offsetZ + z); } } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/postprocess/ChamsShader.java b/src/main/java/meteordevelopment/meteorclient/utils/render/postprocess/ChamsShader.java index 1cd3ed1a26..e868c56d35 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/postprocess/ChamsShader.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/postprocess/ChamsShader.java @@ -12,7 +12,6 @@ import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.render.Chams; import meteordevelopment.meteorclient.utils.PostInit; -import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; import meteordevelopment.orbit.EventHandler; import net.minecraft.entity.Entity; import net.minecraft.resource.Resource; @@ -41,7 +40,7 @@ public static void load() { try { ByteBuffer data = null; for (String fileFormat : FILE_FORMATS) { - Optional optional = mc.getResourceManager().getResource(new MeteorIdentifier("textures/chams." + fileFormat)); + Optional optional = mc.getResourceManager().getResource(MeteorClient.identifier("textures/chams." + fileFormat)); if (optional.isEmpty() || optional.get().getInputStream() == null) { continue; } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/BookTooltipComponent.java b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/BookTooltipComponent.java index d484e305e9..feaef6575b 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/BookTooltipComponent.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/BookTooltipComponent.java @@ -16,7 +16,7 @@ import net.minecraft.util.Identifier; public class BookTooltipComponent implements TooltipComponent, MeteorTooltipData { - private static final Identifier TEXTURE_BOOK_BACKGROUND = new Identifier("textures/gui/book.png"); + private static final Identifier TEXTURE_BOOK_BACKGROUND = Identifier.of("textures/gui/book.png"); private final Text page; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/ContainerTooltipComponent.java b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/ContainerTooltipComponent.java index 21dd00aafc..13c964d520 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/ContainerTooltipComponent.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/ContainerTooltipComponent.java @@ -6,7 +6,7 @@ package meteordevelopment.meteorclient.utils.tooltip; import com.mojang.blaze3d.systems.RenderSystem; -import meteordevelopment.meteorclient.utils.misc.MeteorIdentifier; +import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.utils.render.RenderUtils; import meteordevelopment.meteorclient.utils.render.color.Color; import net.minecraft.client.font.TextRenderer; @@ -17,7 +17,7 @@ import net.minecraft.util.Identifier; public class ContainerTooltipComponent implements TooltipComponent, MeteorTooltipData { - private static final Identifier TEXTURE_CONTAINER_BACKGROUND = new MeteorIdentifier("textures/container.png"); + private static final Identifier TEXTURE_CONTAINER_BACKGROUND = MeteorClient.identifier("textures/container.png"); private final ItemStack[] items; private final Color color; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/MapTooltipComponent.java b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/MapTooltipComponent.java index ffbfbec6f2..651f8fe278 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/MapTooltipComponent.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/MapTooltipComponent.java @@ -22,7 +22,7 @@ import static meteordevelopment.meteorclient.MeteorClient.mc; public class MapTooltipComponent implements TooltipComponent, MeteorTooltipData { - private static final Identifier TEXTURE_MAP_BACKGROUND = new Identifier("textures/map/map_background.png"); + private static final Identifier TEXTURE_MAP_BACKGROUND = Identifier.of("textures/map/map_background.png"); private final int mapId; public MapTooltipComponent(int mapId) { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/MeteorTooltipData.java b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/MeteorTooltipData.java index 03bd6b6429..c23ae5ed4d 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/tooltip/MeteorTooltipData.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/tooltip/MeteorTooltipData.java @@ -6,7 +6,7 @@ package meteordevelopment.meteorclient.utils.tooltip; import net.minecraft.client.gui.tooltip.TooltipComponent; -import net.minecraft.client.item.TooltipData; +import net.minecraft.item.tooltip.TooltipData; public interface MeteorTooltipData extends TooltipData { TooltipComponent getComponent(); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java index e260159c57..f8b5c8f02a 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java @@ -10,6 +10,7 @@ import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.player.InstantRebreak; import meteordevelopment.meteorclient.utils.PreInit; +import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.meteorclient.utils.player.Rotations; @@ -19,7 +20,6 @@ import net.minecraft.block.*; import net.minecraft.block.enums.BlockHalf; import net.minecraft.block.enums.SlabType; -import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.effect.StatusEffectUtil; import net.minecraft.entity.effect.StatusEffects; @@ -374,7 +374,7 @@ private static double getBlockBreakingSpeed(int slot, BlockState block) { if (speed > 1) { ItemStack tool = mc.player.getInventory().getStack(slot); - int efficiency = EnchantmentHelper.getLevel(Enchantments.EFFICIENCY, tool); + int efficiency = Utils.getEnchantmentLevel(tool, Enchantments.EFFICIENCY); if (efficiency > 0 && !tool.isEmpty()) speed += efficiency * efficiency + 1; } @@ -394,7 +394,7 @@ private static double getBlockBreakingSpeed(int slot, BlockState block) { speed *= k; } - if (mc.player.isSubmergedIn(FluidTags.WATER) && !EnchantmentHelper.hasAquaAffinity(mc.player)) { + if (mc.player.isSubmergedIn(FluidTags.WATER) /*fixme && !EnchantmentHelper.hasAquaAffinity(mc.player)*/) { speed /= 5.0F; } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 482ee94175..fa6b9ca5ea 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -46,7 +46,7 @@ }, "depends": { "java": ">=21", - "minecraft": ["1.20.5", "${minecraft_version}"], + "minecraft": ["${minecraft_version}"], "fabricloader": ">=${loader_version}" }, "breaks": { diff --git a/src/main/resources/meteor-client.mixins.json b/src/main/resources/meteor-client.mixins.json index bd79e725fd..f1d012c785 100644 --- a/src/main/resources/meteor-client.mixins.json +++ b/src/main/resources/meteor-client.mixins.json @@ -149,7 +149,7 @@ "RegistriesMixin", "ReloadStateAccessor", "RenderLayersMixin", - "RenderTickCounterMixin", + "RenderTickCounterDynamicMixin", "ResourceReloadLoggerAccessor", "ScreenMixin", "SectionedEntityCacheAccessor", From 19c8f7e9302b165eb93daa8a3ffd353fb129d4a9 Mon Sep 17 00:00:00 2001 From: RacoonDog <32882447+RacoonDog@users.noreply.github.com> Date: Sun, 5 May 2024 22:08:01 -0400 Subject: [PATCH 39/66] handle friend names case-insensitively --- .../meteordevelopment/meteorclient/systems/friends/Friends.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/friends/Friends.java b/src/main/java/meteordevelopment/meteorclient/systems/friends/Friends.java index 3642319fa1..cd4143d130 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/friends/Friends.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/friends/Friends.java @@ -56,7 +56,7 @@ public boolean remove(Friend friend) { public Friend get(String name) { for (Friend friend : friends) { - if (friend.name.equals(name)) { + if (friend.name.equalsIgnoreCase(name)) { return friend; } } From 71f439f7626772d78154b3ed527d4992c3dc859e Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Tue, 25 Jun 2024 22:56:41 +0100 Subject: [PATCH 40/66] fix issues with chams --- .../meteorclient/mixin/LivingEntityRendererMixin.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityRendererMixin.java index 1722122854..258f9d3692 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityRendererMixin.java @@ -97,7 +97,7 @@ private void renderTail(T livingEntity, float f, float g, MatrixStack matrixStac // Player chams - @ModifyArgs(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;scale(FFF)V")) + @ModifyArgs(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;scale(FFF)V", ordinal = 1)) private void modifyScale(Args args, T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { Chams module = Modules.get().get(Chams.class); if (!module.isActive() || !module.players.get() || !(livingEntity instanceof PlayerEntity)) return; @@ -115,10 +115,7 @@ private void modifyColor(Args args, T livingEntity, float f, float g, MatrixStac if (module.ignoreSelf.get() && livingEntity == mc.player) return; Color color = PlayerUtils.getPlayerColor(((PlayerEntity) livingEntity), module.playersColor.get()); - args.set(4, color.r / 255f); - args.set(5, color.g / 255f); - args.set(6, color.b / 255f); - args.set(7, module.playersColor.get().a / 255f); + args.set(4, color.getPacked()); } @Redirect(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;getRenderLayer(Lnet/minecraft/entity/LivingEntity;ZZZ)Lnet/minecraft/client/render/RenderLayer;")) From bfb6e32f2df4b71702d118c854bc071400333432 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Thu, 27 Jun 2024 12:47:22 +0100 Subject: [PATCH 41/66] Add setting to criticals to always smash attack with the mace closes #4685 --- .../mixininterface/IPlayerMoveC2SPacket.java | 1 + .../systems/modules/combat/Criticals.java | 80 +++++++++++++------ 2 files changed, 55 insertions(+), 26 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixininterface/IPlayerMoveC2SPacket.java b/src/main/java/meteordevelopment/meteorclient/mixininterface/IPlayerMoveC2SPacket.java index d2c51899db..35a2cca29f 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixininterface/IPlayerMoveC2SPacket.java +++ b/src/main/java/meteordevelopment/meteorclient/mixininterface/IPlayerMoveC2SPacket.java @@ -7,5 +7,6 @@ public interface IPlayerMoveC2SPacket { int getTag(); + void setTag(int tag); } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Criticals.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Criticals.java index 62dc0ce4a8..92e208f827 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Criticals.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/Criticals.java @@ -11,16 +11,14 @@ import meteordevelopment.meteorclient.mixininterface.IPlayerInteractEntityC2SPacket; import meteordevelopment.meteorclient.mixininterface.IPlayerMoveC2SPacket; import meteordevelopment.meteorclient.mixininterface.IVec3d; -import meteordevelopment.meteorclient.settings.BoolSetting; -import meteordevelopment.meteorclient.settings.EnumSetting; -import meteordevelopment.meteorclient.settings.Setting; -import meteordevelopment.meteorclient.settings.SettingGroup; +import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.orbit.EventHandler; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; +import net.minecraft.item.MaceItem; import net.minecraft.network.packet.c2s.play.HandSwingC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; @@ -28,6 +26,7 @@ public class Criticals extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); + private final SettingGroup sgMace = settings.createGroup("Mace"); private final Setting mode = sgGeneral.add(new EnumSetting.Builder() .name("mode") @@ -40,13 +39,32 @@ public class Criticals extends Module { .name("only-killaura") .description("Only performs crits when using killaura.") .defaultValue(false) + .visible(() -> mode.get() != Mode.None) .build() ); + private final Setting mace = sgMace.add(new BoolSetting.Builder() + .name("smash-attack") + .description("Will always perform smash attacks when using a mace.") + .defaultValue(true) + .build() + ); + + private final Setting extraHeight = sgMace.add(new DoubleSetting.Builder() + .name("additional-height") + .description("The amount of additional height to spoof. More height means more damage.") + .defaultValue(0.0) + .min(0) + .sliderRange(0, 100) + .visible(mace::get) + .build() + ); + private PlayerInteractEntityC2SPacket attackPacket; private HandSwingC2SPacket swingPacket; private boolean sendPackets; private int sendTimer; + public Criticals() { super(Categories.Combat, "criticals", "Performs critical attacks when you hit your target."); } @@ -62,31 +80,40 @@ public void onActivate() { @EventHandler private void onSendPacket(PacketEvent.Send event) { if (event.packet instanceof IPlayerInteractEntityC2SPacket packet && packet.getType() == PlayerInteractEntityC2SPacket.InteractType.ATTACK) { - if (skipCrit()) return; + if (mace.get() && mc.player.getMainHandStack().getItem() instanceof MaceItem) { + if (mc.player.isFallFlying()) return; - Entity entity = packet.getEntity(); + sendPacket(0); + sendPacket(1.501 + extraHeight.get()); + sendPacket(0); + } else { + if (skipCrit()) return; - if (!(entity instanceof LivingEntity) || (entity != Modules.get().get(KillAura.class).getTarget() && ka.get())) return; + Entity entity = packet.getEntity(); - switch (mode.get()) { - case Packet -> { - sendPacket(0.0625); - sendPacket(0); - } - case Bypass -> { - sendPacket(0.11); - sendPacket(0.1100013579); - sendPacket(0.0000013579); - } - default -> { - if (!sendPackets) { - sendPackets = true; - sendTimer = mode.get() == Mode.Jump ? 6 : 4; - attackPacket = (PlayerInteractEntityC2SPacket) event.packet; - - if (mode.get() == Mode.Jump) mc.player.jump(); - else ((IVec3d) mc.player.getVelocity()).setY(0.25); - event.cancel(); + if (!(entity instanceof LivingEntity) || (entity != Modules.get().get(KillAura.class).getTarget() && ka.get())) + return; + + switch (mode.get()) { + case Packet -> { + sendPacket(0.0625); + sendPacket(0); + } + case Bypass -> { + sendPacket(0.11); + sendPacket(0.1100013579); + sendPacket(0.0000013579); + } + case Jump, MiniJump -> { + if (!sendPackets) { + sendPackets = true; + sendTimer = mode.get() == Mode.Jump ? 6 : 4; + attackPacket = (PlayerInteractEntityC2SPacket) event.packet; + + if (mode.get() == Mode.Jump) mc.player.jump(); + else ((IVec3d) mc.player.getVelocity()).setY(0.25); + event.cancel(); + } } } } @@ -141,6 +168,7 @@ public String getInfoString() { } public enum Mode { + None, Packet, Bypass, Jump, From 120dac5a48679ce42edb11c31cf8edda50df8731 Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Thu, 27 Jun 2024 13:20:22 +0100 Subject: [PATCH 42/66] add wind charges to the trajectories module --- .../systems/modules/render/Trajectories.java | 4 +++- .../utils/entity/ProjectileEntitySimulator.java | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Trajectories.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Trajectories.java index b5f4aba8f2..aabafb6beb 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Trajectories.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/Trajectories.java @@ -110,7 +110,9 @@ public Trajectories() { } private boolean itemFilter(Item item) { - return item instanceof BowItem || item instanceof CrossbowItem || item instanceof FishingRodItem || item instanceof TridentItem || item instanceof SnowballItem || item instanceof EggItem || item instanceof EnderPearlItem || item instanceof ExperienceBottleItem || item instanceof ThrowablePotionItem; + return item instanceof RangedWeaponItem || item instanceof FishingRodItem || item instanceof TridentItem || + item instanceof SnowballItem || item instanceof EggItem || item instanceof EnderPearlItem || + item instanceof ExperienceBottleItem || item instanceof ThrowablePotionItem || item instanceof WindChargeItem; } private List getDefaultItems() { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/entity/ProjectileEntitySimulator.java b/src/main/java/meteordevelopment/meteorclient/utils/entity/ProjectileEntitySimulator.java index 1c2b63f2de..c0346a4ab4 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/entity/ProjectileEntitySimulator.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/entity/ProjectileEntitySimulator.java @@ -37,6 +37,9 @@ public class ProjectileEntitySimulator { private double gravity; private double airDrag, waterDrag; + + // held items + public boolean set(Entity user, ItemStack itemStack, double simulated, boolean accurate, double tickDelta) { Item item = itemStack.getItem(); @@ -68,6 +71,10 @@ else if (item instanceof ExperienceBottleItem) { else if (item instanceof ThrowablePotionItem) { set(user, -20, 0.5, simulated, 0.05, 0.8, accurate, tickDelta); } + else if (item instanceof WindChargeItem) { + set(user, 0, 1.5, simulated, 0, 1.0, accurate, tickDelta); + this.airDrag = 1.0; + } else { return false; } @@ -112,6 +119,9 @@ public void set(Entity user, double roll, double speed, double simulated, double this.waterDrag = waterDrag; } + + // fired projectiles + public boolean set(Entity entity, boolean accurate) { // skip entities in ground if (entity instanceof ProjectileInGroundAccessor ppe && ppe.getInGround()) return false; From cff4cf578c71691fc17bf4e50619975f0200f1fd Mon Sep 17 00:00:00 2001 From: MineGame159 Date: Thu, 27 Jun 2024 22:41:59 +0200 Subject: [PATCH 43/66] Fix Vanilla Xray --- .../mixin/BlockModelRendererMixin.java | 30 +++++-------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BlockModelRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BlockModelRendererMixin.java index af1fb3d3e4..00606da5be 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/BlockModelRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BlockModelRendererMixin.java @@ -10,8 +10,6 @@ import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.block.BlockModelRenderer; import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.BakedQuad; -import net.minecraft.client.util.BufferAllocator; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.random.Random; @@ -19,14 +17,15 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyConstant; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.nio.ByteBuffer; - @Mixin(BlockModelRenderer.class) public abstract class BlockModelRendererMixin { - @Unique private final ThreadLocal alphas = new ThreadLocal<>(); + @Unique + private final ThreadLocal alphas = new ThreadLocal<>(); @Inject(method = "render(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLnet/minecraft/util/math/random/Random;JI)V", at = @At("HEAD"), cancellable = true) private void onRender(BlockRenderView world, BakedModel model, BlockState state, BlockPos pos, MatrixStack matrices, VertexConsumer vertexConsumer, boolean cull, Random random, long seed, int overlay, CallbackInfo info) { @@ -36,24 +35,9 @@ private void onRender(BlockRenderView world, BakedModel model, BlockState state, else alphas.set(alpha); } - @Inject(method = "renderQuad(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/client/util/math/MatrixStack$Entry;Lnet/minecraft/client/render/model/BakedQuad;FFFFIIIII)V", at = @At("TAIL")) - private void onRenderQuad(BlockRenderView world, BlockState state, BlockPos pos, VertexConsumer vertexConsumer, MatrixStack.Entry matrixEntry, BakedQuad quad, float brightness0, float brightness1, float brightness2, float brightness3, int light0, int light1, int light2, int light3, int overlay, CallbackInfo ci) { + @ModifyConstant(method = "renderQuad", constant = @Constant(floatValue = 1, ordinal = 3)) + private float renderQuad_modifyAlpha(float original) { int alpha = alphas.get(); - if (alpha != -1) rewriteBuffer(vertexConsumer, alpha); - } - - @Unique - private void rewriteBuffer(VertexConsumer vertexConsumer, int alpha) { - if (vertexConsumer instanceof BufferBuilderAccessor bufferBuilder) { - int i = bufferBuilder.getVertexFormat().getVertexSizeByte(); - try (BufferAllocator.CloseableBuffer allocatedBuffer = bufferBuilder.meteor$getAllocator().getAllocated()) { - if (allocatedBuffer != null) { - ByteBuffer buffer = allocatedBuffer.getBuffer(); - for (int l = 1; l <= 4; l++) { - buffer.put(buffer.capacity() - i * l + 15, (byte) (alpha)); - } - } - } - } + return alpha == -1 ? original : alpha / 255f; } } From 85157375d2e368cdfa78358b0a909b51ae7c2d1d Mon Sep 17 00:00:00 2001 From: squidoodly Date: Sun, 30 Jun 2024 17:27:22 +0100 Subject: [PATCH 44/66] Added mace to kill aura --- .../systems/modules/combat/KillAura.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java index 78e44c6316..da5c5c8e29 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java @@ -34,6 +34,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.AxeItem; import net.minecraft.item.ItemStack; +import net.minecraft.item.MaceItem; import net.minecraft.item.SwordItem; import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket; import net.minecraft.util.Hand; @@ -56,7 +57,7 @@ public class KillAura extends Module { private final Setting weapon = sgGeneral.add(new EnumSetting.Builder() .name("weapon") .description("Only attacks an entity when a specified weapon is in your hand.") - .defaultValue(Weapon.Both) + .defaultValue(Weapon.All) .build() ); @@ -283,7 +284,8 @@ private void onTick(TickEvent.Pre event) { Predicate predicate = switch (weapon.get()) { case Axe -> stack -> stack.getItem() instanceof AxeItem; case Sword -> stack -> stack.getItem() instanceof SwordItem; - case Both -> stack -> stack.getItem() instanceof AxeItem || stack.getItem() instanceof SwordItem; + case Mace -> stack -> stack.getItem() instanceof MaceItem; + case All -> stack -> stack.getItem() instanceof AxeItem || stack.getItem() instanceof SwordItem || stack.getItem() instanceof MaceItem; default -> o -> true; }; FindItemResult weaponResult = InvUtils.findInHotbar(predicate); @@ -400,7 +402,8 @@ private boolean itemInHand() { return switch (weapon.get()) { case Axe -> mc.player.getMainHandStack().getItem() instanceof AxeItem; case Sword -> mc.player.getMainHandStack().getItem() instanceof SwordItem; - case Both -> mc.player.getMainHandStack().getItem() instanceof AxeItem || mc.player.getMainHandStack().getItem() instanceof SwordItem; + case Mace -> mc.player.getMainHandStack().getItem() instanceof MaceItem; + case All -> mc.player.getMainHandStack().getItem() instanceof AxeItem || mc.player.getMainHandStack().getItem() instanceof SwordItem || mc.player.getMainHandStack().getItem() instanceof MaceItem; default -> true; }; } @@ -419,7 +422,8 @@ public String getInfoString() { public enum Weapon { Sword, Axe, - Both, + Mace, + All, Any } From 946a4ba986cda7e721ad8e8376f960865904b27a Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Mon, 1 Jul 2024 13:18:55 +0100 Subject: [PATCH 45/66] fix better tooltips bees setting closes #4708 --- .../systems/modules/render/BetterTooltips.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java index 4487d23b09..c4215cfcf4 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java @@ -21,7 +21,7 @@ import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.meteorclient.utils.tooltip.*; import meteordevelopment.orbit.EventHandler; -import net.minecraft.component.ComponentMap; +import net.minecraft.block.entity.BeehiveBlockEntity; import net.minecraft.component.DataComponentTypes; import net.minecraft.component.type.*; import net.minecraft.component.type.BannerPatternsComponent.Layer; @@ -33,7 +33,6 @@ import net.minecraft.entity.effect.StatusEffectUtil; import net.minecraft.inventory.Inventories; import net.minecraft.item.*; -import net.minecraft.nbt.NbtList; import net.minecraft.registry.DynamicRegistryManager; import net.minecraft.text.MutableText; import net.minecraft.text.RawFilteredPair; @@ -254,17 +253,15 @@ private void appendTooltip(ItemStackTooltipEvent event) { //Beehive if (beehive.get()) { if (event.itemStack.getItem() == Items.BEEHIVE || event.itemStack.getItem() == Items.BEE_NEST) { - ComponentMap components = event.itemStack.getComponents(); - BlockStateComponent blockStateComponent = components.get(DataComponentTypes.BLOCK_STATE); + BlockStateComponent blockStateComponent = event.itemStack.get(DataComponentTypes.BLOCK_STATE); if (blockStateComponent != null) { String level = blockStateComponent.properties().get("honey_level"); event.list.add(1, Text.literal(String.format("%sHoney level: %s%s%s.", Formatting.GRAY, Formatting.YELLOW, level, Formatting.GRAY))); } - NbtComponent nbtComponent = components.get(DataComponentTypes.BLOCK_ENTITY_DATA); - if (nbtComponent != null) { - NbtList beesTag = nbtComponent.copyNbt().getList("Bees", 10); - event.list.add(1, Text.literal(String.format("%sBees: %s%d%s.", Formatting.GRAY, Formatting.YELLOW, beesTag.size(), Formatting.GRAY))); + List bees = event.itemStack.get(DataComponentTypes.BEES); + if (bees != null) { + event.list.add(1, Text.literal(String.format("%sBees: %s%d%s.", Formatting.GRAY, Formatting.YELLOW, bees.size(), Formatting.GRAY))); } } } From c51867e02768d60f172893d49272687e43e6b35b Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Mon, 1 Jul 2024 20:16:28 +0100 Subject: [PATCH 46/66] Ensure toggleOnBindRelease doesn't enable modules when releasing the bind closes #4710, closes #4289, closes #4174, closes #2782 --- .../meteordevelopment/meteorclient/systems/modules/Modules.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java index c5583011a5..c1edf461a6 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java @@ -284,7 +284,7 @@ private void onAction(boolean isKey, int value, int modifiers, boolean isPress) if (mc.currentScreen != null || Input.isKeyPressed(GLFW.GLFW_KEY_F3)) return; for (Module module : moduleInstances.values()) { - if (module.keybind.matches(isKey, value, modifiers) && (isPress || module.toggleOnBindRelease)) { + if (module.keybind.matches(isKey, value, modifiers) && (isPress || (module.toggleOnBindRelease && module.isActive()))) { module.toggle(); module.sendToggledMsg(); } From f82d7dc7fce585585fb4fb63394532befd04e129 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 3 Jul 2024 22:27:07 +0200 Subject: [PATCH 47/66] Fixed game crash caused by ChatInputSuggestor Use length instead of 1 to prevent a crash that happens when you use the left arrow key in the chat and the command prefix is more than one character long. --- .../meteorclient/mixin/ChatInputSuggestorMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ChatInputSuggestorMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ChatInputSuggestorMixin.java index e610790137..7dd3a6b343 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ChatInputSuggestorMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ChatInputSuggestorMixin.java @@ -52,7 +52,7 @@ public void onRefresh(CallbackInfo ci, String string, StringReader reader) { } int cursor = textField.getCursor(); - if (cursor >= 1 && (this.window == null || !this.completingSuggestions)) { + if (cursor >= length && (this.window == null || !this.completingSuggestions)) { this.pendingSuggestions = Commands.DISPATCHER.getCompletionSuggestions(this.parse, cursor); this.pendingSuggestions.thenRun(() -> { if (this.pendingSuggestions.isDone()) { From f33e87bf752715b768b536b08d23ff0f3efc9332 Mon Sep 17 00:00:00 2001 From: Chen Meng <78586843+slmpc@users.noreply.github.com> Date: Thu, 4 Jul 2024 04:54:52 +0800 Subject: [PATCH 48/66] Added pause in creative mode option for middle click open (#4717) --- .../systems/modules/render/BetterTooltips.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java index c4215cfcf4..610e7952c4 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java @@ -76,6 +76,14 @@ public class BetterTooltips extends Module { .build() ); + private final Setting pauseInCreative = sgGeneral.add(new BoolSetting.Builder() + .name("pause-in-creative") + .description("Pauses middle click open while the player is in creative mode.") + .defaultValue(true) + .visible(middleClickOpen::get) + .build() + ); + // Previews private final Setting shulkers = sgPreviews.add(new BoolSetting.Builder() @@ -438,7 +446,8 @@ private ItemStack createBannerFromShield(ItemStack shieldItem) { } public boolean middleClickOpen() { - return isActive() && middleClickOpen.get(); + return (isActive() && middleClickOpen.get()) + && (!pauseInCreative.get() || !mc.player.isInCreativeMode()); } public boolean previewShulkers() { From 7e65731ab263e09e25bec52f84f654081442d56c Mon Sep 17 00:00:00 2001 From: Lubyanoy Ivan Date: Thu, 4 Jul 2024 00:20:37 +0300 Subject: [PATCH 49/66] Make .peek work for containers in item frames --- .../meteorclient/commands/commands/PeekCommand.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/PeekCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/PeekCommand.java index 28d589165d..52e9761622 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/PeekCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/PeekCommand.java @@ -10,12 +10,13 @@ import meteordevelopment.meteorclient.commands.Command; import meteordevelopment.meteorclient.utils.Utils; import net.minecraft.command.CommandSource; +import net.minecraft.entity.decoration.ItemFrameEntity; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; public class PeekCommand extends Command { private static final ItemStack[] ITEMS = new ItemStack[27]; - private static final SimpleCommandExceptionType NOT_HOLDING_SHULKER_BOX = new SimpleCommandExceptionType(Text.literal("You must be holding a storage block with items in it.")); + private static final SimpleCommandExceptionType CANT_PEEK = new SimpleCommandExceptionType(Text.literal("You must be holding a storage block or looking at an item frame.")); public PeekCommand() { super("peek", "Lets you see what's inside storage block items."); @@ -26,7 +27,10 @@ public void build(LiteralArgumentBuilder builder) { builder.executes(context -> { if (Utils.openContainer(mc.player.getMainHandStack(), ITEMS, true)) return SINGLE_SUCCESS; else if (Utils.openContainer(mc.player.getOffHandStack(), ITEMS, true)) return SINGLE_SUCCESS; - else throw NOT_HOLDING_SHULKER_BOX.create(); + else if (mc.targetedEntity instanceof ItemFrameEntity && + Utils.openContainer(((ItemFrameEntity) mc.targetedEntity).getHeldItemStack(), ITEMS, true) + ) return SINGLE_SUCCESS; + else throw CANT_PEEK.create(); }); } } From 65a84e1e99d9a67433e55e55bfeff211da2be01e Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Thu, 4 Jul 2024 18:32:56 +0100 Subject: [PATCH 50/66] Fix gui move stopping you for a tick when opening a gui --- .../entity/player/PlayerTickMovementEvent.java | 17 +++++++++++++++++ .../mixin/ClientPlayerEntityMixin.java | 8 ++++++++ .../systems/modules/movement/GUIMove.java | 9 ++++----- 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 src/main/java/meteordevelopment/meteorclient/events/entity/player/PlayerTickMovementEvent.java diff --git a/src/main/java/meteordevelopment/meteorclient/events/entity/player/PlayerTickMovementEvent.java b/src/main/java/meteordevelopment/meteorclient/events/entity/player/PlayerTickMovementEvent.java new file mode 100644 index 0000000000..38b8775661 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/events/entity/player/PlayerTickMovementEvent.java @@ -0,0 +1,17 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.events.entity.player; + +/** + * @see net.minecraft.client.network.ClientPlayerEntity#tickMovement() + */ +public class PlayerTickMovementEvent { + private static final PlayerTickMovementEvent INSTANCE = new PlayerTickMovementEvent(); + + public static PlayerTickMovementEvent get() { + return INSTANCE; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java index a05a576944..8ab98835a4 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java @@ -10,6 +10,7 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.entity.DamageEvent; import meteordevelopment.meteorclient.events.entity.DropItemsEvent; +import meteordevelopment.meteorclient.events.entity.player.PlayerTickMovementEvent; import meteordevelopment.meteorclient.events.entity.player.SendMovementPacketsEvent; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.movement.*; @@ -93,6 +94,13 @@ private boolean isSneaking(boolean sneaking) { return Modules.get().get(Sneak.class).doPacket() || Modules.get().get(NoSlow.class).airStrict() || sneaking; } + @Inject(method = "tickMovement", at = @At("HEAD")) + private void preTickMovement(CallbackInfo ci) { + MeteorClient.EVENT_BUS.post(PlayerTickMovementEvent.get()); + } + + // Sprint + @ModifyExpressionValue(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z")) private boolean modifyIsWalking(boolean original) { boolean rage = Modules.get().isActive(Sprint.class) && Modules.get().get(Sprint.class).mode.get() == Sprint.Mode.Rage; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/GUIMove.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/GUIMove.java index f9ed75835a..fc177623d3 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/GUIMove.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/GUIMove.java @@ -6,9 +6,9 @@ package meteordevelopment.meteorclient.systems.modules.movement; import meteordevelopment.meteorclient.MeteorClient; +import meteordevelopment.meteorclient.events.entity.player.PlayerTickMovementEvent; import meteordevelopment.meteorclient.events.meteor.KeyEvent; import meteordevelopment.meteorclient.events.render.Render3DEvent; -import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.gui.WidgetScreen; import meteordevelopment.meteorclient.mixin.CreativeInventoryScreenAccessor; import meteordevelopment.meteorclient.mixin.KeyBindingAccessor; @@ -63,7 +63,7 @@ public enum Screens { .build() ); - private final Setting sprint = sgGeneral.add(new BoolSetting.Builder() + public final Setting sprint = sgGeneral.add(new BoolSetting.Builder() .name("sprint") .description("Allows you to sprint while in GUIs.") .defaultValue(true) @@ -87,7 +87,7 @@ public enum Screens { .min(0) .build() ); - + public GUIMove() { super(Categories.Movement, "gui-move", "Allows you to perform various actions while in GUIs."); } @@ -112,7 +112,7 @@ public boolean disableArrows() { } @EventHandler - private void onTick(TickEvent.Pre event) { + private void onPlayerMoveEvent(PlayerTickMovementEvent event) { if (skip()) return; if (screens.get() == Screens.GUI && !(mc.currentScreen instanceof WidgetScreen)) return; if (screens.get() == Screens.Inventory && mc.currentScreen instanceof WidgetScreen) return; @@ -125,7 +125,6 @@ private void onTick(TickEvent.Pre event) { if (jump.get()) set(mc.options.jumpKey, Input.isPressed(mc.options.jumpKey)); if (sneak.get()) set(mc.options.sneakKey, Input.isPressed(mc.options.sneakKey)); if (sprint.get()) set(mc.options.sprintKey, Input.isPressed(mc.options.sprintKey)); - } @EventHandler From e3df815c44107f1aa6b74adaae879a3ec6b6bb7e Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Thu, 4 Jul 2024 19:34:28 +0100 Subject: [PATCH 51/66] refactor and fix some issues with sprint --- .../mixin/ClientPlayerEntityAccessor.java | 4 +++ .../mixin/ClientPlayerEntityMixin.java | 12 ++++++--- .../meteorclient/mixin/LivingEntityMixin.java | 11 +------- .../systems/modules/movement/Sprint.java | 27 +++++++++++-------- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityAccessor.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityAccessor.java index b7aa2c7ef4..c9b0337b9f 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityAccessor.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityAccessor.java @@ -8,6 +8,7 @@ import net.minecraft.client.network.ClientPlayerEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(ClientPlayerEntity.class) public interface ClientPlayerEntityAccessor { @@ -16,4 +17,7 @@ public interface ClientPlayerEntityAccessor { @Accessor("ticksSinceLastPositionPacketSent") void setTicksSinceLastPositionPacketSent(int ticks); + + @Invoker("canSprint") + boolean invokeCanSprint(); } diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java index 8ab98835a4..ab98464f79 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerEntityMixin.java @@ -6,6 +6,7 @@ package meteordevelopment.meteorclient.mixin; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import com.mojang.authlib.GameProfile; import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.entity.DamageEvent; @@ -103,8 +104,7 @@ private void preTickMovement(CallbackInfo ci) { @ModifyExpressionValue(method = "canStartSprinting", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isWalking()Z")) private boolean modifyIsWalking(boolean original) { - boolean rage = Modules.get().isActive(Sprint.class) && Modules.get().get(Sprint.class).mode.get() == Sprint.Mode.Rage; - if (!rage) return original; + if (!Modules.get().get(Sprint.class).rageSprint()) return original; float forwards = Math.abs(input.movementSideways); float sideways = Math.abs(input.movementForward); @@ -114,12 +114,16 @@ private boolean modifyIsWalking(boolean original) { @ModifyExpressionValue(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/input/Input;hasForwardMovement()Z")) private boolean modifyMovement(boolean original) { - boolean rage = Modules.get().isActive(Sprint.class) && Modules.get().get(Sprint.class).mode.get() == Sprint.Mode.Rage; - if (!rage) return original; + if (!Modules.get().get(Sprint.class).rageSprint()) return original; return Math.abs(input.movementSideways) > 1.0E-5F || Math.abs(input.movementForward) > 1.0E-5F; } + @WrapWithCondition(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;setSprinting(Z)V", ordinal = 3)) + private boolean wrapSetSprinting(ClientPlayerEntity instance, boolean b) { + return !Modules.get().get(Sprint.class).rageSprint(); + } + // Rotations @Inject(method = "sendMovementPackets", at = @At("HEAD")) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java index f27d36d9b8..1ef16a142c 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/LivingEntityMixin.java @@ -27,30 +27,21 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.fluid.FluidState; import net.minecraft.item.ItemStack; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.Hand; import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.Map; - import static meteordevelopment.meteorclient.MeteorClient.mc; @Mixin(LivingEntity.class) public abstract class LivingEntityMixin extends Entity { - @Shadow - @Final - private Map activeStatusEffects; - public LivingEntityMixin(EntityType type, World world) { super(type, world); } @@ -132,7 +123,7 @@ private float modifyGetYaw(float original) { if ((Object) this != mc.player) return original; Sprint s = Modules.get().get(Sprint.class); - if (!s.isActive() || s.mode.get() != Sprint.Mode.Rage || !s.jumpFix.get()) return original; + if (!s.rageSprint() || !s.jumpFix.get()) return original; float forward = Math.signum(mc.player.input.movementForward); float strafe = 90 * Math.signum(mc.player.input.movementSideways); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java index 5b8e15e915..c25f855c24 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Sprint.java @@ -6,12 +6,14 @@ package meteordevelopment.meteorclient.systems.modules.movement; import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.mixin.ClientPlayerEntityAccessor; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.EnumSetting; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.orbit.EventHandler; public class Sprint extends Module { @@ -53,19 +55,22 @@ public void onDeactivate() { mc.player.setSprinting(false); } - private void sprint() { - if (mc.player.getHungerManager().getFoodLevel() <= 6) return; - mc.player.setSprinting(true); + @EventHandler + private void onTickMovement(TickEvent.Post event) { + if (shouldSprint()) mc.player.setSprinting(true); } - @EventHandler - private void onTick(TickEvent.Post event) { - switch (mode.get()) { - case Strict -> { - if (mc.player.forwardSpeed > 0) sprint(); - } - case Rage -> sprint(); - } + public boolean shouldSprint() { + boolean strictSprint = mc.player.forwardSpeed > 1.0E-5F + && ((ClientPlayerEntityAccessor) mc.player).invokeCanSprint() + && (!mc.player.horizontalCollision || mc.player.collidedSoftly) + && !(mc.player.isTouchingWater() && !mc.player.isSubmergedInWater()); + + return isActive() && (mode.get() == Mode.Rage || strictSprint) && (mc.currentScreen == null || Modules.get().get(GUIMove.class).sprint.get()); + } + + public boolean rageSprint() { + return isActive() && mode.get() == Mode.Rage; } public boolean stopSprinting() { From 2374b609bc4132f759a53fe20b70a3d37f74c75f Mon Sep 17 00:00:00 2001 From: Wide-Cat Date: Sat, 6 Jul 2024 22:24:51 +0100 Subject: [PATCH 52/66] fix issues with better tooltips when searching in the creative menu closes #4692 --- .../events/game/ItemStackTooltipEvent.java | 13 +--- .../meteorclient/mixin/ItemGroupsMixin.java | 21 ++++++ .../meteorclient/mixin/ItemStackMixin.java | 4 +- .../modules/render/BetterTooltips.java | 70 ++++++++++++------- src/main/resources/meteor-client.mixins.json | 1 + 5 files changed, 71 insertions(+), 38 deletions(-) create mode 100644 src/main/java/meteordevelopment/meteorclient/mixin/ItemGroupsMixin.java diff --git a/src/main/java/meteordevelopment/meteorclient/events/game/ItemStackTooltipEvent.java b/src/main/java/meteordevelopment/meteorclient/events/game/ItemStackTooltipEvent.java index d6046e2785..c0cf9c5f97 100644 --- a/src/main/java/meteordevelopment/meteorclient/events/game/ItemStackTooltipEvent.java +++ b/src/main/java/meteordevelopment/meteorclient/events/game/ItemStackTooltipEvent.java @@ -10,15 +10,4 @@ import java.util.List; -public class ItemStackTooltipEvent { - private static final ItemStackTooltipEvent INSTANCE = new ItemStackTooltipEvent(); - - public ItemStack itemStack; - public List list; - - public static ItemStackTooltipEvent get(ItemStack itemStack, List list) { - INSTANCE.itemStack = itemStack; - INSTANCE.list = list; - return INSTANCE; - } -} +public record ItemStackTooltipEvent(ItemStack itemStack, List list) {} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ItemGroupsMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ItemGroupsMixin.java new file mode 100644 index 0000000000..daa0577e9a --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ItemGroupsMixin.java @@ -0,0 +1,21 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.mixin; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import meteordevelopment.meteorclient.systems.modules.Modules; +import meteordevelopment.meteorclient.systems.modules.render.BetterTooltips; +import net.minecraft.item.ItemGroups; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(ItemGroups.class) +public class ItemGroupsMixin { + @ModifyReturnValue(method = "updateDisplayContext", at = @At("RETURN")) + private static boolean modifyReturn(boolean original) { + return original || Modules.get().get(BetterTooltips.class).updateTooltips(); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ItemStackMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ItemStackMixin.java index cc139b4f24..fac7631650 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ItemStackMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ItemStackMixin.java @@ -33,8 +33,8 @@ public abstract class ItemStackMixin { @ModifyReturnValue(method = "getTooltip", at = @At("RETURN")) private List onGetTooltip(List original) { if (Utils.canUpdate()) { - ItemStackTooltipEvent event = MeteorClient.EVENT_BUS.post(ItemStackTooltipEvent.get((ItemStack) (Object) this, original)); - return event.list; + ItemStackTooltipEvent event = MeteorClient.EVENT_BUS.post(new ItemStackTooltipEvent((ItemStack) (Object) this, original)); + return event.list(); } return original; diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java index 610e7952c4..9336b51568 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/BetterTooltips.java @@ -58,6 +58,7 @@ public class BetterTooltips extends Module { .name("display-when") .description("When to display previews.") .defaultValue(DisplayWhen.Keybind) + .onChanged(value -> updateTooltips = true) .build() ); @@ -66,6 +67,7 @@ public class BetterTooltips extends Module { .description("The bind for keybind mode.") .defaultValue(Keybind.fromKey(GLFW_KEY_LEFT_ALT)) .visible(() -> displayWhen.get() == DisplayWhen.Keybind) + .onChanged(value -> updateTooltips = true) .build() ); @@ -90,6 +92,7 @@ public class BetterTooltips extends Module { .name("containers") .description("Shows a preview of a containers when hovering over it in an inventory.") .defaultValue(true) + .onChanged(value -> updateTooltips = true) .build() ); @@ -105,6 +108,7 @@ public class BetterTooltips extends Module { .name("echests") .description("Shows a preview of your echest when hovering over it in an inventory.") .defaultValue(true) + .onChanged(value -> updateTooltips = true) .build() ); @@ -112,6 +116,7 @@ public class BetterTooltips extends Module { .name("maps") .description("Shows a preview of a map when hovering over it in an inventory.") .defaultValue(true) + .onChanged(value -> updateTooltips = true) .build() ); @@ -129,6 +134,7 @@ public class BetterTooltips extends Module { .name("books") .description("Shows contents of a book when hovering over it in an inventory.") .defaultValue(true) + .onChanged(value -> updateTooltips = true) .build() ); @@ -136,6 +142,7 @@ public class BetterTooltips extends Module { .name("banners") .description("Shows banners' patterns when hovering over it in an inventory. Also works with shields.") .defaultValue(true) + .onChanged(value -> updateTooltips = true) .build() ); @@ -143,6 +150,7 @@ public class BetterTooltips extends Module { .name("entities-in-buckets") .description("Shows entities in buckets when hovering over it in an inventory.") .defaultValue(true) + .onChanged(value -> updateTooltips = true) .build() ); @@ -152,6 +160,7 @@ public class BetterTooltips extends Module { .name("byte-size") .description("Displays an item's size in bytes in the tooltip.") .defaultValue(true) + .onChanged(value -> updateTooltips = true) .build() ); @@ -159,6 +168,7 @@ public class BetterTooltips extends Module { .name("status-effects") .description("Adds list of status effects to tooltips of food items.") .defaultValue(true) + .onChanged(value -> updateTooltips = true) .build() ); @@ -166,6 +176,7 @@ public class BetterTooltips extends Module { .name("beehive") .description("Displays information about a beehive or bee nest.") .defaultValue(true) + .onChanged(value -> updateTooltips = true) .build() ); @@ -234,6 +245,8 @@ public class BetterTooltips extends Module { .build() ); + private boolean updateTooltips = false; + public BetterTooltips() { super(Categories.Render, "better-tooltips", "Displays more useful tooltips for certain items."); } @@ -242,34 +255,34 @@ public BetterTooltips() { private void appendTooltip(ItemStackTooltipEvent event) { // Status effects if (statusEffects.get()) { - if (event.itemStack.getItem() == Items.SUSPICIOUS_STEW) { - SuspiciousStewEffectsComponent stewEffectsComponent = event.itemStack.get(DataComponentTypes.SUSPICIOUS_STEW_EFFECTS); + if (event.itemStack().getItem() == Items.SUSPICIOUS_STEW) { + SuspiciousStewEffectsComponent stewEffectsComponent = event.itemStack().get(DataComponentTypes.SUSPICIOUS_STEW_EFFECTS); if (stewEffectsComponent != null) { for (StewEffect effectTag : stewEffectsComponent.effects()) { StatusEffectInstance effect = new StatusEffectInstance(effectTag.effect(), effectTag.duration(), 0); - event.list.add(1, getStatusText(effect)); + event.list().add(1, getStatusText(effect)); } } } else { - FoodComponent food = event.itemStack.get(DataComponentTypes.FOOD); + FoodComponent food = event.itemStack().get(DataComponentTypes.FOOD); if (food != null) { - food.effects().forEach(e -> event.list.add(1, getStatusText(e.effect()))); + food.effects().forEach(e -> event.list().add(1, getStatusText(e.effect()))); } } } //Beehive if (beehive.get()) { - if (event.itemStack.getItem() == Items.BEEHIVE || event.itemStack.getItem() == Items.BEE_NEST) { - BlockStateComponent blockStateComponent = event.itemStack.get(DataComponentTypes.BLOCK_STATE); + if (event.itemStack().getItem() == Items.BEEHIVE || event.itemStack().getItem() == Items.BEE_NEST) { + BlockStateComponent blockStateComponent = event.itemStack().get(DataComponentTypes.BLOCK_STATE); if (blockStateComponent != null) { String level = blockStateComponent.properties().get("honey_level"); - event.list.add(1, Text.literal(String.format("%sHoney level: %s%s%s.", Formatting.GRAY, Formatting.YELLOW, level, Formatting.GRAY))); + event.list().add(1, Text.literal(String.format("%sHoney level: %s%s%s.", Formatting.GRAY, Formatting.YELLOW, level, Formatting.GRAY))); } - List bees = event.itemStack.get(DataComponentTypes.BEES); + List bees = event.itemStack().get(DataComponentTypes.BEES); if (bees != null) { - event.list.add(1, Text.literal(String.format("%sBees: %s%d%s.", Formatting.GRAY, Formatting.YELLOW, bees.size(), Formatting.GRAY))); + event.list().add(1, Text.literal(String.format("%sBees: %s%d%s.", Formatting.GRAY, Formatting.YELLOW, bees.size(), Formatting.GRAY))); } } } @@ -277,7 +290,7 @@ private void appendTooltip(ItemStackTooltipEvent event) { // Item size tooltip if (byteSize.get()) { try { - event.itemStack.encode(mc.player.getRegistryManager()).write(ByteCountDataOutput.INSTANCE); + event.itemStack().encode(mc.player.getRegistryManager()).write(ByteCountDataOutput.INSTANCE); int byteCount = ByteCountDataOutput.INSTANCE.getCount(); String count; @@ -287,24 +300,24 @@ private void appendTooltip(ItemStackTooltipEvent event) { if (byteCount >= 1024) count = String.format("%.2f kb", byteCount / (float) 1024); else count = String.format("%d bytes", byteCount); - event.list.add(Text.literal(count).formatted(Formatting.GRAY)); + event.list().add(Text.literal(count).formatted(Formatting.GRAY)); } catch (Exception e) { - event.list.add(Text.literal("Error getting bytes.").formatted(Formatting.RED)); + event.list().add(Text.literal("Error getting bytes.").formatted(Formatting.RED)); } } // Hold to preview tooltip - if ((shulkers.get() && !previewShulkers() && Utils.hasItems(event.itemStack)) - || (event.itemStack.getItem() == Items.ENDER_CHEST && echest.get() && !previewEChest()) - || (event.itemStack.getItem() == Items.FILLED_MAP && maps.get() && !previewMaps()) - || (event.itemStack.getItem() == Items.WRITABLE_BOOK && books.get() && !previewBooks()) - || (event.itemStack.getItem() == Items.WRITTEN_BOOK && books.get() && !previewBooks()) - || (event.itemStack.getItem() instanceof EntityBucketItem && entitiesInBuckets.get() && !previewEntities()) - || (event.itemStack.getItem() instanceof BannerItem && banners.get() && !previewBanners()) - || (event.itemStack.getItem() instanceof BannerPatternItem && banners.get() && !previewBanners()) - || (event.itemStack.getItem() == Items.SHIELD && banners.get() && !previewBanners())) { - event.list.add(Text.literal("")); - event.list.add(Text.literal("Hold " + Formatting.YELLOW + keybind + Formatting.RESET + " to preview")); + if ((shulkers.get() && !previewShulkers() && Utils.hasItems(event.itemStack())) + || (event.itemStack().getItem() == Items.ENDER_CHEST && echest.get() && !previewEChest()) + || (event.itemStack().getItem() == Items.FILLED_MAP && maps.get() && !previewMaps()) + || (event.itemStack().getItem() == Items.WRITABLE_BOOK && books.get() && !previewBooks()) + || (event.itemStack().getItem() == Items.WRITTEN_BOOK && books.get() && !previewBooks()) + || (event.itemStack().getItem() instanceof EntityBucketItem && entitiesInBuckets.get() && !previewEntities()) + || (event.itemStack().getItem() instanceof BannerItem && banners.get() && !previewBanners()) + || (event.itemStack().getItem() instanceof BannerPatternItem && banners.get() && !previewBanners()) + || (event.itemStack().getItem() == Items.SHIELD && banners.get() && !previewBanners())) { + event.list().add(Text.literal("")); + event.list().add(Text.literal("Hold " + Formatting.YELLOW + keybind + Formatting.RESET + " to preview")); } } @@ -482,6 +495,15 @@ private boolean isPressed() { return (keybind.get().isPressed() && displayWhen.get() == DisplayWhen.Keybind) || displayWhen.get() == DisplayWhen.Always; } + public boolean updateTooltips() { + if (updateTooltips && isActive()) { + updateTooltips = false; + return true; + } + + return false; + } + public enum DisplayWhen { Keybind, Always diff --git a/src/main/resources/meteor-client.mixins.json b/src/main/resources/meteor-client.mixins.json index f1d012c785..02345053b9 100644 --- a/src/main/resources/meteor-client.mixins.json +++ b/src/main/resources/meteor-client.mixins.json @@ -108,6 +108,7 @@ "ItemEnchantmentsComponentMixin", "ItemEntityMixin", "ItemEntityRendererMixin", + "ItemGroupsMixin", "ItemMixin", "ItemRendererMixin", "ItemStackAccessor", From d4e047db2ccc638644e20b886e5b9409831aeff2 Mon Sep 17 00:00:00 2001 From: RacoonDog <32882447+RacoonDog@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:07:05 -0400 Subject: [PATCH 53/66] use builtin io stream methods --- .../meteorclient/utils/Utils.java | 18 +++++-------- .../meteorclient/utils/files/StreamUtils.java | 25 +++++++------------ 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/utils/Utils.java b/src/main/java/meteordevelopment/meteorclient/utils/Utils.java index 7da482b09a..547948bba9 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/Utils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/Utils.java @@ -52,7 +52,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.chunk.Chunk; -import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.Range; import org.joml.Matrix4f; @@ -481,19 +481,13 @@ public static String getButtonName(int button) { public static byte[] readBytes(InputStream in) { try { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - byte[] buffer = new byte[256]; - int read; - while ((read = in.read(buffer)) > 0) out.write(buffer, 0, read); - - in.close(); - return out.toByteArray(); + return in.readAllBytes(); } catch (IOException e) { - e.printStackTrace(); + MeteorClient.LOG.error("Error reading from stream.", e); + return new byte[0]; + } finally { + IOUtils.closeQuietly(in); } - - return new byte[0]; } public static boolean canUpdate() { diff --git a/src/main/java/meteordevelopment/meteorclient/utils/files/StreamUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/files/StreamUtils.java index 725d76616f..17f76be0ab 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/files/StreamUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/files/StreamUtils.java @@ -5,6 +5,9 @@ package meteordevelopment.meteorclient.utils.files; +import meteordevelopment.meteorclient.MeteorClient; +import org.apache.commons.io.IOUtils; + import java.io.*; public class StreamUtils { @@ -14,29 +17,19 @@ private StreamUtils() { public static void copy(File from, File to) { try (InputStream in = new FileInputStream(from); OutputStream out = new FileOutputStream(to)) { - copy(in, out); + in.transferTo(out); } catch (IOException e) { - e.printStackTrace(); + MeteorClient.LOG.error("Error copying from file '%s' to file '%s'.".formatted(from.getName(), to.getName()), e); } } public static void copy(InputStream in, File to) { try (OutputStream out = new FileOutputStream(to)) { - copy(in, out); - in.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static void copy(InputStream in, OutputStream out) { - byte[] bytes = new byte[512]; - int read; - - try { - while ((read = in.read(bytes)) != -1) out.write(bytes, 0, read); + in.transferTo(out); } catch (IOException e) { - e.printStackTrace(); + MeteorClient.LOG.error("Error writing to file '%s'.".formatted(to.getName())); + } finally { + IOUtils.closeQuietly(in); } } } From 8f10a0f0df45816fb71eefe6a59077dbde263b9a Mon Sep 17 00:00:00 2001 From: RacoonDog <32882447+RacoonDog@users.noreply.github.com> Date: Tue, 16 Jul 2024 03:31:47 -0400 Subject: [PATCH 54/66] Add exception handling to `Http` (#4749) --- .../commands/commands/NameHistoryCommand.java | 9 +++++--- .../meteorclient/mixin/TitleScreenMixin.java | 4 +++- .../meteorclient/utils/network/Capes.java | 22 +++++++++++-------- .../utils/network/FailedHttpResponse.java | 2 +- .../meteorclient/utils/network/Http.java | 16 ++++++++++++-- .../utils/network/OnlinePlayers.java | 4 ++-- .../utils/player/TitleScreenCredits.java | 1 + .../utils/render/PlayerHeadUtils.java | 5 ++++- 8 files changed, 44 insertions(+), 19 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/NameHistoryCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/NameHistoryCommand.java index 10ca1a99df..56b605c88a 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/NameHistoryCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/NameHistoryCommand.java @@ -36,11 +36,14 @@ public void build(LiteralArgumentBuilder builder) { PlayerListEntry lookUpTarget = PlayerListEntryArgumentType.get(context); UUID uuid = lookUpTarget.getProfile().getId(); - NameHistory history = Http.get("https://laby.net/api/v2/user/" + uuid + "/get-profile").sendJson(NameHistory.class); + NameHistory history = Http.get("https://laby.net/api/v2/user/" + uuid + "/get-profile") + .exceptionHandler(e -> error("There was an error fetching that users name history.")) + .sendJson(NameHistory.class); - if (history == null || history.username_history == null || history.username_history.length == 0) { - error("There was an error fetching that users name history."); + if (history == null) { return; + } else if (history.username_history == null || history.username_history.length == 0) { + error("There was an error fetching that users name history."); } String name = lookUpTarget.getProfile().getName(); diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/TitleScreenMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/TitleScreenMixin.java index cccfafa192..be16958768 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/TitleScreenMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/TitleScreenMixin.java @@ -42,7 +42,9 @@ private void onRenderIdkDude(DrawContext context, int mouseX, int mouseY, float MeteorClient.LOG.info("Checking latest version of Meteor Client"); MeteorExecutor.execute(() -> { - String res = Http.get("https://meteorclient.com/api/stats").sendString(); + String res = Http.get("https://meteorclient.com/api/stats") + .exceptionHandler(e -> MeteorClient.LOG.error("Could not fetch version information.")) + .sendString(); if (res == null) return; Version latestVer = new Version(JsonParser.parseString(res).getAsJsonObject().get("version").getAsString()); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/network/Capes.java b/src/main/java/meteordevelopment/meteorclient/utils/network/Capes.java index 372f296374..5d9926b466 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/network/Capes.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/network/Capes.java @@ -47,15 +47,19 @@ public static void init() { MeteorExecutor.execute(() -> { // Cape owners - Stream lines = Http.get(CAPE_OWNERS_URL).sendLines(); - if (lines != null) lines.forEach(s -> { - String[] split = s.split(" "); - - if (split.length >= 2) { - OWNERS.put(UUID.fromString(split[0]), split[1]); - if (!TEXTURES.containsKey(split[1])) TEXTURES.put(split[1], new Cape(split[1])); - } - }); + Stream lines = Http.get(CAPE_OWNERS_URL) + .exceptionHandler(e -> MeteorClient.LOG.error("Could not load capes: " + e.getMessage())) + .sendLines(); + if (lines != null) { + lines.forEach(s -> { + String[] split = s.split(" "); + + if (split.length >= 2) { + OWNERS.put(UUID.fromString(split[0]), split[1]); + if (!TEXTURES.containsKey(split[1])) TEXTURES.put(split[1], new Cape(split[1])); + } + }); + } else return; // Capes lines = Http.get(CAPES_URL).sendLines(); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/network/FailedHttpResponse.java b/src/main/java/meteordevelopment/meteorclient/utils/network/FailedHttpResponse.java index 3d6577741f..c108179288 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/network/FailedHttpResponse.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/network/FailedHttpResponse.java @@ -23,7 +23,7 @@ * * @author Crosby */ -public record FailedHttpResponse(HttpRequest request) implements HttpResponse { +public record FailedHttpResponse(HttpRequest request, Exception exception) implements HttpResponse { @Override public int statusCode() { return Http.BAD_REQUEST; diff --git a/src/main/java/meteordevelopment/meteorclient/utils/network/Http.java b/src/main/java/meteordevelopment/meteorclient/utils/network/Http.java index c581e5f715..f74b7b04f5 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/network/Http.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/network/Http.java @@ -19,6 +19,7 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.util.Date; +import java.util.function.Consumer; import java.util.stream.Stream; public class Http { @@ -42,6 +43,7 @@ private enum Method { public static class Request { private final HttpRequest.Builder builder; private Method method; + private Consumer exceptionHandler = Exception::printStackTrace; private Request(Method method, String url) { try { @@ -96,6 +98,16 @@ public Request bodyJson(Object object) { return this; } + public Request ignoreExceptions() { + exceptionHandler = e -> {}; + return this; + } + + public Request exceptionHandler(Consumer exceptionHandler) { + this.exceptionHandler = exceptionHandler; + return this; + } + private HttpResponse _sendResponse(String accept, HttpResponse.BodyHandler responseBodyHandler) { builder.header("Accept", accept); if (method != null) builder.method(method.name(), HttpRequest.BodyPublishers.noBody()); @@ -105,8 +117,8 @@ private HttpResponse _sendResponse(String accept, HttpResponse.BodyHandle try { return CLIENT.send(request, responseBodyHandler); } catch (IOException | InterruptedException e) { - e.printStackTrace(); - return new FailedHttpResponse<>(request); + exceptionHandler.accept(e); + return new FailedHttpResponse<>(request, e); } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/network/OnlinePlayers.java b/src/main/java/meteordevelopment/meteorclient/utils/network/OnlinePlayers.java index 30dc9c8f96..e716d2e0c7 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/network/OnlinePlayers.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/network/OnlinePlayers.java @@ -15,13 +15,13 @@ public static void update() { long time = System.currentTimeMillis(); if (time - lastPingTime > 5 * 60 * 1000) { - MeteorExecutor.execute(() -> Http.post("https://meteorclient.com/api/online/ping").send()); + MeteorExecutor.execute(() -> Http.post("https://meteorclient.com/api/online/ping").ignoreExceptions().send()); lastPingTime = time; } } public static void leave() { - MeteorExecutor.execute(() -> Http.post("https://meteorclient.com/api/online/leave").send()); + MeteorExecutor.execute(() -> Http.post("https://meteorclient.com/api/online/leave").ignoreExceptions().send()); } } diff --git a/src/main/java/meteordevelopment/meteorclient/utils/player/TitleScreenCredits.java b/src/main/java/meteordevelopment/meteorclient/utils/player/TitleScreenCredits.java index 1481b9e137..96aafa97fb 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/player/TitleScreenCredits.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/player/TitleScreenCredits.java @@ -49,6 +49,7 @@ private static void init() { GithubRepo repo = credit.addon.getRepo(); Http.Request request = Http.get("https://api.github.com/repos/%s/branches/%s".formatted(repo.getOwnerName(), repo.branch())); + request.exceptionHandler(e -> MeteorClient.LOG.error("Could not fetch repository information for addon '%s'.".formatted(credit.addon.name), e)); repo.authenticate(request); HttpResponse res = request.sendJsonResponse(Response.class); diff --git a/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadUtils.java index 0a5b69d560..828fb2c48e 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/render/PlayerHeadUtils.java @@ -1,6 +1,7 @@ package meteordevelopment.meteorclient.utils.render; import com.google.gson.Gson; +import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.systems.accounts.TexturesJson; import meteordevelopment.meteorclient.systems.accounts.UuidToProfileResponse; import meteordevelopment.meteorclient.utils.PostInit; @@ -28,7 +29,9 @@ public static PlayerHeadTexture fetchHead(UUID id) { } public static String getSkinUrl(UUID id) { - UuidToProfileResponse res2 = Http.get("https://sessionserver.mojang.com/session/minecraft/profile/" + id).sendJson(UuidToProfileResponse.class); + UuidToProfileResponse res2 = Http.get("https://sessionserver.mojang.com/session/minecraft/profile/" + id) + .exceptionHandler(e -> MeteorClient.LOG.error("Could not contact mojang session servers.", e)) + .sendJson(UuidToProfileResponse.class); if (res2 == null) return null; String base64Textures = res2.getPropertyValue("textures"); From 17ec839b71561a3a15990fe6054e54a8170d3146 Mon Sep 17 00:00:00 2001 From: RacoonDog <32882447+RacoonDog@users.noreply.github.com> Date: Sat, 13 Jul 2024 14:47:00 -0400 Subject: [PATCH 55/66] fix nuker render cube size --- .../systems/modules/world/Nuker.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java index 42801dc61f..0bcbd45cf7 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java @@ -253,9 +253,8 @@ public class Nuker extends Module { private int timer; private int noBlockTimer; - private BlockPos.Mutable pos1 = new BlockPos.Mutable(); // Rendering for cubes - private BlockPos.Mutable pos2 = new BlockPos.Mutable(); - private Box box; + private final BlockPos.Mutable pos1 = new BlockPos.Mutable(); // Rendering for cubes + private final BlockPos.Mutable pos2 = new BlockPos.Mutable(); int maxh = 0; int maxv = 0; @@ -272,11 +271,16 @@ public void onActivate() { @EventHandler private void onRender(Render3DEvent event) { - if (enableRenderBounding.get()){ + if (enableRenderBounding.get()) { // Render bounding box if cube and should break stuff if (shape.get() != Shape.Sphere && mode.get() != Mode.Smash) { - box = new Box(pos1.toCenterPos(), pos2.toCenterPos()); - event.renderer.box(box, sideColorBox.get(), lineColorBox.get(), shapeModeBox.get(), 0); + int minX = Math.min(pos1.getX(), pos2.getX()); + int minY = Math.min(pos1.getY(), pos2.getY()); + int minZ = Math.min(pos1.getZ(), pos2.getZ()); + int maxX = Math.max(pos1.getX(), pos2.getX()); + int maxY = Math.max(pos1.getY(), pos2.getY()); + int maxZ = Math.max(pos1.getZ(), pos2.getZ()); + event.renderer.box(minX, minY, minZ, maxX, maxY, maxZ, sideColorBox.get(), lineColorBox.get(), shapeModeBox.get(), 0); } } } @@ -341,7 +345,7 @@ private void onTickPre(TickEvent.Pre event) { if (mode.get() == Mode.Flatten){ pos1.setY((int) Math.floor(pY)); } - box = new Box(pos1.toCenterPos(), pos2.toCenterPos()); + Box box = new Box(pos1.toCenterPos(), pos2.toCenterPos()); // Find blocks to break BlockIterator.register(Math.max((int) Math.ceil(range.get()+1), maxh), Math.max((int) Math.ceil(range.get()), maxv), (blockPos, blockState) -> { From babc0c409c2c08cd69ab4398e6e5343b6222a1cc Mon Sep 17 00:00:00 2001 From: Jim Krok Date: Mon, 8 Jul 2024 20:12:05 -0400 Subject: [PATCH 56/66] fix(AutoWalk): Calculate x & z on first tick Calculate x & z on first tick() in the BaritonePathManager GoalDirection class, to fix AutoWalk smart mode so baritone walks in the direction the player is facing. This fixes an issue where smart mode always starts walking towards 0,0. --- .../meteorclient/pathing/BaritonePathManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/pathing/BaritonePathManager.java b/src/main/java/meteordevelopment/meteorclient/pathing/BaritonePathManager.java index 408c7288f0..742f707a88 100644 --- a/src/main/java/meteordevelopment/meteorclient/pathing/BaritonePathManager.java +++ b/src/main/java/meteordevelopment/meteorclient/pathing/BaritonePathManager.java @@ -178,8 +178,8 @@ public static double calculate(double xDiff, double zDiff) { } public void tick() { - if (timer > 20) { - timer = 0; + if (timer <= 0) { + timer = 20; Vec3d pos = mc.player.getPos(); float theta = (float) Math.toRadians(yaw); @@ -188,7 +188,7 @@ public void tick() { z = (int) Math.floor(pos.z + (double) MathHelper.cos(theta) * 100); } - timer++; + timer--; } public boolean isInGoal(int x, int y, int z) { From 3f45b4eecd4376836d9e90b057f4c8148cd5713e Mon Sep 17 00:00:00 2001 From: MineGame159 Date: Tue, 16 Jul 2024 11:36:18 +0200 Subject: [PATCH 57/66] Fix README lines of code badge [no ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 185c474fa0..07237743e4 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ GitHub contributors
GitHub code size in bytes - GitHub lines of code + GitHub lines of code ## Usage From af60c8e83e67b788eb4b99ead08d3262bf3529e7 Mon Sep 17 00:00:00 2001 From: MineGame159 Date: Tue, 16 Jul 2024 14:22:01 +0200 Subject: [PATCH 58/66] Track waypoints using UUIDs, fix multiple waypoints with the same name, compatible with old waypoints --- .../commands/commands/WaypointCommand.java | 2 +- .../modules/render/WaypointsModule.java | 25 +++--- .../systems/waypoints/Waypoint.java | 28 +++++- .../systems/waypoints/Waypoints.java | 88 +++++++++++++------ 4 files changed, 103 insertions(+), 40 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/commands/commands/WaypointCommand.java b/src/main/java/meteordevelopment/meteorclient/commands/commands/WaypointCommand.java index ac776f63c6..5771766766 100644 --- a/src/main/java/meteordevelopment/meteorclient/commands/commands/WaypointCommand.java +++ b/src/main/java/meteordevelopment/meteorclient/commands/commands/WaypointCommand.java @@ -27,7 +27,7 @@ public WaypointCommand() { @Override public void build(LiteralArgumentBuilder builder) { builder.then(literal("list").executes(context -> { - if (Waypoints.get().waypoints.isEmpty()) error("No created waypoints."); + if (Waypoints.get().isEmpty()) error("No created waypoints."); else { info(Formatting.WHITE + "Created Waypoints:"); for (Waypoint waypoint : Waypoints.get()) { diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java index 569c4ba515..132754c0ef 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/render/WaypointsModule.java @@ -28,6 +28,7 @@ import meteordevelopment.meteorclient.utils.render.NametagUtils; import meteordevelopment.meteorclient.utils.render.color.Color; import meteordevelopment.orbit.EventHandler; +import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.DeathScreen; import net.minecraft.text.MutableText; import net.minecraft.text.Text; @@ -37,7 +38,7 @@ import java.text.SimpleDateFormat; import java.util.Date; -import java.util.ListIterator; +import java.util.Iterator; import static meteordevelopment.meteorclient.utils.player.ChatUtils.formatCoords; @@ -181,13 +182,14 @@ public void addDeath(Vec3d deathPos) { private void cleanDeathWPs(int max) { int oldWpC = 0; - ListIterator wps = Waypoints.get().iteratorReverse(); - while (wps.hasPrevious()) { - Waypoint wp = wps.previous(); - if (wp.name.get().startsWith("Death ") && "skull".equals(wp.icon.get())) { + for (Iterator it = Waypoints.get().iterator(); it.hasNext();) { + Waypoint wp = it.next(); + + if (wp.name.get().startsWith("Death ") && wp.icon.get().equals("skull")) { oldWpC++; + if (oldWpC > max) - Waypoints.get().remove(wp); + it.remove(); } } } @@ -219,7 +221,7 @@ private void initTable(GuiTheme theme, WTable table) { }; WButton edit = table.add(theme.button(GuiRenderer.EDIT)).widget(); - edit.action = () -> mc.setScreen(new EditWaypointScreen(theme, waypoint, null)); + edit.action = () -> mc.setScreen(new EditWaypointScreen(theme, waypoint, () -> initTable(theme, table))); // Goto if (validDim) { @@ -248,7 +250,7 @@ private void initTable(GuiTheme theme, WTable table) { create.action = () -> mc.setScreen(new EditWaypointScreen(theme, null, () -> initTable(theme, table))); } - private class EditWaypointScreen extends EditSystemScreen { + private static class EditWaypointScreen extends EditSystemScreen { public EditWaypointScreen(GuiTheme theme, Waypoint value, Runnable reload) { super(theme, value, reload); } @@ -256,14 +258,17 @@ public EditWaypointScreen(GuiTheme theme, Waypoint value, Runnable reload) { @Override public Waypoint create() { return new Waypoint.Builder() - .pos(mc.player.getBlockPos().up(2)) + .pos(MinecraftClient.getInstance().player.getBlockPos().up(2)) .dimension(PlayerUtils.getDimension()) .build(); } @Override public boolean save() { - return !isNew || Waypoints.get().add(value); + if (value.name.get().isBlank()) return false; + + Waypoints.get().add(value); + return true; } @Override diff --git a/src/main/java/meteordevelopment/meteorclient/systems/waypoints/Waypoint.java b/src/main/java/meteordevelopment/meteorclient/systems/waypoints/Waypoint.java index 46bbcbd4b5..f09e53cde1 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/waypoints/Waypoint.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/waypoints/Waypoint.java @@ -20,6 +20,7 @@ import java.util.Map; import java.util.Objects; +import java.util.UUID; public class Waypoint implements ISerializable { public final Settings settings = new Settings(); @@ -93,9 +94,19 @@ public class Waypoint implements ISerializable { .build() ); - private Waypoint() {} + public final UUID uuid; + + private Waypoint() { + uuid = UUID.randomUUID(); + } + public Waypoint(NbtElement tag) { - fromTag((NbtCompound) tag); + NbtCompound nbt = (NbtCompound) tag; + + if (nbt.containsUuid("uuid")) uuid = nbt.getUuid("uuid"); + else uuid = UUID.randomUUID(); + + fromTag(nbt); } public void renderIcon(double x, double y, double a, double size) { @@ -177,6 +188,7 @@ public Waypoint build() { public NbtCompound toTag() { NbtCompound tag = new NbtCompound(); + tag.putUuid("uuid", uuid); tag.put("settings", settings.toTag()); return tag; @@ -196,6 +208,16 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Waypoint waypoint = (Waypoint) o; - return Objects.equals(waypoint.name.get(), this.name.get()); + return Objects.equals(uuid, waypoint.uuid); + } + + @Override + public int hashCode() { + return Objects.hashCode(uuid); + } + + @Override + public String toString() { + return name.get(); } } diff --git a/src/main/java/meteordevelopment/meteorclient/systems/waypoints/Waypoints.java b/src/main/java/meteordevelopment/meteorclient/systems/waypoints/Waypoints.java index 5c7e74932e..193dae163d 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/waypoints/Waypoints.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/waypoints/Waypoints.java @@ -21,21 +21,22 @@ import net.minecraft.client.texture.NativeImage; import net.minecraft.client.texture.NativeImageBackedTexture; import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; import org.jetbrains.annotations.NotNull; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; public class Waypoints extends System implements Iterable { public static final String[] BUILTIN_ICONS = {"square", "circle", "triangle", "star", "diamond", "skull"}; public final Map icons = new ConcurrentHashMap<>(); - public final Map waypoints = new ConcurrentHashMap<>(); + private final List waypoints = Collections.synchronizedList(new ArrayList<>()); public Waypoints() { super(null); @@ -56,42 +57,51 @@ public void init() { } File[] files = iconsFolder.listFiles(); - if (files == null) { - return; - } + if (files == null) return; + for (File file : files) { if (file.getName().endsWith(".png")) { try { String name = file.getName().replace(".png", ""); AbstractTexture texture = new NativeImageBackedTexture(NativeImage.read(new FileInputStream(file))); icons.put(name, texture); - } catch (IOException e) { - e.printStackTrace(); + } + catch (IOException e) { + MeteorClient.LOG.error("Failed to read a waypoint icon", e); } } } } + /** + * Adds a waypoint or saves it if it already exists + * @return {@code true} if waypoint already exists + */ public boolean add(Waypoint waypoint) { - Waypoint added = waypoints.put(waypoint.name.get().toLowerCase(Locale.ROOT), waypoint); - if (added != null) { + if (waypoints.contains(waypoint)) { save(); + return true; } - return added != null; + waypoints.add(waypoint); + save(); + + return false; } public boolean remove(Waypoint waypoint) { - Waypoint removed = waypoints.remove(waypoint.name.get().toLowerCase(Locale.ROOT)); - if (removed != null) { - save(); - } + boolean removed = waypoints.remove(waypoint); + if (removed) save(); - return removed != null; + return removed; } public Waypoint get(String name) { - return waypoints.get(name.toLowerCase(Locale.ROOT)); + for (Waypoint waypoint : waypoints) { + if (waypoint.name.get().equalsIgnoreCase(name)) return waypoint; + } + + return null; } @EventHandler @@ -129,30 +139,56 @@ public boolean isEmpty() { @Override public @NotNull Iterator iterator() { - return waypoints.values().iterator(); - } - - public ListIterator iteratorReverse() { - return new ArrayList<>(waypoints.values()).listIterator(waypoints.size()); + return new WaypointIterator(); } private void copyIcon(File file) { - StreamUtils.copy(Waypoints.class.getResourceAsStream("/assets/" + MeteorClient.MOD_ID + "/textures/icons/waypoints/" + file.getName()), file); + String path = "/assets/" + MeteorClient.MOD_ID + "/textures/icons/waypoints/" + file.getName(); + InputStream in = Waypoints.class.getResourceAsStream(path); + + if (in == null) { + MeteorClient.LOG.error("Failed to read a resource: {}", path); + return; + } + + StreamUtils.copy(in, file); } @Override public NbtCompound toTag() { NbtCompound tag = new NbtCompound(); - tag.put("waypoints", NbtUtils.listToTag(waypoints.values())); + tag.put("waypoints", NbtUtils.listToTag(waypoints)); return tag; } @Override public Waypoints fromTag(NbtCompound tag) { - Map fromNbt = NbtUtils.listFromTag(tag.getList("waypoints", 10), Waypoint::new).stream().collect(Collectors.toMap(o -> o.name.get().toLowerCase(Locale.ROOT), o -> o)); - this.waypoints.clear(); - this.waypoints.putAll(fromNbt); + waypoints.clear(); + + for (NbtElement waypointTag : tag.getList("waypoints", 10)) { + waypoints.add(new Waypoint(waypointTag)); + } return this; } + + private final class WaypointIterator implements Iterator { + private final Iterator it = waypoints.iterator(); + + @Override + public boolean hasNext() { + return it.hasNext(); + } + + @Override + public Waypoint next() { + return it.next(); + } + + @Override + public void remove() { + Iterator.super.remove(); + save(); + } + } } From 21e034d007a9ae06806a2097f5f89e54c8037a3a Mon Sep 17 00:00:00 2001 From: MineGame159 Date: Wed, 17 Jul 2024 20:03:56 +0200 Subject: [PATCH 59/66] Fix binding keys --- .../meteordevelopment/meteorclient/systems/modules/Modules.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java index c1edf461a6..5b0b98343a 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java @@ -246,7 +246,7 @@ private boolean onBinding(boolean isKey, int value, int modifiers) { if (!isBinding()) return false; if (awaitingKeyRelease) { - if (!isKey || value != GLFW.GLFW_KEY_ENTER) return false; + if (!isKey || (value != GLFW.GLFW_KEY_ENTER && value != GLFW.GLFW_KEY_KP_ENTER)) return false; awaitingKeyRelease = false; return false; From ab5f7ac151ca83879ea0a112fdb5e7bd119f5dd4 Mon Sep 17 00:00:00 2001 From: MineGame159 Date: Fri, 19 Jul 2024 10:19:51 +0200 Subject: [PATCH 60/66] Fix Axiom compatibility --- .../meteorclient/mixin/BlockModelRendererMixin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/BlockModelRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/BlockModelRendererMixin.java index 00606da5be..97d9aa82dd 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/BlockModelRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/BlockModelRendererMixin.java @@ -27,8 +27,8 @@ public abstract class BlockModelRendererMixin { @Unique private final ThreadLocal alphas = new ThreadLocal<>(); - @Inject(method = "render(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLnet/minecraft/util/math/random/Random;JI)V", at = @At("HEAD"), cancellable = true) - private void onRender(BlockRenderView world, BakedModel model, BlockState state, BlockPos pos, MatrixStack matrices, VertexConsumer vertexConsumer, boolean cull, Random random, long seed, int overlay, CallbackInfo info) { + @Inject(method = {"renderSmooth", "renderFlat"}, at = @At("HEAD"), cancellable = true) + private void onRenderSmooth(BlockRenderView world, BakedModel model, BlockState state, BlockPos pos, MatrixStack matrices, VertexConsumer vertexConsumer, boolean cull, Random random, long seed, int overlay, CallbackInfo info) { int alpha = Xray.getAlpha(state, pos); if (alpha == 0) info.cancel(); From 30a1b68f7eef5e18c1d88394ebd6a7ca8c4b64a7 Mon Sep 17 00:00:00 2001 From: MineGame159 Date: Fri, 19 Jul 2024 10:46:09 +0200 Subject: [PATCH 61/66] Add a per-entity cooldown to AutoNametag --- .../systems/modules/world/AutoNametag.java | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoNametag.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoNametag.java index 3e1ea5576a..3444077d42 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoNametag.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/AutoNametag.java @@ -5,6 +5,8 @@ package meteordevelopment.meteorclient.systems.modules.world; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; @@ -21,6 +23,7 @@ import net.minecraft.item.Items; import net.minecraft.util.Hand; +import java.util.Iterator; import java.util.Set; public class AutoNametag extends Module { @@ -62,6 +65,8 @@ public class AutoNametag extends Module { .build() ); + private final Object2IntMap entityCooldowns = new Object2IntOpenHashMap<>(); + private Entity target; private boolean offHand; @@ -69,9 +74,14 @@ public AutoNametag() { super(Categories.World, "auto-nametag", "Automatically uses nametags on entities without a nametag. WILL nametag ALL entities in the specified distance."); } + @Override + public void onDeactivate() { + entityCooldowns.clear(); + } + @EventHandler - private void onTick(TickEvent.Pre event) { - // Nametag in hobar + private void onTickPre(TickEvent.Pre event) { + // Find nametag in hotbar FindItemResult findNametag = InvUtils.findInHotbar(Items.NAME_TAG); if (!findNametag.found()) { @@ -80,33 +90,45 @@ private void onTick(TickEvent.Pre event) { return; } - // Target target = TargetUtils.get(entity -> { if (!PlayerUtils.isWithin(entity, range.get())) return false; if (!entities.get().contains(entity.getType())) return false; - if (entity.hasCustomName()) { - return renametag.get() && !entity.getCustomName().equals(mc.player.getInventory().getStack(findNametag.slot()).getName()); - } - return true; - }, priority.get()); - if (target == null) return; + if (entity.hasCustomName() && (!renametag.get() || entity.getCustomName().equals(mc.player.getInventory().getStack(findNametag.slot()).getName()))) + return false; + + return entityCooldowns.getInt(entity) <= 0; + }, priority.get()); + if (target == null) + return; // Swapping slots InvUtils.swap(findNametag.slot(), true); offHand = findNametag.isOffhand(); - // Interaction if (rotate.get()) Rotations.rotate(Rotations.getYaw(target), Rotations.getPitch(target), -100, this::interact); else interact(); } + @EventHandler + private void onTickPost(TickEvent.Post event) { + for (Iterator it = entityCooldowns.keySet().iterator(); it.hasNext(); ) { + Entity entity = it.next(); + int cooldown = entityCooldowns.getInt(entity) - 1; + + if (cooldown <= 0) it.remove(); + else entityCooldowns.put(entity, cooldown); + } + } + private void interact() { mc.interactionManager.interactEntity(mc.player, target, offHand ? Hand.OFF_HAND : Hand.MAIN_HAND); InvUtils.swapBack(); + + entityCooldowns.put(target, 20); } } From c7d2f7f2f1d0b0b259617f486fff9a01134d10ed Mon Sep 17 00:00:00 2001 From: MineGame159 Date: Fri, 19 Jul 2024 22:11:02 +0200 Subject: [PATCH 62/66] AutoLog will now disable AutoReconnect after a disconnect --- .../meteorclient/systems/modules/misc/AutoLog.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoLog.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoLog.java index 8e9f1ba7e5..26c4b5e1be 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoLog.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoLog.java @@ -14,6 +14,7 @@ import meteordevelopment.meteorclient.systems.friends.Friends; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.entity.DamageUtils; import meteordevelopment.meteorclient.utils.player.PlayerUtils; @@ -22,7 +23,9 @@ import net.minecraft.entity.decoration.EndCrystalEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.packet.s2c.common.DisconnectS2CPacket; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; +import net.minecraft.util.Colors; public class AutoLog extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); @@ -137,7 +140,15 @@ private void onTick(TickEvent.Post event) { } private void disconnect(String reason) { - mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(Text.literal("[AutoLog] " + reason))); + MutableText text = Text.literal("[AutoLog] " + reason); + AutoReconnect autoReconnect = Modules.get().get(AutoReconnect.class); + + if (autoReconnect.isActive()) { + text.append(Text.literal("\n\nINFO - AutoReconnect was disabled").withColor(Colors.GRAY)); + autoReconnect.toggle(); + } + + mc.player.networkHandler.onDisconnect(new DisconnectS2CPacket(text)); } private class StaticListener { From fdf8e1cb151f4f98677befb1c82d665168093a26 Mon Sep 17 00:00:00 2001 From: Anand Surendra Bhasme <96731982+Hyped1XGeek@users.noreply.github.com> Date: Sat, 20 Jul 2024 01:57:11 +0530 Subject: [PATCH 63/66] Fix auto dimension in NoFall overriding every item instead of just the bucket and removed the setting, making it always enabled (#4759) --- .../meteorclient/systems/modules/movement/NoFall.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java index 0ec72a7f64..006c472e78 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java @@ -24,7 +24,6 @@ import meteordevelopment.meteorclient.utils.player.PlayerUtils; import meteordevelopment.meteorclient.utils.player.Rotations; import meteordevelopment.meteorclient.utils.world.BlockUtils; -import meteordevelopment.meteorclient.utils.world.Dimension; import meteordevelopment.orbit.EventHandler; import net.minecraft.block.Block; import net.minecraft.block.Blocks; @@ -74,14 +73,6 @@ public class NoFall extends Module { .build() ); - private final Setting autoDimension = sgGeneral.add(new BoolSetting.Builder() - .name("auto-dimension") - .description("Use powder snow bucket in nether.") - .defaultValue(true) - .visible(() -> mode.get() == Mode.Place) - .build() - ); - private final Setting antiBounce = sgGeneral.add(new BoolSetting.Builder() .name("anti-bounce") .description("Disables bouncing on slime-block and bed upon landing.") @@ -157,7 +148,7 @@ private void onTick(TickEvent.Pre event) { // Bucket mode else if (mode.get() == Mode.Place) { - PlacedItem placedItem1 = autoDimension.get() && PlayerUtils.getDimension() == Dimension.Nether ? PlacedItem.PowderSnow : placedItem.get(); + PlacedItem placedItem1 = mc.world.getDimension().ultrawarm() && placedItem.get() == PlacedItem.Bucket ? PlacedItem.PowderSnow : placedItem.get(); if (mc.player.fallDistance > 3 && !EntityUtils.isAboveWater(mc.player)) { Item item = placedItem1.item; From f99666f6f91d2f2a51f7cd86483747468c98c0c0 Mon Sep 17 00:00:00 2001 From: Anand Surendra Bhasme <96731982+AnandBhasme@users.noreply.github.com> Date: Sun, 21 Jul 2024 18:56:53 +0530 Subject: [PATCH 64/66] NoFall consistently picks up Powder Snow after fall (#4761) --- .../meteorclient/systems/modules/movement/NoFall.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java index 006c472e78..af4259de2c 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/NoFall.java @@ -178,6 +178,8 @@ else if (mode.get() == Mode.Place) { timer++; if (mc.player.getBlockStateAtPos().getBlock() == placedItem1.block) { useItem(InvUtils.findInHotbar(Items.BUCKET), false, targetPos, true); + } else if (mc.world.getBlockState(mc.player.getBlockPos().down()).getBlock() == Blocks.POWDER_SNOW && mc.player.fallDistance==0 && placedItem1.block==Blocks.POWDER_SNOW){ //check if the powder snow block is still there and the player is on the ground + useItem(InvUtils.findInHotbar(Items.BUCKET), false, targetPos.down(), true); } } } From 4dc99b3ca91f19696efeeb86494e6b8f269d78a9 Mon Sep 17 00:00:00 2001 From: MineGame159 Date: Sun, 21 Jul 2024 16:37:49 +0200 Subject: [PATCH 65/66] Build against 1.21 version of Baritone --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 4ae76d382c..75a09a970c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ archives_base_name=meteor-client # Dependency Versions # Baritone (https://github.com/MeteorDevelopment/baritone) -baritone_version=1.20.6 +baritone_version=1.21 # Sodium (https://github.com/CaffeineMC/sodium-fabric) sodium_version=mc1.21-0.5.9 From 271a0e5da2e6bc7e3da7798df3724b79d0ece4ec Mon Sep 17 00:00:00 2001 From: Anand Surendra Bhasme <96731982+AnandBhasme@users.noreply.github.com> Date: Tue, 23 Jul 2024 15:12:03 +0530 Subject: [PATCH 66/66] Add entities to AutoLog (#4766) --- .../systems/modules/misc/AutoLog.java | 121 ++++++++++++++---- 1 file changed, 96 insertions(+), 25 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoLog.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoLog.java index 26c4b5e1be..d2a786aa75 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoLog.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoLog.java @@ -5,9 +5,14 @@ package meteordevelopment.meteorclient.systems.modules.misc; +import java.util.HashMap; +import java.util.Set; +import java.util.Map; + import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.BoolSetting; +import meteordevelopment.meteorclient.settings.EntityTypeListSetting; import meteordevelopment.meteorclient.settings.IntSetting; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.SettingGroup; @@ -20,15 +25,18 @@ import meteordevelopment.meteorclient.utils.player.PlayerUtils; import meteordevelopment.orbit.EventHandler; import net.minecraft.entity.Entity; -import net.minecraft.entity.decoration.EndCrystalEntity; +import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.packet.s2c.common.DisconnectS2CPacket; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Colors; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; public class AutoLog extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); + private final SettingGroup sgEntities = settings.createGroup("Entities"); private final Setting health = sgGeneral.add(new IntSetting.Builder() .name("health") @@ -60,20 +68,47 @@ public class AutoLog extends Module { .build() ); - private final Setting crystalLog = sgGeneral.add(new BoolSetting.Builder() - .name("crystal-nearby") - .description("Disconnects when a crystal appears near you.") - .defaultValue(false) + private final Setting>> entities = sgEntities.add(new EntityTypeListSetting.Builder() + .name("entities") + .description("Disconnects when a specified entity is present within a specified range.") + .defaultValue(EntityType.END_CRYSTAL) + .build() + ); + + private final Setting useTotalCount = sgEntities.add(new BoolSetting.Builder() + .name("use-total-count") + .description("Toggle between counting the total number of all selected entities or each entity individually.") + .defaultValue(true) + .visible(() -> !entities.get().isEmpty()) + .build()); + + private final Setting combinedEntityThreshold = sgEntities.add(new IntSetting.Builder() + .name("combined-entity-threshold") + .description("The minimum total number of selected entities that must be near you before disconnection occurs.") + .defaultValue(10) + .min(1) + .sliderMax(32) + .visible(() -> useTotalCount.get() && !entities.get().isEmpty()) .build() ); - private final Setting range = sgGeneral.add(new IntSetting.Builder() + private final Setting individualEntityThreshold = sgEntities.add(new IntSetting.Builder() + .name("individual-entity-threshold") + .description("The minimum number of entities individually that must be near you before disconnection occurs.") + .defaultValue(2) + .min(1) + .sliderMax(16) + .visible(() -> !useTotalCount.get() && !entities.get().isEmpty()) + .build() + ); + + private final Setting range = sgEntities.add(new IntSetting.Builder() .name("range") - .description("How close a crystal has to be to you before you disconnect.") - .defaultValue(4) - .range(1, 10) - .sliderMax(5) - .visible(crystalLog::get) + .description("How close an entity has to be to you before you disconnect.") + .defaultValue(5) + .min(1) + .sliderMax(16) + .visible(() -> !entities.get().isEmpty()) .build() ); @@ -91,6 +126,10 @@ public class AutoLog extends Module { .build() ); + //Declaring variables outside the loop for better efficiency + private final Object2IntMap> entityCounts = new Object2IntOpenHashMap<>(); + private int totalEntities = 0; + public AutoLog() { super(Categories.Combat, "auto-log", "Automatically disconnects you when certain requirements are met."); } @@ -110,31 +149,63 @@ private void onTick(TickEvent.Post event) { } } - if (smart.get() && playerHealth + mc.player.getAbsorptionAmount() - PlayerUtils.possibleHealthReductions() < health.get()){ + if (smart.get() && playerHealth + mc.player.getAbsorptionAmount() + - PlayerUtils.possibleHealthReductions() < health.get()) { disconnect("Health was going to be lower than " + health.get() + "."); if (toggleOff.get()) this.toggle(); } - - if (!onlyTrusted.get() && !instantDeath.get() && !crystalLog.get()) return; // only check all entities if needed + if (!onlyTrusted.get() && !instantDeath.get() && entities.get().isEmpty()) + return; // only check all entities if needed for (Entity entity : mc.world.getEntities()) { if (entity instanceof PlayerEntity player && player.getUuid() != mc.player.getUuid()) { if (onlyTrusted.get() && player != mc.player && !Friends.get().isFriend(player)) { - disconnect("A non-trusted player appeared in your render distance."); - if (toggleOff.get()) this.toggle(); - break; + disconnect("A non-trusted player appeared in your render distance."); + if (toggleOff.get()) this.toggle(); + break; } if (instantDeath.get() && PlayerUtils.isWithin(entity, 8) && DamageUtils.getAttackDamage(player, mc.player) - > playerHealth + mc.player.getAbsorptionAmount()) { + > playerHealth + mc.player.getAbsorptionAmount()) { disconnect("Anti-32k measures."); - if (toggleOff.get()) this.toggle(); + if (toggleOff.get()) + this.toggle(); break; } } - if (crystalLog.get() && entity instanceof EndCrystalEntity && PlayerUtils.isWithin(entity, range.get())) { - disconnect("End Crystal appeared within specified range."); - if (toggleOff.get()) this.toggle(); + } + + // Entities detection Logic + if (!entities.get().isEmpty()) { + // Reset totalEntities count and clear the entityCounts map + totalEntities = 0; + entityCounts.clear(); + + // Iterate through all entities in the world and count the ones that match the selected types and are within range + for (Entity entity : mc.world.getEntities()) { + if (PlayerUtils.isWithin(entity, range.get()) && entities.get().contains(entity.getType())) { + totalEntities++; + if (!useTotalCount.get()) { + entityCounts.put(entity.getType(), entityCounts.getOrDefault(entity.getType(), 0) + 1); + } + } + } + + if (useTotalCount.get() && totalEntities >= combinedEntityThreshold.get()) { + disconnect("Total number of selected entities within range exceeded the limit."); + if (toggleOff.get()) + this.toggle(); + } else if (!useTotalCount.get()) { + // Check if the count of each entity type exceeds the specified limit + for (Object2IntMap.Entry> entry : entityCounts.object2IntEntrySet()) { + if (entry.getIntValue() >= individualEntityThreshold.get()) { + disconnect("Number of " + entry.getKey().getName().getString() + + " within range exceeded the limit."); + if (toggleOff.get()) + this.toggle(); + break; + } + } } } } @@ -157,11 +228,11 @@ private void healthListener(TickEvent.Post event) { if (isActive()) disableHealthListener(); else if (Utils.canUpdate() - && !mc.player.isDead() - && mc.player.getHealth() > health.get()) { + && !mc.player.isDead() + && mc.player.getHealth() > health.get()) { toggle(); disableHealthListener(); - } + } } }