Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2014-2025 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.events;

import net.minecraft.entity.Entity;
import net.wurstclient.event.CancellableEvent;
import net.wurstclient.event.Listener;

import java.util.ArrayList;

public interface GetPlayerDepthStriderListener extends Listener
{
public void onGetPlayerDepthStrider(GetPlayerDepthStriderEvent event);

public static class GetPlayerDepthStriderEvent
extends CancellableEvent<GetPlayerDepthStriderListener>
{
private final Entity entity;

public GetPlayerDepthStriderEvent(Entity entity)
{
this.entity = entity;
}

public Entity getEntity()
{
return entity;
}

@Override
public void fire(ArrayList<GetPlayerDepthStriderListener> listeners)
{
for(GetPlayerDepthStriderListener listener : listeners)
{
listener.onGetPlayerDepthStrider(this);
if(isCancelled())
break;
}
}

@Override
public Class<GetPlayerDepthStriderListener> getListenerType()
{
return GetPlayerDepthStriderListener.class;
}
}
}
19 changes: 11 additions & 8 deletions src/main/java/net/wurstclient/hacks/AntiWaterPushHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.events.IsPlayerInWaterListener;
import net.wurstclient.events.GetPlayerDepthStriderListener;
import net.wurstclient.events.UpdateListener;
import net.wurstclient.events.VelocityFromFluidListener;
import net.wurstclient.hack.Hack;
import net.wurstclient.settings.CheckboxSetting;

@SearchTags({"anti water push", "NoWaterPush", "no water push"})
public final class AntiWaterPushHack extends Hack implements UpdateListener,
VelocityFromFluidListener, IsPlayerInWaterListener
VelocityFromFluidListener, GetPlayerDepthStriderListener
{
private final CheckboxSetting preventSlowdown = new CheckboxSetting(
"Prevent slowdown", "Allows you to walk underwater at full speed.\n"
Expand All @@ -36,15 +36,15 @@ protected void onEnable()
{
EVENTS.add(UpdateListener.class, this);
EVENTS.add(VelocityFromFluidListener.class, this);
EVENTS.add(IsPlayerInWaterListener.class, this);
EVENTS.add(GetPlayerDepthStriderListener.class, this);
}

@Override
protected void onDisable()
{
EVENTS.remove(UpdateListener.class, this);
EVENTS.remove(VelocityFromFluidListener.class, this);
EVENTS.remove(IsPlayerInWaterListener.class, this);
EVENTS.remove(GetPlayerDepthStriderListener.class, this);
}

@Override
Expand All @@ -66,21 +66,24 @@ public void onUpdate()
}

@Override
public void onVelocityFromFluid(VelocityFromFluidEvent event)
public void onVelocityFromFluid(
VelocityFromFluidListener.VelocityFromFluidEvent event)
{
if(event.getEntity() == MC.player)
event.cancel();
}

@Override
public void onIsPlayerInWater(IsPlayerInWaterEvent event)
public void onGetPlayerDepthStrider(GetPlayerDepthStriderEvent event)
{
if(preventSlowdown.isChecked())
event.setInWater(false);
if(isPreventingSlowdown() && event.getEntity() == MC.player)
event.cancel();

}

public boolean isPreventingSlowdown()
{
return preventSlowdown.isChecked();
}

}
33 changes: 33 additions & 0 deletions src/main/java/net/wurstclient/mixin/LivingEntityMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2014-2025 Wurst-Imperium and contributors.
*
* This source code is subject to the terms of the GNU General Public
* License, version 3. If a copy of the GPL was not distributed with this
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt
*/
package net.wurstclient.mixin;

import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.LivingEntity;
import net.wurstclient.event.EventManager;
import net.wurstclient.events.GetPlayerDepthStriderListener;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(LivingEntity.class)
public class LivingEntityMixin
{
@Redirect(method = "travel",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/enchantment/EnchantmentHelper;getDepthStrider(Lnet/minecraft/entity/LivingEntity;)I"))
private int getDepthStrider(LivingEntity entity)
{
GetPlayerDepthStriderListener.GetPlayerDepthStriderEvent event =
new GetPlayerDepthStriderListener.GetPlayerDepthStriderEvent(
entity);
EventManager.fire(event);
return event.isCancelled() ? 3
: EnchantmentHelper.getDepthStrider(entity);
}
}
1 change: 1 addition & 0 deletions src/main/resources/wurst.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"LanguageManagerMixin",
"LightmapTextureManagerMixin",
"LivingEntityRendererMixin",
"LivingEntityMixin",
"MinecraftClientMixin",
"MobEntityRendererMixin",
"MouseMixin",
Expand Down