Skip to content

Commit

Permalink
improve efficiency by checking settings first
Browse files Browse the repository at this point in the history
  • Loading branch information
moritztim committed Nov 7, 2023
1 parent 8c8741c commit ca32b71
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,26 @@ private void onTick(TickEvent.Post event) {
if (toggleOff.get()) this.toggle();
}

for (Entity entity : mc.world.getEntities()) {
if (entity instanceof PlayerEntity && entity.getUuid() != mc.player.getUuid()) {
if (onlyTrusted.get() && entity != mc.player && !Friends.get().isFriend((PlayerEntity) entity)) {
disconnect("A non-trusted player appeared in your render distance.");
if (onlyTrusted.get() || instantDeath.get() || crystalLog.get()) { // only check all entities if needed
for (Entity entity : mc.world.getEntities()) {
if (entity instanceof PlayerEntity && entity.getUuid() != mc.player.getUuid()) {
if (onlyTrusted.get() && entity != mc.player && !Friends.get().isFriend((PlayerEntity) entity)) {
disconnect("A non-trusted player appeared in your render distance.");
if (toggleOff.get()) this.toggle();
break;
}
if (instantDeath.get() && PlayerUtils.isWithin(entity, 8) && DamageUtils.getSwordDamage((PlayerEntity) entity, true)
> playerHealth + mc.player.getAbsorptionAmount()) {
disconnect("Anti-32k measures.");
if (toggleOff.get()) this.toggle();
break;
}
}
if (PlayerUtils.isWithin(entity, 8) && instantDeath.get() && DamageUtils.getSwordDamage((PlayerEntity) entity, true)
> playerHealth + mc.player.getAbsorptionAmount()) {
disconnect("Anti-32k measures.");
if (crystalLog.get() && entity instanceof EndCrystalEntity && PlayerUtils.isWithin(entity, range.get())) {
disconnect("End Crystal appeared within specified range.");
if (toggleOff.get()) this.toggle();
break;
}
}
if (entity instanceof EndCrystalEntity && PlayerUtils.isWithin(entity, range.get()) && crystalLog.get()) {
disconnect("End Crystal appeared within specified range.");
if (toggleOff.get()) this.toggle();
}
}
}

Expand Down

0 comments on commit ca32b71

Please sign in to comment.