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();
int getId();
int getEntityId();
GameProfile getGameProfile();
@@ -29,7 +29,7 @@ public interface Terminator {
Location getLocation();
boolean isAlive();
boolean isBotAlive(); //Has to be named like this because paper re-obfuscates it
float getHealth();
@@ -37,11 +37,11 @@ public interface Terminator {
void ignite();
boolean isOnFire();
boolean isBotOnFire();
boolean isFalling();
boolean isBlocking();
boolean isBotBlocking();
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
private void tickBot(Terminator bot) {
if (!bot.isAlive()) return;
if (!bot.isBotAlive()) return;
Location loc = bot.getLocation();

View File

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

View File

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

View File

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

View File

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

View File

@@ -213,7 +213,7 @@ public class Debugger {
public void tpall() {
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() {
@@ -334,7 +334,7 @@ public class Debugger {
}
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) {
print("Failed to locate a bot.");

View File

@@ -12,7 +12,7 @@ repositories {
}
dependencies {
implementation(project(":TerminatorPlus-Plugin"))
implementation(project(":TerminatorPlus-Plugin", "reobf"))
implementation(project(":TerminatorPlus-API"))
}
@@ -20,7 +20,7 @@ tasks.jar {
from(configurations.compileClasspath.get().map { if (it.isDirectory()) it else zipTree(it) })
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) {