Skip to content

Commit

Permalink
Fixed Painter performance
Browse files Browse the repository at this point in the history
  • Loading branch information
cattyngmd authored and C10udburst committed Nov 20, 2022
1 parent c4f4539 commit 6493377
Showing 1 changed file with 17 additions and 11 deletions.
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

0 comments on commit 6493377

Please sign in to comment.