fix more bugs
This commit is contained in:
@@ -255,6 +255,16 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
return isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBotHealth() {
|
||||
return getHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBotMaxHealth() {
|
||||
return getMaxHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
loadChunks();
|
||||
@@ -412,7 +422,6 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
public void setShield(boolean enabled) {
|
||||
this.shield = enabled;
|
||||
|
||||
System.out.println("set shield");
|
||||
setItemOffhand(new org.bukkit.inventory.ItemStack(enabled ? Material.SHIELD : Material.AIR));
|
||||
}
|
||||
|
||||
@@ -421,7 +430,7 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
|
||||
MathUtils.clean(velocity); // TODO lag????
|
||||
|
||||
if (isInWater()) {
|
||||
if (isBotInWater()) {
|
||||
y = Math.min(velocity.getY() + 0.1, 0.1);
|
||||
addFriction(0.8);
|
||||
velocity.setY(y);
|
||||
@@ -440,7 +449,7 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInWater() {
|
||||
public boolean isBotInWater() {
|
||||
Location loc = getLocation();
|
||||
|
||||
for (int i = 0; i <= 2; i++) {
|
||||
@@ -531,7 +540,7 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnGround() {
|
||||
public boolean isBotOnGround() {
|
||||
return groundTicks != 0;
|
||||
}
|
||||
|
||||
@@ -552,6 +561,16 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBot() {
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
this.remove(RemovalReason.DISCARDED);
|
||||
} else {
|
||||
scheduler.runTask(plugin, () -> this.remove(RemovalReason.DISCARDED));
|
||||
}
|
||||
this.removeVisually();
|
||||
}
|
||||
|
||||
private void removeTab() {
|
||||
sendPacket(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, this));
|
||||
}
|
||||
@@ -667,7 +686,7 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
private void kb(Location loc1, Location loc2) {
|
||||
Vector vel = loc1.toVector().subtract(loc2.toVector()).setY(0).normalize().multiply(0.3);
|
||||
|
||||
if (isOnGround()) vel.multiply(0.8).setY(0.4);
|
||||
if (isBotOnGround()) vel.multiply(0.8).setY(0.4);
|
||||
|
||||
velocity = vel;
|
||||
}
|
||||
@@ -687,6 +706,11 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBotPitch(float pitch) {
|
||||
super.setXRot(pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void faceLocation(Location loc) {
|
||||
look(loc.toVector().subtract(getLocation().toVector()), false);
|
||||
@@ -742,7 +766,6 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
@Override
|
||||
public void setItemOffhand(org.bukkit.inventory.ItemStack item) {
|
||||
setItem(item, EquipmentSlot.OFFHAND);
|
||||
System.out.println("set offhand");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -754,15 +777,15 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
public void setItem(org.bukkit.inventory.ItemStack item, EquipmentSlot slot) {
|
||||
if (item == null) item = defaultItem;
|
||||
|
||||
System.out.println("set");
|
||||
//System.out.println("set");
|
||||
if (slot == EquipmentSlot.MAINHAND) {
|
||||
getBukkitEntity().getInventory().setItemInMainHand(item);
|
||||
} else if (slot == EquipmentSlot.OFFHAND) {
|
||||
getBukkitEntity().getInventory().setItemInOffHand(item);
|
||||
}
|
||||
|
||||
System.out.println("slot = " + slot);
|
||||
System.out.println("item = " + item);
|
||||
//System.out.println("slot = " + slot);
|
||||
//System.out.println("item = " + item);
|
||||
sendPacket(new ClientboundSetEquipmentPacket(getId(), new ArrayList<>(Collections.singletonList(
|
||||
new Pair<>(slot, CraftItemStack.asNMSCopy(item))
|
||||
))));
|
||||
|
||||
@@ -63,6 +63,10 @@ public class AICommand extends CommandInstance implements AIManager {
|
||||
desc = "Begin an AI training session."
|
||||
)
|
||||
public void reinforcement(Player sender, @Arg("population-size") int populationSize, @Arg("name") String name, @OptArg("skin") String skin) {
|
||||
//FIXME: Sometimes, bots will become invisible, or just stop working if they're the last one alive, this has been partially fixed (invis part) see Terminator#removeBot, which removes the bot.
|
||||
//This seems to fix it for the most part, but its still buggy, as the bot will sometimes still freeze
|
||||
//see https://cdn.carbonhost.cloud/6201479d7b237373ab269385/screenshots/javaw_DluMN4m0FR.png
|
||||
//Blocks are also not placeable where bots have died
|
||||
if (agent != null) {
|
||||
sender.sendMessage("A session is already active.");
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.nuggetmc.tplus.utils;
|
||||
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.nuggetmc.tplus.TerminatorPlus;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import net.nuggetmc.tplus.api.agent.Agent;
|
||||
@@ -178,6 +179,17 @@ public class Debugger {
|
||||
}
|
||||
}
|
||||
|
||||
public void renderBots() {
|
||||
int rendered = 0;
|
||||
for (Terminator fetch : TerminatorPlus.getInstance().getManager().fetch()) {
|
||||
rendered++;
|
||||
Bot bot = (Bot) fetch;
|
||||
ServerGamePacketListenerImpl connection = bot.getBukkitEntity().getHandle().connection;
|
||||
fetch.renderBot(connection, true);
|
||||
}
|
||||
print("Rendered " + rendered + " bots.");
|
||||
}
|
||||
|
||||
public void lol(String name, String skinName) {
|
||||
String[] skin = MojangAPI.getSkin(skinName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user