Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split NoSlowdown with checkboxes #800

Closed
Closed
44 changes: 44 additions & 0 deletions src/main/java/net/wurstclient/hacks/NoSlowdownHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,58 @@
import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.hack.Hack;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.EnumSetting;

@SearchTags({"no slowdown", "no slow down"})
public final class NoSlowdownHack extends Hack
{
private final CheckboxSetting blocks =
new CheckboxSetting("Block honey + soul sand slowness", true);
private final EnumSetting<ItemSlowness> items =
new EnumSetting<>("Block item slowness", ItemSlowness.values(), ItemSlowness.ALL);

public NoSlowdownHack()
{
super("NoSlowdown");
setCategory(Category.MOVEMENT);
addSetting(blocks);
addSetting(items);
}

public boolean noBlockSlowness()
{
return isEnabled() && blocks.isChecked();
}

public boolean noItemSlowness()
{
return isEnabled() && items.getSelected() == ItemSlowness.ALL;
}

public boolean noNonBlockingItemSlowness()
{
return isEnabled() && items.getSelected() == ItemSlowness.EXCEPT_BLOCKING;
}

private enum ItemSlowness
{
ALL("All"),
EXCEPT_BLOCKING("Except blocking"),
NONE("None");

private final String name;

private ItemSlowness(String name)
{
this.name = name;
}

@Override
public String toString()
{
return name;
}
}

// See BlockMixin.onGetVelocityMultiplier() and
Expand Down
118 changes: 59 additions & 59 deletions src/main/java/net/wurstclient/mixin/BlockMixin.java
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
/*
* Copyright (c) 2014-2023 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 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;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemConvertible;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.wurstclient.WurstClient;
import net.wurstclient.event.EventManager;
import net.wurstclient.events.ShouldDrawSideListener.ShouldDrawSideEvent;
import net.wurstclient.hack.HackList;
@Mixin(Block.class)
public abstract class BlockMixin implements ItemConvertible
{
/**
* This mixin allows X-Ray to show ores that would normally be obstructed by
* other blocks.
*/
@Inject(at = @At("HEAD"),
method = "shouldDrawSide(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;Lnet/minecraft/util/math/BlockPos;)Z",
cancellable = true)
private static void onShouldDrawSide(BlockState state, BlockView world,
BlockPos pos, Direction direction, BlockPos blockPos,
CallbackInfoReturnable<Boolean> cir)
{
ShouldDrawSideEvent event = new ShouldDrawSideEvent(state, pos);
EventManager.fire(event);
if(event.isRendered() != null)
cir.setReturnValue(event.isRendered());
}
@Inject(at = @At("HEAD"),
method = "getVelocityMultiplier()F",
cancellable = true)
private void onGetVelocityMultiplier(CallbackInfoReturnable<Float> cir)
{
HackList hax = WurstClient.INSTANCE.getHax();
if(hax == null || !hax.noSlowdownHack.isEnabled())
return;
if(cir.getReturnValueF() < 1)
cir.setReturnValue(1F);
}
}
/*
* Copyright (c) 2014-2023 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 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;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemConvertible;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.wurstclient.WurstClient;
import net.wurstclient.event.EventManager;
import net.wurstclient.events.ShouldDrawSideListener.ShouldDrawSideEvent;
import net.wurstclient.hack.HackList;

@Mixin(Block.class)
public abstract class BlockMixin implements ItemConvertible
{
/**
* This mixin allows X-Ray to show ores that would normally be obstructed by
* other blocks.
*/
@Inject(at = @At("HEAD"),
method = "shouldDrawSide(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;Lnet/minecraft/util/math/BlockPos;)Z",
cancellable = true)
private static void onShouldDrawSide(BlockState state, BlockView world,
BlockPos pos, Direction direction, BlockPos blockPos,
CallbackInfoReturnable<Boolean> cir)
{
ShouldDrawSideEvent event = new ShouldDrawSideEvent(state, pos);
EventManager.fire(event);

if(event.isRendered() != null)
cir.setReturnValue(event.isRendered());
}

@Inject(at = @At("HEAD"),
method = "getVelocityMultiplier()F",
cancellable = true)
private void onGetVelocityMultiplier(CallbackInfoReturnable<Float> cir)
{
HackList hax = WurstClient.INSTANCE.getHax();
if(hax == null || !hax.noSlowdownHack.noBlockSlowness())
return;

if(cir.getReturnValueF() < 1)
cir.setReturnValue(1F);
}
}
Loading
Loading