Skip to content

Commit

Permalink
Add onlyOnClick setting to Scaffold module
Browse files Browse the repository at this point in the history
  • Loading branch information
DesiCow authored and arlomcwalter committed Jan 28, 2023
1 parent ba1568f commit 1a61830
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private boolean redirectUsingItem(ClientPlayerEntity player) {

@Inject(method = "isSneaking", at = @At("HEAD"), cancellable = true)
private void onIsSneaking(CallbackInfoReturnable<Boolean> info) {
if (Modules.get().isActive(Scaffold.class)) info.setReturnValue(false);
if (Modules.get().get(Scaffold.class).scaffolding()) info.setReturnValue(false);
}

@Inject(method = "shouldSlowDown", at = @At("HEAD"), cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ public class Scaffold extends Module {
.build()
);

private final Setting<Boolean> onlyOnClick = sgGeneral.add(new BoolSetting.Builder()
.name("only-on-click")
.description("Only places blocks when holding right click.")
.defaultValue(false)
.build()
);

private final Setting<Boolean> renderSwing = sgGeneral.add(new BoolSetting.Builder()
.name("swing")
.description("Renders your client-side swing.")
Expand Down Expand Up @@ -153,6 +160,8 @@ public void onActivate() {

@EventHandler
private void onTick(TickEvent.Pre event) {
if (onlyOnClick.get() && !mc.options.useKey.isPressed()) return;

if (airPlace.get()) {
Vec3d vec = mc.player.getPos().add(mc.player.getVelocity()).add(0, -0.5f, 0);
bp.set(vec.getX(), vec.getY(), vec.getZ());
Expand Down Expand Up @@ -238,6 +247,10 @@ private void onTick(TickEvent.Pre event) {
}
}

public boolean scaffolding() {
return isActive() && (!onlyOnClick.get() || (onlyOnClick.get() && mc.options.useKey.isPressed()));
}

private boolean validItem(ItemStack itemStack, BlockPos pos) {
if (!(itemStack.getItem() instanceof BlockItem)) return false;

Expand Down

0 comments on commit 1a61830

Please sign in to comment.