feat: filter neutral entities and friend players
This commit is contained in:
parent
b480fd3a79
commit
3272be2fae
1 changed files with 25 additions and 0 deletions
|
@ -1,12 +1,15 @@
|
|||
package ftbsc.bscv.modules.defense;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
|
||||
import ftbsc.bscv.Boscovicino;
|
||||
import ftbsc.bscv.ICommons;
|
||||
import ftbsc.bscv.api.ILoadable;
|
||||
import ftbsc.bscv.modules.QuickModule;
|
||||
import ftbsc.bscv.tools.Setting;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.TickEvent.Phase;
|
||||
|
@ -22,6 +25,8 @@ public class Aura extends QuickModule implements ICommons {
|
|||
|
||||
public final ForgeConfigSpec.ConfigValue<Double> reach;
|
||||
public final ForgeConfigSpec.ConfigValue<Double> strenght;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> neutral;
|
||||
public final ForgeConfigSpec.ConfigValue<Boolean> friends;
|
||||
|
||||
public Aura() {
|
||||
super();
|
||||
|
@ -40,6 +45,18 @@ public class Aura extends QuickModule implements ICommons {
|
|||
.comment("minimum strenght required for attack")
|
||||
.fallback(1.)
|
||||
.build(this);
|
||||
|
||||
this.neutral = Setting.Bool.builder()
|
||||
.fallback(false)
|
||||
.name("neutral")
|
||||
.comment("attack neutral mobs")
|
||||
.build(this);
|
||||
|
||||
this.friends = Setting.Bool.builder()
|
||||
.fallback(false)
|
||||
.name("friends")
|
||||
.comment("attack players tagged as friends")
|
||||
.build(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -55,6 +72,14 @@ public class Aura extends QuickModule implements ICommons {
|
|||
if (!(e instanceof LivingEntity)) continue;
|
||||
if (!e.isAlive()) continue;
|
||||
if (e.distanceTo(MC.player) > this.reach.get()) continue;
|
||||
if (!this.neutral.get() && e.getClassification(false).isFriendly()) continue;
|
||||
if (e instanceof PlayerEntity) {
|
||||
PlayerEntity player = (PlayerEntity) e;
|
||||
if (Boscovicino.friends().isFriend(player.getGameProfile().getId())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!this.friends.get() && Boscovicino.friends().isFriend(e.getDisplayName().getString())) continue;
|
||||
MC.gameMode.attack(MC.player, e);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue