make build work & fix some crashes

This commit is contained in:
Badbird-5907
2022-06-17 21:09:08 -04:00
parent 6610ac05db
commit 5bfd9f9a8e
8 changed files with 32 additions and 22 deletions

View File

@@ -15,7 +15,7 @@ public interface Terminator {
String getBotName(); String getBotName();
int getId(); int getEntityId();
GameProfile getGameProfile(); GameProfile getGameProfile();
@@ -29,7 +29,7 @@ public interface Terminator {
Location getLocation(); Location getLocation();
boolean isAlive(); boolean isBotAlive(); //Has to be named like this because paper re-obfuscates it
float getHealth(); float getHealth();
@@ -37,11 +37,11 @@ public interface Terminator {
void ignite(); void ignite();
boolean isOnFire(); boolean isBotOnFire();
boolean isFalling(); boolean isFalling();
boolean isBlocking(); boolean isBotBlocking();
void block(int length, int cooldown); void block(int length, int cooldown);

View File

@@ -36,7 +36,7 @@ public class BotAgent extends Agent {
// This is where the code starts to get spicy // This is where the code starts to get spicy
private void tickBot(Terminator bot) { private void tickBot(Terminator bot) {
if (!bot.isAlive()) return; if (!bot.isBotAlive()) return;
Location loc = bot.getLocation(); Location loc = bot.getLocation();

View File

@@ -64,7 +64,7 @@ public class LegacyAgent extends Agent {
} }
private void center(Terminator bot) { private void center(Terminator bot) {
if (bot == null || !bot.isAlive()) { if (bot == null || !bot.isBotAlive()) {
return; return;
} }
@@ -89,7 +89,7 @@ public class LegacyAgent extends Agent {
} }
private void tickBot(Terminator bot) { private void tickBot(Terminator bot) {
if (!bot.isAlive()) { if (!bot.isBotAlive()) {
return; return;
} }
@@ -227,7 +227,7 @@ public class LegacyAgent extends Agent {
NeuralNetwork network = bot.getNeuralNetwork(); NeuralNetwork network = bot.getNeuralNetwork();
if (network.dynamicLR()) { if (network.dynamicLR()) {
if (bot.isBlocking()) { if (bot.isBotBlocking()) {
vel.multiply(0.6); vel.multiply(0.6);
} }
@@ -253,7 +253,7 @@ public class LegacyAgent extends Agent {
boolean left = network.check(BotNode.LEFT); boolean left = network.check(BotNode.LEFT);
boolean right = network.check(BotNode.RIGHT); boolean right = network.check(BotNode.RIGHT);
if (bot.isBlocking()) { if (bot.isBotBlocking()) {
vel.multiply(0.6); vel.multiply(0.6);
} }
@@ -313,7 +313,7 @@ public class LegacyAgent extends Agent {
double dot = loc.toVector().subtract(player.getLocation().toVector()).normalize().dot(loc.getDirection()); double dot = loc.toVector().subtract(player.getLocation().toVector()).normalize().dot(loc.getDirection());
if (bot.isBlocking() && dot >= -0.1) { if (bot.isBotBlocking() && dot >= -0.1) {
player.getWorld().playSound(bot.getLocation(), Sound.ITEM_SHIELD_BLOCK, 1, 1); player.getWorld().playSound(bot.getLocation(), Sound.ITEM_SHIELD_BLOCK, 1, 1);
event.setCancelled(true); event.setCancelled(true);
} }
@@ -903,7 +903,7 @@ public class LegacyAgent extends Agent {
String worldName = world.getName(); String worldName = world.getName();
Location loc = bot.getLocation(); Location loc = bot.getLocation();
if (bot.isOnFire()) { if (bot.isBotOnFire()) {
if (bot.getBukkitEntity().getWorld().getEnvironment() != World.Environment.NETHER) { if (bot.getBukkitEntity().getWorld().getEnvironment() != World.Environment.NETHER) {
placeWaterDown(bot, world, loc); placeWaterDown(bot, world, loc);
} }
@@ -1035,7 +1035,7 @@ public class LegacyAgent extends Agent {
scheduler.runTaskLater(plugin, () -> { scheduler.runTaskLater(plugin, () -> {
boatCooldown.remove(bot); boatCooldown.remove(bot);
if (bot.isAlive()) { if (bot.isBotAlive()) {
bot.faceLocation(target.getLocation()); bot.faceLocation(target.getLocation());
} }
}, 5); }, 5);

View File

@@ -244,7 +244,7 @@ public class IntelligenceAgent {
} }
private int aliveCount() { private int aliveCount() {
return (int) bots.values().stream().filter(Terminator::isAlive).count(); return (int) bots.values().stream().filter(Terminator::isBotAlive).count();
} }
private void close() { private void close() {

View File

@@ -67,7 +67,7 @@ public class Bot extends ServerPlayer implements Terminator {
private boolean removeOnDeath; private boolean removeOnDeath;
private int aliveTicks; private int aliveTicks;
private int kills; private int kills;
private byte fireTicks; private byte fireTicks; // Fire animation isn't played? Bot still takes damage.
private byte groundTicks; private byte groundTicks;
private byte jumpTicks; private byte jumpTicks;
private byte noFallTicks; private byte noFallTicks;
@@ -129,6 +129,11 @@ public class Bot extends ServerPlayer implements Terminator {
return displayName; return displayName;
} }
@Override
public int getEntityId() {
return getId();
}
@Override @Override
public NeuralNetwork getNeuralNetwork() { public NeuralNetwork getNeuralNetwork() {
return network; return network;
@@ -245,6 +250,11 @@ public class Bot extends ServerPlayer implements Terminator {
Bukkit.getOnlinePlayers().forEach(p -> ((CraftPlayer) p).getHandle().connection.send(packet)); Bukkit.getOnlinePlayers().forEach(p -> ((CraftPlayer) p).getHandle().connection.send(packet));
} }
@Override
public boolean isBotAlive() {
return isAlive();
}
@Override @Override
public void tick() { public void tick() {
loadChunks(); loadChunks();
@@ -352,7 +362,7 @@ public class Bot extends ServerPlayer implements Terminator {
} }
@Override @Override
public boolean isOnFire() { public boolean isBotOnFire() {
return fireTicks != 0; return fireTicks != 0;
} }
@@ -395,8 +405,8 @@ public class Bot extends ServerPlayer implements Terminator {
} }
@Override @Override
public boolean isBlocking() { public boolean isBotBlocking() {
return blocking; return isBlocking();
} }
public void setShield(boolean enabled) { public void setShield(boolean enabled) {

View File

@@ -186,7 +186,7 @@ public class BotManagerImpl implements BotManager, Listener {
@Override @Override
public Terminator getBot(int entityId) { public Terminator getBot(int entityId) {
for (Terminator bot : bots) { for (Terminator bot : bots) {
if (bot.getId() == entityId) { if (bot.getEntityId() == entityId) {
return bot; return bot;
} }
} }

View File

@@ -213,7 +213,7 @@ public class Debugger {
public void tpall() { public void tpall() {
Player player = (Player) sender; Player player = (Player) sender;
TerminatorPlus.getInstance().getManager().fetch().stream().filter(Terminator::isAlive).forEach(bot -> bot.getBukkitEntity().teleport(player)); TerminatorPlus.getInstance().getManager().fetch().stream().filter(Terminator::isBotAlive).forEach(bot -> bot.getBukkitEntity().teleport(player));
} }
public void viewsession() { public void viewsession() {
@@ -334,7 +334,7 @@ public class Debugger {
} }
public void tp() { public void tp() {
Terminator bot = MathUtils.getRandomSetElement(TerminatorPlus.getInstance().getManager().fetch().stream().filter(Terminator::isAlive).collect(Collectors.toSet())); Terminator bot = MathUtils.getRandomSetElement(TerminatorPlus.getInstance().getManager().fetch().stream().filter(Terminator::isBotAlive).collect(Collectors.toSet()));
if (bot == null) { if (bot == null) {
print("Failed to locate a bot."); print("Failed to locate a bot.");

View File

@@ -12,7 +12,7 @@ repositories {
} }
dependencies { dependencies {
implementation(project(":TerminatorPlus-Plugin")) implementation(project(":TerminatorPlus-Plugin", "reobf"))
implementation(project(":TerminatorPlus-API")) implementation(project(":TerminatorPlus-API"))
} }
@@ -20,7 +20,7 @@ tasks.jar {
from(configurations.compileClasspath.get().map { if (it.isDirectory()) it else zipTree(it) }) from(configurations.compileClasspath.get().map { if (it.isDirectory()) it else zipTree(it) })
archiveFileName.set(jarName + ".jar") archiveFileName.set(jarName + ".jar")
} }
//TODO currently, the resources are in src/main/resources, because gradle is stubborn and won't include the resources in TerminatroPlus-Plugin/src/main/resources, will need to fix //TODO currently, the resources are in src/main/resources, because gradle is stubborn and won't include the resources in TerminatorPlus-Plugin/src/main/resources, will need to fix
/* /*
task copyPlugin(type: Copy) { task copyPlugin(type: Copy) {