Fix mobtarget and obstacles
-Fix trapdoors -Fix mobtarget (and make the setting global)
This commit is contained in:
@@ -929,7 +929,7 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
@@ -937,6 +937,14 @@ public class LegacyAgent extends Agent {
|
||||
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) {
|
||||
if (LegacyMats.BREAK.contains(block.getType())) {
|
||||
return false;
|
||||
|
||||
@@ -921,12 +921,4 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
this.yRotO = this.getYRot();
|
||||
this.xRotO = this.getXRot();
|
||||
}
|
||||
|
||||
public boolean isIgnoredByMobs() {
|
||||
return ignoredByMobs;
|
||||
}
|
||||
|
||||
public void setIgnoredByMobs(boolean ignoredByMobs) {
|
||||
this.ignoredByMobs = ignoredByMobs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,6 @@ public class BotManagerImpl implements BotManager, Listener {
|
||||
} else if (i > 1) {
|
||||
bot.setVelocity(randomVelocity().multiply(f));
|
||||
}
|
||||
bot.setIgnoredByMobs(!mobTarget);
|
||||
|
||||
bots.add(bot);
|
||||
i++;
|
||||
@@ -232,8 +231,10 @@ public class BotManagerImpl implements BotManager, Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onMobTarget(EntityTargetLivingEntityEvent event) {
|
||||
Bot bot = (Bot) getBot(event.getEntity().getUniqueId());
|
||||
if (bot != null && bot.isIgnoredByMobs()) {
|
||||
if (mobTarget || event.getTarget() == null)
|
||||
return;
|
||||
Bot bot = (Bot) getBot(event.getTarget().getUniqueId());
|
||||
if (bot != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,8 +291,8 @@ public class BotCommand extends CommandInstance {
|
||||
sender.sendMessage(ChatUtils.LINE);
|
||||
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 + "mobtarget" + ChatUtils.BULLET_FORMATTED + "Allow all future bots spawned 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 + "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 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.LINE);
|
||||
return;
|
||||
@@ -325,7 +325,7 @@ public class BotCommand extends CommandInstance {
|
||||
return;
|
||||
}
|
||||
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")) {
|
||||
if (args.size() < 2) {
|
||||
sender.sendMessage(ChatColor.RED + "You must specify a player name!");
|
||||
|
||||
Reference in New Issue
Block a user