Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
OLEPOSSU committed Apr 20, 2024
2 parents ae56a7e + b39a6e3 commit 27c3b6a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public boolean start(BlockPos pos, Box box, Vec3d vec, double p, RotationType ty

boolean alreadyRotated = SettingUtils.rotationCheck(box, type);

if (p < priority || (p == priority && (!(target instanceof BoxTarget) || SettingUtils.rotationCheck(((BoxTarget) target).box, type)))) {
if (p < priority || key == this.key || (p == priority && (!(target instanceof BoxTarget) || SettingUtils.rotationCheck(((BoxTarget) target).box, type)))) {
if (!alreadyRotated) {
priority = p;
}
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/kassuk/addon/blackout/modules/AutoCrystalPlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ public AutoCrystalPlus() {
.defaultValue(false)
.build()
);
private final Setting<Boolean> inhibit = sgExplode.add(new BoolSetting.Builder()
.name("Inhibit")
.description("Stops targeting attacked crystals.")
.defaultValue(false)
.build()
);
private final Setting<DelayMode> existedMode = sgExplode.add(new EnumSetting.Builder<DelayMode>()
.name("Existed Mode")
.description("Should crystal existed times be counted in seconds or ticks.")
Expand Down Expand Up @@ -658,8 +664,8 @@ public AutoCrystalPlus() {
private BlockPos placePos = null;
private Direction placeDir = null;
private Entity expEntity = null;
private Box expEntityBB = null;
private final TimerList<Integer> attackedList = new TimerList<>();
private final TimerList<Integer> inhibitList = new TimerList<>();
private final Map<BlockPos, Long> existedList = new HashMap<>();
private final Map<BlockPos, Long> existedTicksList = new HashMap<>();
private final Map<BlockPos, Long> own = new HashMap<>();
Expand Down Expand Up @@ -760,6 +766,7 @@ private void onTickPost(TickEvent.Post event) {
@EventHandler(priority = EventPriority.HIGHEST + 1)
private void onRender3D(Render3DEvent event) {
attackedList.update();
inhibitList.update();

if (autoMine == null) autoMine = Modules.get().get(AutoMine.class);

Expand All @@ -781,7 +788,6 @@ private void onRender3D(Render3DEvent event) {
}
cps /= 4.5;

attackedList.update();
attackTimer = Math.max(attackTimer - delta, 0);
placeTimer = Math.max(placeTimer - delta * getSpeed(), 0);
placeLimitTimer += delta;
Expand Down Expand Up @@ -990,9 +996,9 @@ private void update() {

if (!isPaused() && (hand != null || switchMode.get() == SwitchMode.Silent || switchMode.get() == SwitchMode.PickSilent || switchMode.get() == SwitchMode.InvSilent) && explode.get()) {
for (Entity en : mc.world.getEntities()) {

if (paAttack.get() && pa.isActive() && en.getBlockPos().equals(pa.crystalPos)) continue;
if (!(en instanceof EndCrystalEntity)) continue;
if (paAttack.get() && pa.isActive() && en.getBlockPos().equals(pa.crystalPos)) continue;
if (inhibitList.contains(en.getId())) continue;
if (switchTimer > 0) continue;

double[] dmg = getDmg(en.getPos(), true)[0];
Expand All @@ -1009,14 +1015,10 @@ private void update() {
if (expEntity != null) {
if (multiTaskCheck() && !isAttacked(expEntity.getId()) && attackDelayCheck() && existedCheck(expEntity.getBlockPos())) {
if (!SettingUtils.shouldRotate(RotationType.Attacking) || startAttackRot()) {
if (SettingUtils.shouldRotate(RotationType.Attacking)) expEntityBB = expEntity.getBoundingBox();
explode(expEntity.getId(), expEntity.getPos());
}
}
}

if (!isAlive(expEntityBB) && SettingUtils.shouldRotate(RotationType.Attacking))
Managers.ROTATION.end(Objects.hash(name + "attacking"));
} else if (SettingUtils.shouldRotate(RotationType.Attacking)) Managers.ROTATION.end(Objects.hash(name + "attacking"));
}

private boolean attackDelayCheck() {
Expand All @@ -1027,7 +1029,6 @@ private boolean attackDelayCheck() {
}

private boolean startAttackRot() {
expEntityBB = expEntity.getBoundingBox();
return (Managers.ROTATION.start(expEntity.getBoundingBox(), smartRot.get() ? expEntity.getPos() : null, priority + (!isAttacked(expEntity.getId()) && blocksPlacePos(expEntity) ? -0.1 : 0.1), RotationType.Attacking, Objects.hash(name + "attacking")));
}

Expand Down Expand Up @@ -1178,6 +1179,7 @@ private void attackEntity(int id, Box bb, Vec3d vec) {
if (mc.player != null) {
lastAttack = System.currentTimeMillis();
attackedList.add(id, 1 / expSpeed.get());
if (inhibit.get()) inhibitList.add(id, 0.5);

delayTimer = 0;
delayTicks = 0;
Expand Down

0 comments on commit 27c3b6a

Please sign in to comment.