Debugger added.
This commit is contained in:
@@ -151,7 +151,7 @@ public class Bot extends EntityPlayer {
|
||||
|
||||
double y;
|
||||
|
||||
if (isOnGround()) {
|
||||
if (groundTicks != 0) {
|
||||
velocity.setY(0);
|
||||
addFriction();
|
||||
y = 0;
|
||||
@@ -289,13 +289,12 @@ public class Bot extends EntityPlayer {
|
||||
}
|
||||
|
||||
private void kb(Location loc1, Location loc2) {
|
||||
Vector diff = loc1.toVector().subtract(loc2.toVector()).normalize();
|
||||
diff.multiply(0.5);
|
||||
diff.setY(kbUp);
|
||||
Vector diff = loc1.toVector().subtract(loc2.toVector()).normalize().setY(kbUp);
|
||||
Vector vel = velocity.clone().add(diff).multiply(0.5);
|
||||
|
||||
Vector vel = velocity.clone().add(diff);
|
||||
if (vel.length() > 1) vel.normalize();
|
||||
if (vel.getY() > kbUp) vel.setY(kbUp);
|
||||
if (groundTicks != 0) vel.multiply(0.8).setY(0.4);
|
||||
else if (vel.getY() > kbUp) vel.setY(kbUp);
|
||||
|
||||
velocity = vel;
|
||||
kbTicks = 10;
|
||||
|
||||
@@ -27,6 +27,12 @@ public class BotManager implements Listener {
|
||||
|
||||
private final Set<Bot> bots = new HashSet<>();
|
||||
|
||||
public BotManager(PlayerAI plugin) {
|
||||
this.plugin = plugin;
|
||||
this.agent = new BotAgent(this);
|
||||
this.numberFormat = NumberFormat.getInstance(Locale.US);
|
||||
}
|
||||
|
||||
public Set<Bot> fetch() {
|
||||
return bots;
|
||||
}
|
||||
@@ -35,10 +41,8 @@ public class BotManager implements Listener {
|
||||
bots.add(bot);
|
||||
}
|
||||
|
||||
public BotManager(PlayerAI plugin) {
|
||||
this.plugin = plugin;
|
||||
this.agent = new BotAgent(this);
|
||||
this.numberFormat = NumberFormat.getInstance(Locale.US);
|
||||
public BotAgent getAgent() {
|
||||
return agent;
|
||||
}
|
||||
|
||||
public void createBots(Player sender, String name, String skin, int n) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.nuggetmc.ai.utils.PlayerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class BotAgent {
|
||||
@@ -14,11 +15,32 @@ public class BotAgent {
|
||||
private PlayerAI plugin;
|
||||
private BotManager manager;
|
||||
|
||||
private final BukkitScheduler scheduler;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private int taskID;
|
||||
|
||||
public BotAgent(BotManager manager) {
|
||||
this.plugin = PlayerAI.getInstance();
|
||||
this.manager = manager;
|
||||
this.scheduler = Bukkit.getScheduler();
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::tick, 0, 1);
|
||||
setEnabled(true);
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean b) {
|
||||
enabled = b;
|
||||
|
||||
if (b) {
|
||||
taskID = scheduler.scheduleSyncRepeatingTask(plugin, this::tick, 0, 1);
|
||||
} else {
|
||||
scheduler.cancelTask(taskID);
|
||||
}
|
||||
}
|
||||
|
||||
private void tick() {
|
||||
@@ -61,7 +83,7 @@ public class BotAgent {
|
||||
vel.checkFinite();
|
||||
vel.add(bot.velocity);
|
||||
} catch (IllegalArgumentException e) {
|
||||
vel = bot.velocity;
|
||||
vel = new Vector(0, 0.5, 0);
|
||||
}
|
||||
|
||||
if (vel.length() > 1) vel.normalize();
|
||||
|
||||
Reference in New Issue
Block a user