From 8743a66ca269dd82cedd8d07789497e4b207ef02 Mon Sep 17 00:00:00 2001 From: MiniDigger | Martin Date: Sat, 16 May 2020 15:25:40 +0200 Subject: [PATCH] Fix usage of vanilla goals --- .../Implement-Mob-Goal-API.patch | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/Spigot-Server-Patches/Implement-Mob-Goal-API.patch b/Spigot-Server-Patches/Implement-Mob-Goal-API.patch index 8f2cb779f8..6f7db7cf58 100644 --- a/Spigot-Server-Patches/Implement-Mob-Goal-API.patch +++ b/Spigot-Server-Patches/Implement-Mob-Goal-API.patch @@ -446,14 +446,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public void addGoal(T mob, int priority, Goal goal) { + CraftMob craftMob = (CraftMob) mob; -+ checkType(craftMob, goal.getTypes()); + getHandle(craftMob, goal.getTypes()).addGoal(priority, new PaperCustomGoal<>(goal)); + } + + @Override + public void removeGoal(T mob, Goal goal) { + CraftMob craftMob = (CraftMob) mob; -+ checkType(craftMob, goal.getTypes()); + if (goal instanceof PaperCustomGoal) { + getHandle(craftMob, goal.getTypes()).removeGoal((PathfinderGoal) goal); + } else if (goal instanceof PaperVanillaGoal) { @@ -631,16 +629,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return goals; + } + -+ private void checkType(CraftMob mob, EnumSet types) { -+ if (!hasHandle(types)) { -+ throw new IllegalArgumentException(mob + " has no goal selector for types " + types); -+ } -+ } -+ -+ private boolean hasHandle(EnumSet type) { -+ return !type.isEmpty(); -+ } -+ + private PathfinderGoalSelector getHandle(CraftMob mob, EnumSet types) { + if (types.contains(GoalType.TARGET)) { + return mob.getHandle().targetSelector; @@ -693,12 +681,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public boolean shouldActivate() { -+ return handle.shouldActivate(); ++ return handle.shouldActivate2(); + } + + @Override + public boolean shouldStayActive() { -+ return handle.shouldStayActive(); ++ return handle.shouldStayActive2(); + } + + @Override @@ -748,10 +736,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public PathfinderGoal() {} - public abstract boolean a(); -+ public boolean a() { return this.shouldActivate(); } public boolean shouldActivate() { return false;} // Paper - OBFHELPER ++ public boolean a() { return this.shouldActivate(); } public boolean shouldActivate() { return false;} public boolean shouldActivate2() { return a(); } // Paper - OBFHELPER, for both directions... - public boolean b() { -+ public boolean b() { return this.shouldStayActive(); } public boolean shouldStayActive() { // Paper - OBFHELPER ++ public boolean b() { return this.shouldStayActive(); } public boolean shouldStayActive2() { return b(); } public boolean shouldStayActive() { // Paper - OBFHELPER, for both directions... return this.a(); }