mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
Update fakeplayer use_to action
This commit is contained in:
@@ -1306,10 +1306,10 @@ index 0000000000000000000000000000000000000000..821d456d11b6f49ea8eba59e79d09980
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/Actions.java b/src/main/java/top/leavesmc/leaves/bot/agent/Actions.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..899079c1bd323bc8d18b2cee1589bf094937996a
|
||||
index 0000000000000000000000000000000000000000..0296cf157ef2472ade3c6bf39c5765708ae52eaa
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/bot/agent/Actions.java
|
||||
@@ -0,0 +1,51 @@
|
||||
@@ -0,0 +1,53 @@
|
||||
+package top.leavesmc.leaves.bot.agent;
|
||||
+
|
||||
+import top.leavesmc.leaves.bot.agent.action.AttackAction;
|
||||
@@ -1320,6 +1320,7 @@ index 0000000000000000000000000000000000000000..899079c1bd323bc8d18b2cee1589bf09
|
||||
+import top.leavesmc.leaves.bot.agent.action.StopAction;
|
||||
+import top.leavesmc.leaves.bot.agent.action.UseItemAction;
|
||||
+import top.leavesmc.leaves.bot.agent.action.UseItemOnAction;
|
||||
+import top.leavesmc.leaves.bot.agent.action.UseItemToAction;
|
||||
+
|
||||
+import java.util.HashSet;
|
||||
+import java.util.Set;
|
||||
@@ -1337,6 +1338,7 @@ index 0000000000000000000000000000000000000000..899079c1bd323bc8d18b2cee1589bf09
|
||||
+ register(new StopAction());
|
||||
+ register(new BreakBlockAction());
|
||||
+ register(new SneakAction());
|
||||
+ register(new UseItemToAction());
|
||||
+ }
|
||||
+
|
||||
+ public static void register(BotAction action) {
|
||||
@@ -1731,6 +1733,45 @@ index 0000000000000000000000000000000000000000..58d6bcd4c6b6b02c42b7175e192b7600
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/action/UseItemToAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/action/UseItemToAction.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c3b373b2ab61a467194ae3653a5e56997bec5317
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/bot/agent/action/UseItemToAction.java
|
||||
@@ -0,0 +1,33 @@
|
||||
+package top.leavesmc.leaves.bot.agent.action;
|
||||
+
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import net.minecraft.world.InteractionHand;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import net.minecraft.world.phys.EntityHitResult;
|
||||
+import net.minecraft.world.phys.HitResult;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import top.leavesmc.leaves.bot.ServerBot;
|
||||
+import top.leavesmc.leaves.bot.agent.BotAction;
|
||||
+
|
||||
+public class UseItemToAction extends BotAction {
|
||||
+
|
||||
+ public UseItemToAction() {
|
||||
+ super("use_to", true, true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BotAction getNew(int tickDelay, int number, @NotNull ServerPlayer player) {
|
||||
+ return new UseItemToAction().setNumber(number).setTickDelay(tickDelay);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean doTick(@NotNull ServerBot bot) {
|
||||
+ HitResult result = bot.getRayTrace(4);
|
||||
+ if (result.getType() == HitResult.Type.ENTITY) {
|
||||
+ bot.punch();
|
||||
+ bot.updateItemInMainHand();
|
||||
+ return ((EntityHitResult) result).getEntity().interact(bot, InteractionHand.MAIN_HAND).consumesAction();
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/entity/CraftBot.java b/src/main/java/top/leavesmc/leaves/entity/CraftBot.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..2d5044c4a09044364e818b7674908bf98932bf58
|
||||
|
||||
Reference in New Issue
Block a user