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

Added "onlyOnClick" setting to Scaffold module #3205

Merged
merged 1 commit into from
Jan 28, 2023
Merged
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
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