From 64933773a7a4f2fc393ca1d21003905e9755b88a Mon Sep 17 00:00:00 2001 From: cattyngmd Date: Sun, 20 Nov 2022 12:00:30 +0300 Subject: [PATCH] Fixed Painter performance --- .../anticope/rejects/modules/Painter.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/anticope/rejects/modules/Painter.java b/src/main/java/anticope/rejects/modules/Painter.java index 4bca9e13..2a442796 100644 --- a/src/main/java/anticope/rejects/modules/Painter.java +++ b/src/main/java/anticope/rejects/modules/Painter.java @@ -41,6 +41,14 @@ public class Painter extends Module { .defaultValue(0) .build() ); + + private final Setting 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 rotate = sgGeneral.add(new BoolSetting.Builder() .name("rotate") @@ -76,8 +84,7 @@ public class Painter extends Module { .defaultValue(true) .build() ); - - private ArrayList positions = new ArrayList<>(); + private int ticksWaited; public Painter() { @@ -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; + } } }