mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
Remove Attack Self
This commit is contained in:
@@ -2412,10 +2412,10 @@ index 0000000000000000000000000000000000000000..d626ac47af400d01993c358fa5a93671
|
||||
+}
|
||||
diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/Actions.java b/src/main/java/org/leavesmc/leaves/bot/agent/Actions.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..92fc24b187979d5db4b2a316f066ac01a8890879
|
||||
index 0000000000000000000000000000000000000000..5555d5fc7bc169cd08f6760b296a83d9d9853118
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/leavesmc/leaves/bot/agent/Actions.java
|
||||
@@ -0,0 +1,66 @@
|
||||
@@ -0,0 +1,65 @@
|
||||
+package org.leavesmc.leaves.bot.agent;
|
||||
+
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
@@ -2444,7 +2444,6 @@ index 0000000000000000000000000000000000000000..92fc24b187979d5db4b2a316f066ac01
|
||||
+ register(new UseItemToAction());
|
||||
+ register(new LookAction());
|
||||
+ register(new FishAction());
|
||||
+ register(new AttackSelfAction());
|
||||
+ register(new SwimAction());
|
||||
+ register(new UseItemOffHandAction());
|
||||
+ register(new UseItemOnOffhandAction());
|
||||
@@ -2583,13 +2582,14 @@ index 0000000000000000000000000000000000000000..9abcb8852ac031abaa991881a7cd6b33
|
||||
+}
|
||||
diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/AttackAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/AttackAction.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..584ebd1e369467440009fe12518609a713102717
|
||||
index 0000000000000000000000000000000000000000..b230e8896f3cfe9ef714a0a4a0bfc49be5f2aa4f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/AttackAction.java
|
||||
@@ -0,0 +1,36 @@
|
||||
@@ -0,0 +1,43 @@
|
||||
+package org.leavesmc.leaves.bot.agent.actions;
|
||||
+
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import net.minecraft.world.phys.EntityHitResult;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.leavesmc.leaves.bot.ServerBot;
|
||||
@@ -2615,53 +2615,14 @@ index 0000000000000000000000000000000000000000..584ebd1e369467440009fe12518609a7
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean doTick(@NotNull ServerBot bot) {
|
||||
+ EntityHitResult result = bot.getTargetEntity(3);
|
||||
+ if (result != null) {
|
||||
+ bot.attack(result.getEntity());
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/leavesmc/leaves/bot/agent/actions/AttackSelfAction.java b/src/main/java/org/leavesmc/leaves/bot/agent/actions/AttackSelfAction.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..193446c68f4617f0542817f13df3bce0fa667c61
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/leavesmc/leaves/bot/agent/actions/AttackSelfAction.java
|
||||
@@ -0,0 +1,39 @@
|
||||
+package org.leavesmc.leaves.bot.agent.actions;
|
||||
+
|
||||
+import com.google.common.base.Predicates;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.leavesmc.leaves.bot.ServerBot;
|
||||
+import org.leavesmc.leaves.bot.agent.BotAction;
|
||||
+import org.leavesmc.leaves.command.CommandArgument;
|
||||
+import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
+import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
+
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class AttackSelfAction extends BotAction {
|
||||
+
|
||||
+ public AttackSelfAction() {
|
||||
+ super("attack_self", new CommandArgument(CommandArgumentType.INTEGER, CommandArgumentType.INTEGER));
|
||||
+ setTabComplete(0, List.of("[TickDelay]"));
|
||||
+ setTabComplete(1, List.of("[DoNumber]"));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BotAction getNew(@NotNull ServerPlayer player, @NotNull CommandArgumentResult result) {
|
||||
+ return new AttackSelfAction().setTickDelay(result.readInt(20)).setNumber(result.readInt(-1));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean doTick(@NotNull ServerBot bot) {
|
||||
+ List<Entity> entities = bot.level().getEntities((Entity) null, bot.getBoundingBox(), (entity -> entity != bot));
|
||||
+ if (!entities.isEmpty()) {
|
||||
+ for (Entity entity : entities) {
|
||||
+ bot.attack(entity);
|
||||
+ bot.attack(entities.getFirst());
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ EntityHitResult result = bot.getTargetEntity(3);
|
||||
+ if (result != null) {
|
||||
+ bot.attack(result.getEntity());
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
Reference in New Issue
Block a user