Fix mobtarget and obstacles

-Fix trapdoors
-Fix mobtarget (and make the setting global)
This commit is contained in:
ThisTestUser
2022-10-04 11:01:06 -04:00
parent 08dd248fba
commit e626fa7144
4 changed files with 26 additions and 25 deletions

View File

@@ -929,7 +929,7 @@ public class LegacyAgent extends Agent {
} }
private boolean checkObstacles(Terminator bot, Block block, LivingEntity player) { private boolean checkObstacles(Terminator bot, Block block, LivingEntity player) {
if (LegacyMats.OBSTACLES.contains(block.getType())) { if (LegacyMats.OBSTACLES.contains(block.getType()) || isDoorObstacle(block)) {
preBreak(bot, player, block, LegacyLevel.AT_D); preBreak(bot, player, block, LegacyLevel.AT_D);
return true; return true;
} }
@@ -937,6 +937,14 @@ public class LegacyAgent extends Agent {
return false; return false;
} }
private boolean isDoorObstacle(Block block) {
if (block.getType().data == Door.class)
return true;
if (block.getType().data == TrapDoor.class && ((TrapDoor)block.getBlockData()).isOpen())
return true;
return false;
}
private boolean checkAt(Terminator bot, Block block, LivingEntity player) { private boolean checkAt(Terminator bot, Block block, LivingEntity player) {
if (LegacyMats.BREAK.contains(block.getType())) { if (LegacyMats.BREAK.contains(block.getType())) {
return false; return false;

View File

@@ -921,12 +921,4 @@ public class Bot extends ServerPlayer implements Terminator {
this.yRotO = this.getYRot(); this.yRotO = this.getYRot();
this.xRotO = this.getXRot(); this.xRotO = this.getXRot();
} }
public boolean isIgnoredByMobs() {
return ignoredByMobs;
}
public void setIgnoredByMobs(boolean ignoredByMobs) {
this.ignoredByMobs = ignoredByMobs;
}
} }

View File

@@ -149,7 +149,6 @@ public class BotManagerImpl implements BotManager, Listener {
} else if (i > 1) { } else if (i > 1) {
bot.setVelocity(randomVelocity().multiply(f)); bot.setVelocity(randomVelocity().multiply(f));
} }
bot.setIgnoredByMobs(!mobTarget);
bots.add(bot); bots.add(bot);
i++; i++;
@@ -232,8 +231,10 @@ public class BotManagerImpl implements BotManager, Listener {
@EventHandler @EventHandler
public void onMobTarget(EntityTargetLivingEntityEvent event) { public void onMobTarget(EntityTargetLivingEntityEvent event) {
Bot bot = (Bot) getBot(event.getEntity().getUniqueId()); if (mobTarget || event.getTarget() == null)
if (bot != null && bot.isIgnoredByMobs()) { return;
Bot bot = (Bot) getBot(event.getTarget().getUniqueId());
if (bot != null) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@@ -291,8 +291,8 @@ public class BotCommand extends CommandInstance {
sender.sendMessage(ChatUtils.LINE); sender.sendMessage(ChatUtils.LINE);
sender.sendMessage(ChatColor.GOLD + "Bot Settings" + extra); sender.sendMessage(ChatColor.GOLD + "Bot Settings" + extra);
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "setgoal" + ChatUtils.BULLET_FORMATTED + "Set the global bot target selection method."); sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "setgoal" + ChatUtils.BULLET_FORMATTED + "Set the global bot target selection method.");
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "mobtarget" + ChatUtils.BULLET_FORMATTED + "Allow all future bots spawned to be targeted by hostile mobs."); sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "mobtarget" + ChatUtils.BULLET_FORMATTED + "Allow all bots to be targeted by hostile mobs.");
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "playertarget" + ChatUtils.BULLET_FORMATTED + "Sets a player name for the bots to focus on if the goal is PLAYER."); sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "playertarget" + ChatUtils.BULLET_FORMATTED + "Sets a player name for spawned bots to focus on if the goal is PLAYER.");
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "region" + ChatUtils.BULLET_FORMATTED + "Sets a region for the bots to prioritize entities inside."); sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "region" + ChatUtils.BULLET_FORMATTED + "Sets a region for the bots to prioritize entities inside.");
sender.sendMessage(ChatUtils.LINE); sender.sendMessage(ChatUtils.LINE);
return; return;
@@ -325,7 +325,7 @@ public class BotCommand extends CommandInstance {
return; return;
} }
manager.setMobTarget(Boolean.parseBoolean(arg2)); manager.setMobTarget(Boolean.parseBoolean(arg2));
sender.sendMessage("Mob targeting is now " + (manager.isMobTarget() ? ChatColor.GREEN + "enabled" : ChatColor.RED + "disabled") + ChatColor.RESET + ". (for all future bots)"); sender.sendMessage("Mob targeting is now " + (manager.isMobTarget() ? ChatColor.GREEN + "enabled" : ChatColor.RED + "disabled") + ChatColor.RESET + ".");
} else if (arg1.equalsIgnoreCase("playertarget")) { } else if (arg1.equalsIgnoreCase("playertarget")) {
if (args.size() < 2) { if (args.size() < 2) {
sender.sendMessage(ChatColor.RED + "You must specify a player name!"); sender.sendMessage(ChatColor.RED + "You must specify a player name!");