From 9a6b7540bd60fb51b685d20946a5cde391a8e5dc Mon Sep 17 00:00:00 2001 From: Alexander01998 Date: Tue, 19 Dec 2023 19:45:07 +0100 Subject: [PATCH] Update to 23w51a/b --- .../net/wurstclient/commands/PotionCmd.java | 33 +++++++++---------- .../net/wurstclient/hacks/AutoEatHack.java | 4 ++- .../net/wurstclient/hacks/AutoPotionHack.java | 4 ++- .../net/wurstclient/hacks/LiquidsHack.java | 2 +- .../java/net/wurstclient/hacks/ReachHack.java | 9 ++--- .../net/wurstclient/hacks/SafeWalkHack.java | 2 +- .../java/net/wurstclient/hacks/StepHack.java | 17 +++++----- .../wurstclient/mixin/ChatScreenMixin.java | 9 +++-- .../mixin/ClientPlayerEntityMixin.java | 32 +++++++++++++++++- .../ClientPlayerInteractionManagerMixin.java | 29 ---------------- .../mixin/EntityRendererMixin.java | 9 ++--- .../net/wurstclient/mixin/IngameHudMixin.java | 13 ++++---- .../serverfinder/WurstServerPinger.java | 2 +- src/main/resources/fabric.mod.json | 4 +-- src/main/resources/wurst.accesswidener | 1 - 15 files changed, 86 insertions(+), 84 deletions(-) diff --git a/src/main/java/net/wurstclient/commands/PotionCmd.java b/src/main/java/net/wurstclient/commands/PotionCmd.java index 66b2063518..199a38012e 100644 --- a/src/main/java/net/wurstclient/commands/PotionCmd.java +++ b/src/main/java/net/wurstclient/commands/PotionCmd.java @@ -80,7 +80,7 @@ public void call(String[] args) throws CmdException { NbtCompound effect = new NbtCompound(); - effect.putInt("id", parseEffectId(args[1 + i * 3])); + effect.putString("id", parseEffectId(args[1 + i * 3])); effect.putInt("amplifier", parseInt(args[2 + i * 3]) - 1); effect.putInt("duration", parseInt(args[3 + i * 3]) * 20); @@ -103,8 +103,9 @@ private NbtList convertEffectsToNbt(ItemStack stack) { NbtCompound tag = new NbtCompound(); - int id = Registries.STATUS_EFFECT.getRawId(effect.getEffectType()); - tag.putInt("id", id); + String id = Registries.STATUS_EFFECT + .getId(effect.getEffectType().value()).toString(); + tag.putString("id", id); tag.putInt("amplifier", effect.getAmplifier()); tag.putInt("duration", effect.getDuration()); @@ -119,7 +120,7 @@ private void remove(ItemStack stack, String[] args) throws CmdSyntaxError if(args.length != 2) throw new CmdSyntaxError(); - int id = parseEffectId(args[1]); + String id = parseEffectId(args[1]); List oldEffects = PotionUtil.getCustomPotionEffects(stack); @@ -127,14 +128,14 @@ private void remove(ItemStack stack, String[] args) throws CmdSyntaxError NbtList newEffects = new NbtList(); for(StatusEffectInstance oldEffect : oldEffects) { - int oldId = - Registries.STATUS_EFFECT.getRawId(oldEffect.getEffectType()); + String oldId = Registries.STATUS_EFFECT + .getId(oldEffect.getEffectType().value()).toString(); - if(oldId == id) + if(oldId.equals(id)) continue; NbtCompound effect = new NbtCompound(); - effect.putInt("id", oldId); + effect.putString("id", oldId); effect.putInt("amplifier", oldEffect.getAmplifier()); effect.putInt("duration", oldEffect.getDuration()); newEffects.add(effect); @@ -146,29 +147,27 @@ private void remove(ItemStack stack, String[] args) throws CmdSyntaxError ChatUtils.message("Effect removed."); } - private int parseEffectId(String input) throws CmdSyntaxError + private String parseEffectId(String input) throws CmdSyntaxError { - int id = 0; + StatusEffect effect; if(MathUtils.isInteger(input)) - id = Integer.parseInt(input); + effect = Registries.STATUS_EFFECT.get(Integer.parseInt(input)); else try { Identifier identifier = new Identifier(input); - StatusEffect effect = Registries.STATUS_EFFECT.get(identifier); - - id = Registries.STATUS_EFFECT.getRawId(effect); + effect = Registries.STATUS_EFFECT.get(identifier); }catch(InvalidIdentifierException e) { throw new CmdSyntaxError("Invalid effect: " + input); } - if(id < 1) - throw new CmdSyntaxError(); + if(effect == null) + throw new CmdSyntaxError("Invalid effect: " + input); - return id; + return Registries.STATUS_EFFECT.getId(effect).toString(); } private int parseInt(String s) throws CmdSyntaxError diff --git a/src/main/java/net/wurstclient/hacks/AutoEatHack.java b/src/main/java/net/wurstclient/hacks/AutoEatHack.java index 488858cdfc..e8f8e103d3 100644 --- a/src/main/java/net/wurstclient/hacks/AutoEatHack.java +++ b/src/main/java/net/wurstclient/hacks/AutoEatHack.java @@ -28,6 +28,7 @@ import net.minecraft.item.FoodComponent; import net.minecraft.item.FoodComponents; import net.minecraft.item.Item; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; @@ -276,7 +277,8 @@ private boolean isAllowedFood(FoodComponent food) for(Pair pair : food.getStatusEffects()) { - StatusEffect effect = pair.getFirst().getEffectType(); + RegistryEntry effect = + pair.getFirst().getEffectType(); if(!allowHunger.isChecked() && effect == StatusEffects.HUNGER) return false; diff --git a/src/main/java/net/wurstclient/hacks/AutoPotionHack.java b/src/main/java/net/wurstclient/hacks/AutoPotionHack.java index 9fa1814a07..2693b05da9 100644 --- a/src/main/java/net/wurstclient/hacks/AutoPotionHack.java +++ b/src/main/java/net/wurstclient/hacks/AutoPotionHack.java @@ -14,6 +14,7 @@ import net.minecraft.item.Items; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.potion.PotionUtil; +import net.minecraft.registry.entry.RegistryEntry; import net.wurstclient.Category; import net.wurstclient.SearchTags; import net.wurstclient.events.UpdateListener; @@ -121,7 +122,8 @@ private int findPotion(int startSlot, int endSlot) return -1; } - private boolean hasEffect(ItemStack stack, StatusEffect effect) + private boolean hasEffect(ItemStack stack, + RegistryEntry effect) { for(StatusEffectInstance effectInstance : PotionUtil .getPotionEffects(stack)) diff --git a/src/main/java/net/wurstclient/hacks/LiquidsHack.java b/src/main/java/net/wurstclient/hacks/LiquidsHack.java index 9775271751..e040bbb669 100644 --- a/src/main/java/net/wurstclient/hacks/LiquidsHack.java +++ b/src/main/java/net/wurstclient/hacks/LiquidsHack.java @@ -34,7 +34,7 @@ protected void onDisable() @Override public void onHitResultRayTrace(float partialTicks) { - float reach = MC.interactionManager.getReachDistance(); + double reach = MC.player.method_55754(); MC.crosshairTarget = MC.getCameraEntity().raycast(reach, partialTicks, true); } diff --git a/src/main/java/net/wurstclient/hacks/ReachHack.java b/src/main/java/net/wurstclient/hacks/ReachHack.java index c327427eef..e9d65ea6de 100644 --- a/src/main/java/net/wurstclient/hacks/ReachHack.java +++ b/src/main/java/net/wurstclient/hacks/ReachHack.java @@ -13,6 +13,7 @@ import net.wurstclient.settings.SliderSetting; import net.wurstclient.settings.SliderSetting.ValueDisplay; +// TODO: Remove this hack in 1.20.5, as it seems to be patched. @SearchTags({"range"}) public final class ReachHack extends Hack { @@ -26,11 +27,11 @@ public ReachHack() addSetting(range); } - public float getReachDistance() + public double getReachDistance() { - return range.getValueF(); + return range.getValue(); } - // See ClientPlayerInteractionManagerMixin.onGetReachDistance() and - // ClientPlayerInteractionManagerMixin.hasExtendedReach() + // See ClientPlayerEntityMixin.method_55754() and + // ClientPlayerEntityMixin.method_55755() } diff --git a/src/main/java/net/wurstclient/hacks/SafeWalkHack.java b/src/main/java/net/wurstclient/hacks/SafeWalkHack.java index 745d59657c..ac409d54d1 100644 --- a/src/main/java/net/wurstclient/hacks/SafeWalkHack.java +++ b/src/main/java/net/wurstclient/hacks/SafeWalkHack.java @@ -67,7 +67,7 @@ public void onClipAtLedge(boolean clipping) } Box box = player.getBoundingBox(); - Box adjustedBox = box.stretch(0, -player.stepHeight, 0) + Box adjustedBox = box.stretch(0, -player.getStepHeight(), 0) .expand(-edgeDistance.getValue(), 0, -edgeDistance.getValue()); if(MC.world.isSpaceEmpty(player, adjustedBox)) diff --git a/src/main/java/net/wurstclient/hacks/StepHack.java b/src/main/java/net/wurstclient/hacks/StepHack.java index 689cfcdce4..8dbfe7c496 100644 --- a/src/main/java/net/wurstclient/hacks/StepHack.java +++ b/src/main/java/net/wurstclient/hacks/StepHack.java @@ -48,23 +48,15 @@ public void onEnable() public void onDisable() { EVENTS.remove(UpdateListener.class, this); - MC.player.stepHeight = 0.5F; } @Override public void onUpdate() { if(mode.getSelected() == Mode.SIMPLE) - { - // simple mode - MC.player.stepHeight = height.getValueF(); return; - } - // legit mode ClientPlayerEntity player = MC.player; - player.stepHeight = 0.5F; - if(!player.horizontalCollision) return; @@ -80,7 +72,6 @@ public void onUpdate() return; Box box = player.getBoundingBox().offset(0, 0.05, 0).expand(0.05); - if(!MC.world.isSpaceEmpty(player, box.offset(0, 1, 0))) return; @@ -106,6 +97,14 @@ public void onUpdate() player.getZ()); } + public float adjustStepHeight(float stepHeight) + { + if(isEnabled() && mode.getSelected() == Mode.SIMPLE) + return height.getValueF(); + + return stepHeight; + } + public boolean isAutoJumpAllowed() { return !isEnabled() && !WURST.getCmds().goToCmd.isActive(); diff --git a/src/main/java/net/wurstclient/mixin/ChatScreenMixin.java b/src/main/java/net/wurstclient/mixin/ChatScreenMixin.java index 9a4b21052f..306067b07f 100644 --- a/src/main/java/net/wurstclient/mixin/ChatScreenMixin.java +++ b/src/main/java/net/wurstclient/mixin/ChatScreenMixin.java @@ -12,7 +12,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.minecraft.client.gui.screen.ChatScreen; import net.minecraft.client.gui.screen.Screen; @@ -41,10 +40,10 @@ protected void onInit(CallbackInfo ci) } @Inject(at = @At("HEAD"), - method = "sendMessage(Ljava/lang/String;Z)Z", + method = "sendMessage(Ljava/lang/String;Z)V", cancellable = true) public void onSendMessage(String message, boolean addToHistory, - CallbackInfoReturnable cir) + CallbackInfo ci) { if((message = normalize(message)).isEmpty()) return; @@ -54,7 +53,7 @@ public void onSendMessage(String message, boolean addToHistory, if(event.isCancelled()) { - cir.setReturnValue(true); + ci.cancel(); return; } @@ -71,7 +70,7 @@ public void onSendMessage(String message, boolean addToHistory, else client.player.networkHandler.sendChatMessage(newMessage); - cir.setReturnValue(true); + ci.cancel(); } @Shadow diff --git a/src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java b/src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java index ff3b552276..3d5b31c834 100644 --- a/src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java @@ -26,6 +26,7 @@ import net.minecraft.entity.MovementType; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.math.Vec3d; import net.wurstclient.WurstClient; import net.wurstclient.event.EventManager; @@ -269,7 +270,7 @@ protected Vec3d adjustMovementForSneaking(Vec3d movement, MovementType type) } @Override - public boolean hasStatusEffect(StatusEffect effect) + public boolean hasStatusEffect(RegistryEntry effect) { HackList hax = WurstClient.INSTANCE.getHax(); @@ -286,4 +287,33 @@ public boolean hasStatusEffect(StatusEffect effect) return super.hasStatusEffect(effect); } + + @Override + public float getStepHeight() + { + return WurstClient.INSTANCE.getHax().stepHack + .adjustStepHeight(super.getStepHeight()); + } + + // getter for GENERIC_BLOCK_INTERACTION_RANGE + @Override + public double method_55754() + { + HackList hax = WurstClient.INSTANCE.getHax(); + if(hax == null || !hax.reachHack.isEnabled()) + return super.method_55754(); + + return hax.reachHack.getReachDistance(); + } + + // getter for GENERIC_ENTITY_INTERACTION_RANGE + @Override + public double method_55755() + { + HackList hax = WurstClient.INSTANCE.getHax(); + if(hax == null || !hax.reachHack.isEnabled()) + return super.method_55755(); + + return hax.reachHack.getReachDistance(); + } } diff --git a/src/main/java/net/wurstclient/mixin/ClientPlayerInteractionManagerMixin.java b/src/main/java/net/wurstclient/mixin/ClientPlayerInteractionManagerMixin.java index 6fdc89123d..fefa8abdec 100644 --- a/src/main/java/net/wurstclient/mixin/ClientPlayerInteractionManagerMixin.java +++ b/src/main/java/net/wurstclient/mixin/ClientPlayerInteractionManagerMixin.java @@ -31,12 +31,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; -import net.wurstclient.WurstClient; import net.wurstclient.event.EventManager; import net.wurstclient.events.BlockBreakingProgressListener.BlockBreakingProgressEvent; import net.wurstclient.events.StopUsingItemListener.StopUsingItemEvent; -import net.wurstclient.hack.HackList; -import net.wurstclient.hacks.ReachHack; import net.wurstclient.mixinterface.IClientPlayerInteractionManager; @Mixin(ClientPlayerInteractionManager.class) @@ -57,32 +54,6 @@ private void onPlayerDamageBlock(BlockPos pos, Direction direction, EventManager.fire(new BlockBreakingProgressEvent(pos, direction)); } - @Inject(at = @At("HEAD"), - method = "getReachDistance()F", - cancellable = true) - private void onGetReachDistance(CallbackInfoReturnable ci) - { - HackList hax = WurstClient.INSTANCE.getHax(); - if(hax == null) - return; - - ReachHack reach = hax.reachHack; - if(reach.isEnabled()) - ci.setReturnValue(reach.getReachDistance()); - } - - @Inject(at = @At("HEAD"), - method = "hasExtendedReach()Z", - cancellable = true) - private void hasExtendedReach(CallbackInfoReturnable cir) - { - HackList hax = WurstClient.INSTANCE.getHax(); - if(hax == null || !hax.reachHack.isEnabled()) - return; - - cir.setReturnValue(true); - } - @Inject(at = @At("HEAD"), method = "stopUsingItem(Lnet/minecraft/entity/player/PlayerEntity;)V") private void onStopUsingItem(PlayerEntity player, CallbackInfo ci) diff --git a/src/main/java/net/wurstclient/mixin/EntityRendererMixin.java b/src/main/java/net/wurstclient/mixin/EntityRendererMixin.java index c8acb3fd70..5aa221a313 100644 --- a/src/main/java/net/wurstclient/mixin/EntityRendererMixin.java +++ b/src/main/java/net/wurstclient/mixin/EntityRendererMixin.java @@ -35,11 +35,11 @@ public abstract class EntityRendererMixin protected EntityRenderDispatcher dispatcher; @Inject(at = @At("HEAD"), - method = "renderLabelIfPresent(Lnet/minecraft/entity/Entity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", + method = "renderLabelIfPresent(Lnet/minecraft/entity/Entity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IF)V", cancellable = true) private void onRenderLabelIfPresent(T entity, Text text, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, - int i, CallbackInfo ci) + int i, float tickDelta, CallbackInfo ci) { // add HealthTags info if(entity instanceof LivingEntity) @@ -48,7 +48,7 @@ private void onRenderLabelIfPresent(T entity, Text text, // do NameTags adjustments wurstRenderLabelIfPresent(entity, text, matrixStack, - vertexConsumerProvider, i); + vertexConsumerProvider, i, tickDelta); ci.cancel(); } @@ -57,7 +57,8 @@ private void onRenderLabelIfPresent(T entity, Text text, * an infinite loop. Also makes it easier to modify. */ protected void wurstRenderLabelIfPresent(T entity, Text text, - MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) + MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, + float tickDelta) { NameTagsHack nameTags = WurstClient.INSTANCE.getHax().nameTagsHack; diff --git a/src/main/java/net/wurstclient/mixin/IngameHudMixin.java b/src/main/java/net/wurstclient/mixin/IngameHudMixin.java index 157661d5e3..a1c3e59218 100644 --- a/src/main/java/net/wurstclient/mixin/IngameHudMixin.java +++ b/src/main/java/net/wurstclient/mixin/IngameHudMixin.java @@ -29,13 +29,12 @@ public class IngameHudMixin @Final private DebugHud debugHud; - @Inject( - at = @At(value = "INVOKE", - target = "Lcom/mojang/blaze3d/systems/RenderSystem;enableBlend()V", - remap = false, - ordinal = 3), - method = "render(Lnet/minecraft/client/gui/DrawContext;F)V") - private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) + // runs after renderScoreboardSidebar() + // and before playerListHud.setVisible() + @Inject(at = @At("HEAD"), + method = "method_55804(Lnet/minecraft/client/gui/DrawContext;F)V") + private void onMethod_55804(DrawContext context, float tickDelta, + CallbackInfo ci) { if(debugHud.shouldShowDebugHud()) return; diff --git a/src/main/java/net/wurstclient/serverfinder/WurstServerPinger.java b/src/main/java/net/wurstclient/serverfinder/WurstServerPinger.java index 64de3bdfcf..7a2369f88b 100644 --- a/src/main/java/net/wurstclient/serverfinder/WurstServerPinger.java +++ b/src/main/java/net/wurstclient/serverfinder/WurstServerPinger.java @@ -41,7 +41,7 @@ private void pingInCurrentThread(String ip, int port) try { - pinger.add(server, () -> {}); + pinger.add(server, () -> {}, () -> {}); System.out.println("Ping successful: " + ip + ":" + port); }catch(UnknownHostException e) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 827d585e69..5f20a31035 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,8 +30,8 @@ "depends": { "fabricloader": ">=0.15.0", - "fabric-api": ">=0.91.1", - "minecraft": "~1.20.3-beta.3", + "fabric-api": ">=0.91.4", + "minecraft": "~1.20.5-alpha.23.51.a", "java": ">=17" }, "suggests": { diff --git a/src/main/resources/wurst.accesswidener b/src/main/resources/wurst.accesswidener index 6961e92ae3..c727812c21 100644 --- a/src/main/resources/wurst.accesswidener +++ b/src/main/resources/wurst.accesswidener @@ -16,6 +16,5 @@ accessible field net/minecraft/client/network/ClientPlayerInteractionManager bre accessible field net/minecraft/client/network/ClientPlayerInteractionManager currentBreakingProgress F accessible field net/minecraft/client/toast/ToastManager toastQueue Ljava/util/Deque; accessible field net/minecraft/entity/Entity movementMultiplier Lnet/minecraft/util/math/Vec3d; -accessible field net/minecraft/entity/Entity stepHeight F accessible field net/minecraft/item/ArmorItem toughness F accessible field net/minecraft/network/packet/s2c/play/ChunkDeltaUpdateS2CPacket sectionPos Lnet/minecraft/util/math/ChunkSectionPos;