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

Fixed Painter performance and added blocks-per-tick option #180

Merged
merged 1 commit into from
Nov 20, 2022
Merged
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
28 changes: 17 additions & 11 deletions src/main/java/anticope/rejects/modules/Painter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ public class Painter extends Module {
.defaultValue(0)
.build()
);

private final Setting<Integer> bpt = sgGeneral.add(new IntSetting.Builder()
.name("blocks-per-tick")
.description("Amount of blocks that can be placed in one tick")
.min(1)
.defaultValue(1)
.build()
);

private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
.name("rotate")
Expand Down Expand Up @@ -76,8 +84,7 @@ public class Painter extends Module {
.defaultValue(true)
.build()
);

private ArrayList<BlockPos> positions = new ArrayList<>();

private int ticksWaited;

public Painter() {
Expand All @@ -102,16 +109,15 @@ private void onTick(TickEvent.Post event) {
}

// Find spots
int placed = 0;
for (BlockPos blockPos : WorldUtils.getSphere(mc.player.getBlockPos(), range.get(), range.get())) {
if (shouldPlace(blockPos, block.get())) positions.add(blockPos);
}

// Place
for (BlockPos blockPos : positions) {
BlockUtils.place(blockPos, findItemResult, rotate.get(), -100, false);

// Delay 0
if (delay.get() != 0) break;
if (shouldPlace(blockPos, block.get())) {
BlockUtils.place(blockPos, findItemResult, rotate.get(), -100, false);
placed++;

// Delay 0
if (delay.get() != 0 && placed >= bpt.get()) break;
}
}
}

Expand Down