Fixes EffSetPathGoal not working correctly.

Also fixes some unhandled exceptions and a loop that was breaking when
it wasn't supposed to.
This commit is contained in:
TheBukor
2016-12-14 14:14:34 -02:00
parent f784116a82
commit 6bdfc3196e
11 changed files with 33 additions and 19 deletions
@@ -32,9 +32,9 @@ public class EffClearPathGoals extends Effect {
protected void execute(Event e) {
LivingEntity[] ents = entities.getAll(e);
for (LivingEntity ent : ents) {
if (ent instanceof Player || ent instanceof ArmorStand || ent == null)
continue;
SkStuff.getNMSMethods().clearPathfinderGoals(ent);
if (!(ent instanceof Player || ent instanceof ArmorStand || ent == null)) {
SkStuff.getNMSMethods().clearPathfinderGoals(ent);
}
}
}
}
@@ -38,15 +38,15 @@ public class EffMakeJump extends Effect {
protected void execute(Event e) {
LivingEntity[] ents = entities.getAll(e);
for (Entity ent : ents) {
if (ent == null || ent instanceof Player || ent instanceof ArmorStand)
continue;
Object obcEnt = craftLivEnt.cast(ent);
try {
Object nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
Object controllerJump = nmsEnt.getClass().getMethod("getControllerJump").invoke(nmsEnt);
controllerJump.getClass().getMethod("a").invoke(controllerJump);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
ex.printStackTrace();
if (!(ent == null || ent instanceof Player || ent instanceof ArmorStand)) {
Object obcEnt = craftLivEnt.cast(ent);
try {
Object nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
Object controllerJump = nmsEnt.getClass().getMethod("getControllerJump").invoke(nmsEnt);
controllerJump.getClass().getMethod("a").invoke(controllerJump);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
ex.printStackTrace();
}
}
}
}
@@ -49,8 +49,9 @@ public class EffRemovePathGoal extends Effect {
protected void execute(Event e) {
LivingEntity[] ents = entities.getAll(e);
for (LivingEntity ent : ents) {
if (ent instanceof Player || ent instanceof ArmorStand || ent == null)
if (ent instanceof Player || ent instanceof ArmorStand || ent == null) {
return;
}
Object obcEnt = craftLivEnt.cast(ent);
Object nmsEnt = null;
try {
@@ -157,7 +157,7 @@ public class EffSetPathGoal extends Effect {
bowShootUnkParam = (Expression<Number>) expr[36];
bowShootFollowRange = (Expression<Number>) expr[37];
}
entities = (Expression<LivingEntity>) expr[35];
entities = (Expression<LivingEntity>) expr[38];
return true;
}
@@ -169,7 +169,7 @@ public class EffSetPathGoal extends Effect {
@SuppressWarnings("deprecation")
@Override
protected void execute(Event e) {
LivingEntity[] ents = entities.getAll(e);
LivingEntity[] ents = entities.getAll(e);
for (LivingEntity ent : ents) {
if (ent == null || ent instanceof Player || ent instanceof ArmorStand)
return;