From b69c5dd42b94c3f1473d2c14ad68873d0a5724c1 Mon Sep 17 00:00:00 2001 From: GeorgeRNG <81434111+GeorgeRNG@users.noreply.github.com> Date: Thu, 21 Dec 2023 16:10:53 +0000 Subject: [PATCH] a commit made in pure spite --- .../dev/dfonline/codeclient/CodeClient.java | 15 ++++- .../dfonline/codeclient/action/impl/GoTo.java | 27 +++++++-- .../dfonline/codeclient/config/Config.java | 2 +- .../dev/BlockBreakDeltaCalculator.java | 17 +++--- .../mixin/render/MChunkRendererRegion.java | 55 ------------------- src/main/resources/CodeClient.mixins.json | 1 - 6 files changed, 45 insertions(+), 72 deletions(-) delete mode 100644 src/main/java/dev/dfonline/codeclient/mixin/render/MChunkRendererRegion.java diff --git a/src/main/java/dev/dfonline/codeclient/CodeClient.java b/src/main/java/dev/dfonline/codeclient/CodeClient.java index b151675f..b1d4a836 100644 --- a/src/main/java/dev/dfonline/codeclient/CodeClient.java +++ b/src/main/java/dev/dfonline/codeclient/CodeClient.java @@ -13,7 +13,9 @@ import dev.dfonline.codeclient.dev.overlay.ChestPeeker; import dev.dfonline.codeclient.location.Dev; import dev.dfonline.codeclient.location.Location; +import dev.dfonline.codeclient.location.Plot; import dev.dfonline.codeclient.location.Spawn; +import dev.dfonline.codeclient.switcher.StateSwitcher; import dev.dfonline.codeclient.websocket.SocketHandler; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; @@ -31,8 +33,10 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.listener.PacketListener; import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket; import net.minecraft.network.packet.s2c.play.CloseScreenS2CPacket; import net.minecraft.util.Identifier; +import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.NotNull; import org.lwjgl.glfw.GLFW; import org.slf4j.Logger; @@ -80,7 +84,7 @@ public static boolean handlePacket(Packet packet) String name = packet.getClass().getName().replace("net.minecraft.network.packet.s2c.play.",""); // if(!List.of("PlayerListS2CPacket","WorldTimeUpdateS2CPacket","GameMessageS2CPacket","KeepAliveS2CPacket", "ChunkDataS2CPacket", "UnloadChunkS2CPacket","TeamS2CPacket", "ChunkRenderDistanceCenterS2CPacket", "MessageHeaderS2CPacket", "LightUpdateS2CPacket", "OverlayMessageS2CPacket").contains(name)) LOGGER.info(name); - if((MC.currentScreen instanceof GameMenuScreen || MC.currentScreen instanceof ChatScreen) && packet instanceof CloseScreenS2CPacket) { + if((MC.currentScreen instanceof GameMenuScreen || MC.currentScreen instanceof ChatScreen || MC.currentScreen instanceof StateSwitcher) && packet instanceof CloseScreenS2CPacket) { return true; } return false; @@ -110,6 +114,9 @@ public static boolean onSendPacket(Packet packet) if(BuildClip.onPacket(packet)) return true; Event.onSendPacket(packet); String name = packet.getClass().getName().replace("net.minecraft.network.packet.c2s.play.",""); + if(packet instanceof CommandExecutionC2SPacket commandExecutionC2SPacket) { + LOGGER.info(commandExecutionC2SPacket.command()); + } // LOGGER.info(name); return false; } @@ -131,6 +138,12 @@ public static void onTick() { if(editBind.wasPressed()) { MC.setScreen(new DevInventoryScreen(MC.player)); } + if(dev.getSize() == null) { + var pos = new BlockPos(dev.getX() - 1,49,dev.getZ()); + if(CodeClient.MC.world.getBlockState(pos.south(50)).isOf(Blocks.STONE)) dev.setSize(Plot.Size.BASIC); + if(CodeClient.MC.world.getBlockState(pos.south(100)).isOf(Blocks.STONE)) dev.setSize(Plot.Size.LARGE); + if(CodeClient.MC.world.getBlockState(pos.south(300)).isOf(Blocks.STONE)) dev.setSize(Plot.Size.MASSIVE); + } } if(CodeClient.location instanceof Spawn spawn && spawn.consumeHasJustJoined()) { if(autoJoin == AutoJoin.PLOT) { diff --git a/src/main/java/dev/dfonline/codeclient/action/impl/GoTo.java b/src/main/java/dev/dfonline/codeclient/action/impl/GoTo.java index ac2a0630..f3607a07 100644 --- a/src/main/java/dev/dfonline/codeclient/action/impl/GoTo.java +++ b/src/main/java/dev/dfonline/codeclient/action/impl/GoTo.java @@ -25,6 +25,9 @@ public class GoTo extends Action { private ItemStack locationItem; private boolean active; private int buffer = 0; + private int lastTickPackets = 1; + private int thisTickPackets = 0; + boolean doNotSuppress = false; public GoTo(Vec3d target, Callback callback) { super(callback); @@ -55,8 +58,18 @@ public boolean onReceivePacket(Packet packet) { return false; } + @Override + public boolean onSendPacket(Packet packet) { + if(packet instanceof PlayerPositionLookS2CPacket pos) { + if(doNotSuppress) doNotSuppress = false; + else return true; + } + return super.onSendPacket(packet); + } + @Override public void onTick() { + thisTickPackets = 0; if(CodeClient.MC.player == null || CodeClient.MC.getNetworkHandler() == null) { callback(); return; @@ -70,6 +83,7 @@ public void onTick() { } if(locationItem != null) return; hackTowards(); + lastTickPackets=thisTickPackets; } private void locationItemTeleport() { @@ -111,13 +125,14 @@ private void hackTowards() { double distance = offset.length(); Vec3d jump = distance > maxLength ? pos.add(offset.normalize().multiply(maxLength)) : target; if(distance > 10) { - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); - CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); + for (int i = 0; i < Math.min(lastTickPackets + 5,50); i++) { + thisTickPackets++; + this.doNotSuppress = true; + CodeClient.MC.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(false)); + } } + thisTickPackets++; + this.doNotSuppress = true; CodeClient.MC.player.setPos(jump.x, jump.y, jump.z); } } diff --git a/src/main/java/dev/dfonline/codeclient/config/Config.java b/src/main/java/dev/dfonline/codeclient/config/Config.java index 64f9b748..35521bd4 100644 --- a/src/main/java/dev/dfonline/codeclient/config/Config.java +++ b/src/main/java/dev/dfonline/codeclient/config/Config.java @@ -377,7 +377,7 @@ public YetAnotherConfigLib getLibConfig() { .build()) .option(Option.createBuilder(boolean.class) .name(Text.literal("Custom Block Breaking")) - .description(OptionDescription.of(Text.literal("Keep codeblocks safe from accidental breaking."),Text.literal("They will have the survival breaking animation."),Text.literal("Breaking multiple will temporarily increase the speed."))) + .description(OptionDescription.of(Text.literal("Keep codeblocks safe from accidental breaking."),Text.literal("They will have the survival breaking animation."),Text.literal("They will take 5 ticks to break (0.25 seconds)"))) .binding( false, () -> CustomBlockBreaking, diff --git a/src/main/java/dev/dfonline/codeclient/dev/BlockBreakDeltaCalculator.java b/src/main/java/dev/dfonline/codeclient/dev/BlockBreakDeltaCalculator.java index 802df319..acef105b 100644 --- a/src/main/java/dev/dfonline/codeclient/dev/BlockBreakDeltaCalculator.java +++ b/src/main/java/dev/dfonline/codeclient/dev/BlockBreakDeltaCalculator.java @@ -27,14 +27,15 @@ public static void breakBlock(BlockPos pos) { * The insanity previously mentioned. */ public static float calculateBlockDelta(BlockPos pos) { - AtomicReference speed = new AtomicReference<>(0F); - oldBlocks.getBlocks().forEach(recentBlock -> { - float age = (float) recentBlock.howLongAgo() / 1000; - float recency = Math.max(10.0F - age,0); - float score = recency / 100; - speed.updateAndGet(v -> (v + score)); - }); - return Math.max(speed.get(), 0.1F); + return 0.2F; +// AtomicReference speed = new AtomicReference<>(0F); +// oldBlocks.getBlocks().forEach(recentBlock -> { +// float age = (float) recentBlock.howLongAgo() / 1000; +// float recency = Math.max(10.0F - age,0); +// float score = recency / 100; +// speed.updateAndGet(v -> (v + score)); +// }); +// return Math.max(speed.get(), 0.1F); } private static class RecentBlocks { diff --git a/src/main/java/dev/dfonline/codeclient/mixin/render/MChunkRendererRegion.java b/src/main/java/dev/dfonline/codeclient/mixin/render/MChunkRendererRegion.java deleted file mode 100644 index 5404ed63..00000000 --- a/src/main/java/dev/dfonline/codeclient/mixin/render/MChunkRendererRegion.java +++ /dev/null @@ -1,55 +0,0 @@ -package dev.dfonline.codeclient.mixin.render; - -import dev.dfonline.codeclient.CodeClient; -import dev.dfonline.codeclient.dev.NoClip; -import dev.dfonline.codeclient.location.Plot; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(World.class) -public abstract class MChunkRendererRegion { - @Shadow public abstract boolean setBlockState(BlockPos pos, BlockState state); - -// @Inject(method = "getBlockState", at = @At("HEAD"), cancellable = true) -// private void getAppearance(BlockPos pos, CallbackInfoReturnable cir) { -// if(CodeClient.location instanceof Plot plot) { -// Boolean inPlot = plot.isInPlot(pos); -// if(inPlot != null && !inPlot) { -// cir.setReturnValue(Blocks.VOID_AIR.getDefaultState()); -// } -// BlockState state = NoClip.replaceBlockAt(pos); -// if(state != null) { -// CodeClient.MC.world.setBlockState(pos, state); -// this.setBlockState(pos, state); -// cir.setReturnValue(state); -// } -// } -// } - - @Inject(method = "getBlockState", at = @At("RETURN")) - private void getSize(BlockPos pos, CallbackInfoReturnable cir) { - BlockState block = cir.getReturnValue(); - if(block == null) return; - if(CodeClient.location instanceof Plot plot) { - if(plot.getX() == null) return; - if(plot.getSize() != null) return; - - if(pos.getY() != 49) return; - if(block.getBlock() != Blocks.STONE) return; - - if(pos.getX() + 1 > plot.getX()) return; - if(pos.getX() < plot.getX() - 19) return; - - if(pos.getZ() == plot.getZ() + 50) plot.setSize(Plot.Size.BASIC); - if(pos.getZ() == plot.getZ() + 100) plot.setSize(Plot.Size.LARGE); - if(pos.getZ() == plot.getZ() + 300) plot.setSize(Plot.Size.MASSIVE); - } - } -} diff --git a/src/main/resources/CodeClient.mixins.json b/src/main/resources/CodeClient.mixins.json index d5715fca..815dd7a5 100644 --- a/src/main/resources/CodeClient.mixins.json +++ b/src/main/resources/CodeClient.mixins.json @@ -15,7 +15,6 @@ "entity.player.MPlayerEntity", "network.MClientCommonPlayNetworkHandler", "network.MClientConnection", - "render.MChunkRendererRegion", "render.MDebugRenderer", "render.hud.MDrawContext", "render.hud.MInGameHud",