Skip to content

Commit

Permalink
Update to 23w51a/b
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Dec 19, 2023
1 parent 495c418 commit 9a6b754
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 84 deletions.
33 changes: 16 additions & 17 deletions src/main/java/net/wurstclient/commands/PotionCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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());

Expand All @@ -119,22 +120,22 @@ 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<StatusEffectInstance> oldEffects =
PotionUtil.getCustomPotionEffects(stack);

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);
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/wurstclient/hacks/AutoEatHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -276,7 +277,8 @@ private boolean isAllowedFood(FoodComponent food)

for(Pair<StatusEffectInstance, Float> pair : food.getStatusEffects())
{
StatusEffect effect = pair.getFirst().getEffectType();
RegistryEntry<StatusEffect> effect =
pair.getFirst().getEffectType();

if(!allowHunger.isChecked() && effect == StatusEffects.HUNGER)
return false;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/wurstclient/hacks/AutoPotionHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<StatusEffect> effect)
{
for(StatusEffectInstance effectInstance : PotionUtil
.getPotionEffects(stack))
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/wurstclient/hacks/LiquidsHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/wurstclient/hacks/ReachHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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()
}
2 changes: 1 addition & 1 deletion src/main/java/net/wurstclient/hacks/SafeWalkHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/net/wurstclient/hacks/StepHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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();
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/net/wurstclient/mixin/ChatScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Boolean> cir)
CallbackInfo ci)
{
if((message = normalize(message)).isEmpty())
return;
Expand All @@ -54,7 +53,7 @@ public void onSendMessage(String message, boolean addToHistory,

if(event.isCancelled())
{
cir.setReturnValue(true);
ci.cancel();
return;
}

Expand All @@ -71,7 +70,7 @@ public void onSendMessage(String message, boolean addToHistory,
else
client.player.networkHandler.sendChatMessage(newMessage);

cir.setReturnValue(true);
ci.cancel();
}

@Shadow
Expand Down
32 changes: 31 additions & 1 deletion src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -269,7 +270,7 @@ protected Vec3d adjustMovementForSneaking(Vec3d movement, MovementType type)
}

@Override
public boolean hasStatusEffect(StatusEffect effect)
public boolean hasStatusEffect(RegistryEntry<StatusEffect> effect)
{
HackList hax = WurstClient.INSTANCE.getHax();

Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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<Float> 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<Boolean> 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)
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/wurstclient/mixin/EntityRendererMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public abstract class EntityRendererMixin<T extends Entity>
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)
Expand All @@ -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();
}

Expand All @@ -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;

Expand Down
13 changes: 6 additions & 7 deletions src/main/java/net/wurstclient/mixin/IngameHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 9a6b754

Please sign in to comment.