diff --git a/Spigot-API-Patches/Add-Mob-Goal-API.patch b/Spigot-API-Patches/Add-Mob-Goal-API.patch index 966f3a9f8d..76fc3d5e28 100644 --- a/Spigot-API-Patches/Add-Mob-Goal-API.patch +++ b/Spigot-API-Patches/Add-Mob-Goal-API.patch @@ -162,7 +162,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + MOVE, + LOOK, + JUMP, -+ TARGET ++ TARGET, ++ /** ++ * Used to map vanilla goals, that are a behavior goal but don't have a type set... ++ */ ++ UNKNOWN_BEHAVIOR, + +} diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/MobGoals.java b/src/main/java/com/destroystokyo/paper/entity/ai/MobGoals.java diff --git a/Spigot-Server-Patches/Implement-Mob-Goal-API.patch b/Spigot-Server-Patches/Implement-Mob-Goal-API.patch index 92904a7f0e..fdfd3254c8 100644 --- a/Spigot-Server-Patches/Implement-Mob-Goal-API.patch +++ b/Spigot-Server-Patches/Implement-Mob-Goal-API.patch @@ -312,6 +312,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return GoalType.LOOK; + case JUMP: + return GoalType.JUMP; ++ case UNKNOWN_BEHAVIOR: ++ return GoalType.UNKNOWN_BEHAVIOR; + case TARGET: + return GoalType.TARGET; + default: @@ -335,6 +337,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return PathfinderGoal.Type.LOOK; + case JUMP: + return PathfinderGoal.Type.JUMP; ++ case UNKNOWN_BEHAVIOR: ++ return PathfinderGoal.Type.UNKNOWN_BEHAVIOR; + case TARGET: + return PathfinderGoal.Type.TARGET; + default: @@ -400,6 +404,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.handle = handle; + + this.setTypes(MobGoalHelper.paperToVanilla(handle.getTypes())); ++ if (this.getGoalTypes().size() == 0) { ++ this.getGoalTypes().addUnchecked(Type.UNKNOWN_BEHAVIOR); ++ } + } + + @Override @@ -752,8 +759,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/PathfinderGoal.java +++ b/src/main/java/net/minecraft/server/PathfinderGoal.java @@ -0,0 +0,0 @@ public abstract class PathfinderGoal { + private final EnumSet a = EnumSet.noneOf(PathfinderGoal.Type.class); // Paper unused, but dummy to prevent plugins from crashing as hard. Theyll need to support paper in a special case if this is super important, but really doesn't seem like it would be. + private final OptimizedSmallEnumSet goalTypes = new OptimizedSmallEnumSet<>(PathfinderGoal.Type.class); // Paper - remove streams from pathfindergoalselector - public PathfinderGoal() {} +- public PathfinderGoal() {} ++ // Paper start make sure goaltypes is never empty ++ public PathfinderGoal() { ++ if (this.goalTypes.size() == 0) { ++ this.goalTypes.addUnchecked(Type.UNKNOWN_BEHAVIOR); ++ } ++ } ++ // paper end - public abstract boolean a(); + public boolean a() { return this.shouldActivate(); } public boolean shouldActivate() { return false;} public boolean shouldActivate2() { return a(); } // Paper - OBFHELPER, for both directions... @@ -783,6 +799,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper start - remove streams from pathfindergoalselector this.goalTypes.clear(); this.goalTypes.addAllUnchecked(enumset); ++ // make sure its never empty ++ if (this.goalTypes.size() == 0) { ++ this.goalTypes.addUnchecked(Type.UNKNOWN_BEHAVIOR); ++ } + // Paper end - remove streams from pathfindergoalselector + } + +@@ -0,0 +0,0 @@ public abstract class PathfinderGoal { + + public static enum Type { + +- MOVE, LOOK, JUMP, TARGET; ++ MOVE, LOOK, JUMP, TARGET, UNKNOWN_BEHAVIOR; // Paper - add unknown + + private Type() {} + } diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java