Fix bot stuck issue

-Removed snow breaking feature (wrong kind of fix)
-Remove snow from LegacyMats (because snow can have a hitbox if more than 1 layer)
This commit is contained in:
ThisTestUser
2022-12-15 19:59:28 -05:00
parent 58f39c1d39
commit 88bf90080c
2 changed files with 17 additions and 41 deletions

View File

@@ -184,7 +184,7 @@ public class LegacyAgent extends Agent {
if (checkDown(bot, botPlayer, livingTarget.getLocation(), bothXZ)) return; if (checkDown(bot, botPlayer, livingTarget.getLocation(), bothXZ)) return;
if ((withinTargetXZ || sameXZ) && checkUp(bot, livingTarget, botPlayer, target, withinTargetXZ)) return; if ((withinTargetXZ || sameXZ) && checkUp(bot, livingTarget, botPlayer, target, withinTargetXZ, sameXZ)) return;
if (bothXZ) sideResult = checkSide(bot, livingTarget, botPlayer); if (bothXZ) sideResult = checkSide(bot, livingTarget, botPlayer);
@@ -510,24 +510,6 @@ public class LegacyAgent extends Agent {
Collections.sort(locStanding, (a, b) -> Collections.sort(locStanding, (a, b) ->
Double.compare(BotUtils.getHorizSqDist(a, player.getLocation()), BotUtils.getHorizSqDist(b, player.getLocation()))); Double.compare(BotUtils.getHorizSqDist(a, player.getLocation()), BotUtils.getHorizSqDist(b, player.getLocation())));
//Break snow in the way
for (Location loc : locStanding) {
if (loc.getBlock().getType() == Material.SNOW) {
get = loc.getBlock();
npc.faceLocation(get.getLocation());
level = LegacyLevel.getOffset(player.getLocation(), loc);
if (level != null) {
preBreak(npc, player, get, level);
return level;
} else {
//This should not happen
level = null;
get = null;
}
}
}
//Break potential obstructing walls //Break potential obstructing walls
for (Location loc : locStanding) { for (Location loc : locStanding) {
boolean up = false; boolean up = false;
@@ -596,11 +578,6 @@ public class LegacyAgent extends Agent {
//Break standing block //Break standing block
get = standing; get = standing;
level = LegacyLevel.BELOW; level = LegacyLevel.BELOW;
noJump.add(player);
scheduler.runTaskLater(plugin, () -> {
noJump.remove(player);
}, 15);
} else { } else {
//Break above //Break above
Block above = npc.getLocation().add(0, 2, 0).getBlock(); Block above = npc.getLocation().add(0, 2, 0).getBlock();
@@ -639,11 +616,6 @@ public class LegacyAgent extends Agent {
//Break standing block //Break standing block
get = standing; get = standing;
level = LegacyLevel.BELOW; level = LegacyLevel.BELOW;
noJump.add(player);
scheduler.runTaskLater(plugin, () -> {
noJump.remove(player);
}, 15);
} else { } else {
//Break above //Break above
Block above = npc.getLocation().add(0, 2, 0).getBlock(); Block above = npc.getLocation().add(0, 2, 0).getBlock();
@@ -682,11 +654,6 @@ public class LegacyAgent extends Agent {
//Break standing block //Break standing block
get = standing; get = standing;
level = LegacyLevel.BELOW; level = LegacyLevel.BELOW;
noJump.add(player);
scheduler.runTaskLater(plugin, () -> {
noJump.remove(player);
}, 15);
} else { } else {
//Break above //Break above
Block above = npc.getLocation().add(0, 2, 0).getBlock(); Block above = npc.getLocation().add(0, 2, 0).getBlock();
@@ -725,11 +692,6 @@ public class LegacyAgent extends Agent {
//Break standing block //Break standing block
get = standing; get = standing;
level = LegacyLevel.BELOW; level = LegacyLevel.BELOW;
noJump.add(player);
scheduler.runTaskLater(plugin, () -> {
noJump.remove(player);
}, 15);
} else { } else {
//Break above //Break above
Block above = npc.getLocation().add(0, 2, 0).getBlock(); Block above = npc.getLocation().add(0, 2, 0).getBlock();
@@ -783,6 +745,11 @@ public class LegacyAgent extends Agent {
if (level != null) { if (level != null) {
if (level == LegacyLevel.BELOW) { if (level == LegacyLevel.BELOW) {
noJump.add(player);
scheduler.runTaskLater(plugin, () -> {
noJump.remove(player);
}, 15);
npc.look(BlockFace.DOWN); npc.look(BlockFace.DOWN);
downMine(npc, player, get); downMine(npc, player, get);
} else if (level == LegacyLevel.ABOVE) } else if (level == LegacyLevel.ABOVE)
@@ -793,7 +760,7 @@ public class LegacyAgent extends Agent {
return level; return level;
} }
private boolean checkUp(Terminator npc, LivingEntity target, LivingEntity playerNPC, Location loc, boolean c) { private boolean checkUp(Terminator npc, LivingEntity target, LivingEntity playerNPC, Location loc, boolean c, boolean sameXZ) {
Location a = playerNPC.getLocation(); Location a = playerNPC.getLocation();
Location b = target.getLocation(); Location b = target.getLocation();
@@ -925,6 +892,16 @@ public class LegacyAgent extends Agent {
} }
return true; return true;
} else if (sameXZ && LegacyMats.BREAK.contains(m1)) {
Block block = npc.getStandingOn().isEmpty() ? null : npc.getStandingOn().get(0);
if (block != null && block.getLocation().getBlockY() == playerNPC.getLocation().getBlockY()
&& !LegacyMats.BREAK.contains(block.getType())) {
npc.look(BlockFace.DOWN);
downMine(npc, playerNPC, block);
preBreak(npc, playerNPC, block, LegacyLevel.BELOW);
return true;
}
} }
} }

View File

@@ -99,7 +99,6 @@ public class LegacyMats {
Material.WATER, Material.WATER,
Material.LAVA, Material.LAVA,
Material.TALL_GRASS, Material.TALL_GRASS,
Material.SNOW,
Material.CAVE_AIR, Material.CAVE_AIR,
Material.VINE, Material.VINE,
Material.FERN, Material.FERN,