This commit is contained in:
Jason Penilla 2021-06-13 19:40:12 -07:00
parent 3e552cc54c
commit f67dc7a35b
No known key found for this signature in database
GPG Key ID: 0E75A301420E48F8
6 changed files with 82 additions and 125 deletions

View File

@ -441,10 +441,10 @@ index 0000000000000000000000000000000000000000..b42091752981a1f309ab350e9a394092
+ GoalKey<Mob> UNIVERSAL_ANGER_RESET = GoalKey.of(Mob.class, NamespacedKey.minecraft("universal_anger_reset"));
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index bbf15311a48ba96e14ffa2ab9d59613e79f06618..4cffbc4f665e267371e99094e8b7de975fffc223 100644
index 847ba5143660d5c56ff8f2cae2169a51b8927757..17553703d6dcb0c7852cc35b08da05075af435f2 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1879,6 +1879,16 @@ public final class Bukkit {
@@ -1867,6 +1867,16 @@ public final class Bukkit {
public static boolean isStopping() {
return server.isStopping();
}
@ -462,10 +462,10 @@ index bbf15311a48ba96e14ffa2ab9d59613e79f06618..4cffbc4f665e267371e99094e8b7de97
@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 21ebe1e70a4b9df54a5c730cee6d024cc1358b88..969cba46ba2790dde32724111ad77332c5872e0b 100644
index e6b62ba32e089e2fd8563ec8430b72196f6680e0..0a109e9157d9a9f15f71d2fa96d31b7f8eb3fde2 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1648,5 +1648,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1638,5 +1638,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return true if server is in the process of being shutdown
*/
boolean isStopping();

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Expose game version
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 847ba5143660d5c56ff8f2cae2169a51b8927757..2c9d2739e78d5c422574f5ddda078ca395c0fa6d 100644
index 17553703d6dcb0c7852cc35b08da05075af435f2..4eb60f2772c80f9917e88c40ed2214993709e443 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -118,6 +118,18 @@ public final class Bukkit {
@ -28,7 +28,7 @@ index 847ba5143660d5c56ff8f2cae2169a51b8927757..2c9d2739e78d5c422574f5ddda078ca3
* Gets a view of all currently logged in players. This {@linkplain
* Collections#unmodifiableCollection(Collection) view} is a reused
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index e6b62ba32e089e2fd8563ec8430b72196f6680e0..46d1086bd7d7f91b4337c8463974d4b9d501cbf0 100644
index 0a109e9157d9a9f15f71d2fa96d31b7f8eb3fde2..22495f576b05e3f0161bfd2c4ea5e5622fdb6302 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -97,6 +97,16 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi

View File

@ -17,7 +17,7 @@ keeping long lived large direct buffers in cache.
Set system properly at server startup if not set already to help protect from this.
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index c288b89bf5a22269823ba1d18af217032d7c6a36..bd10345cb90f98b8af1519afd603a5244f3a5ca2 100644
index 2904cbda94a8fb986d94022c11061f98938237dd..6ebd0f6053929beb246993b5a1b682b9971baf0b 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -28,6 +28,7 @@ public class Main {
@ -27,4 +27,4 @@ index c288b89bf5a22269823ba1d18af217032d7c6a36..bd10345cb90f98b8af1519afd603a524
+ if (System.getProperty("jdk.nio.maxCachedBufferSize") == null) System.setProperty("jdk.nio.maxCachedBufferSize", "262144"); // Paper - cap per-thread NIO cache size
OptionParser parser = new OptionParser() {
{
acceptsAll(asList("?", "help"), "Show the help");
acceptsAll(Main.asList("?", "help"), "Show the help");

View File

@ -4,11 +4,23 @@ Date: Fri, 3 Jan 2020 16:26:19 +0100
Subject: [PATCH] Implement Mob Goal API
diff --git a/build.gradle.kts b/build.gradle.kts
index 2543a4cf2bb58c2265cfc427c427b683d2ff70ca..5c885454c729467e29fd3784058fff6a7379c9dc 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -52,6 +52,7 @@ dependencies {
implementation("co.aikar:cleaner:1.0-SNAPSHOT") // Paper
implementation("io.netty:netty-all:4.1.65.Final") // Paper
+ testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test
testImplementation("junit:junit:4.13.1")
testImplementation("org.hamcrest:hamcrest-library:1.3")
}
diff --git a/pom.xml b/pom.xml
index 4c8a057e790c96b0ab5123549d0566371acacb46..1a9204c869dd36e80932b1366352db15ebd70723 100644
index 86cce7143abd317326cc755118bf61435e82e479..4233698d499b520dfc07c4184cefca633a95d15b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -176,6 +176,13 @@
@@ -121,6 +121,13 @@
<version>1.3</version>
<scope>test</scope>
</dependency>
@ -24,14 +36,12 @@ index 4c8a057e790c96b0ab5123549d0566371acacb46..1a9204c869dd36e80932b1366352db15
<!-- This builds a completely 'ready to start' jar with all dependencies inside -->
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java
new file mode 100644
index 0000000000000000000000000000000000000000..6ddb198f86ccf3bc2471752d5fb2f59d9a7ab4df
index 0000000000000000000000000000000000000000..9efe7e29faf09901e8cde8713db80ceb31453412
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java
@@ -0,0 +1,462 @@
@@ -0,0 +1,463 @@
+package com.destroystokyo.paper.entity.ai;
+
+import GoalKey;
+import GoalType;
+import com.destroystokyo.paper.entity.RangedEntity;
+import com.destroystokyo.paper.util.set.OptimizedSmallEnumSet;
+import com.google.common.collect.BiMap;
@ -42,7 +52,6 @@ index 0000000000000000000000000000000000000000..6ddb198f86ccf3bc2471752d5fb2f59d
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import net.minecraft.world.entity.AgableMob;
+import net.minecraft.world.entity.FlyingMob;
+import net.minecraft.world.entity.PathfinderMob;
+import net.minecraft.world.entity.TamableAnimal;
@ -247,7 +256,7 @@ index 0000000000000000000000000000000000000000..6ddb198f86ccf3bc2471752d5fb2f59d
+ deobfuscationMap.put("shulker_d", "shulker_nearest");
+ deobfuscationMap.put("shulker_e", "shulker_peek");
+ deobfuscationMap.put("squid_a", "squid_flee");
+ deobfuscationMap.put("skeleton_abstract_1", "skeleton_melee");
+ deobfuscationMap.put("abstract_skeleton_1", "skeleton_melee");
+ deobfuscationMap.put("strider_a", "strider_go_to_lava");
+ deobfuscationMap.put("turtle_a", "turtle_breed");
+ deobfuscationMap.put("turtle_b", "turtle_go_home");
@ -268,12 +277,12 @@ index 0000000000000000000000000000000000000000..6ddb198f86ccf3bc2471752d5fb2f59d
+ deobfuscationMap.put("wolf_a", "wolf_avoid_entity");
+ deobfuscationMap.put("zombie_a", "zombie_attack_turtle_egg");
+
+ ignored.add("selector_1");
+ ignored.add("selector_2");
+ ignored.add("goal_selector_1");
+ ignored.add("goal_selector_2");
+ ignored.add("wrapped");
+
+ bukkitMap.put(net.minecraft.world.entity.Mob.class, Mob.class);
+ bukkitMap.put(AgableMob.class, Ageable.class);
+ bukkitMap.put(net.minecraft.world.entity.AgeableMob.class, Ageable.class);
+ bukkitMap.put(AmbientCreature.class, Ambient.class);
+ bukkitMap.put(Animal.class, Animals.class);
+ bukkitMap.put(net.minecraft.world.entity.ambient.Bat.class, Bat.class);
@ -364,8 +373,12 @@ index 0000000000000000000000000000000000000000..6ddb198f86ccf3bc2471752d5fb2f59d
+ bukkitMap.put(net.minecraft.world.entity.monster.piglin.PiglinBrute.class, PiglinBrute.class);
+ bukkitMap.put(net.minecraft.world.entity.monster.Strider.class, Strider.class);
+ bukkitMap.put(net.minecraft.world.entity.monster.Zoglin.class, Zoglin.class);
+ bukkitMap.put(net.minecraft.world.entity.GlowSquid.class, org.bukkit.entity.GlowSquid.class);
+ bukkitMap.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, org.bukkit.entity.Axolotl.class);
+ bukkitMap.put(net.minecraft.world.entity.animal.goat.Goat.class, org.bukkit.entity.Goat.class);
+ }
+
+ // TODO: FIX THIS
+ public static String getUsableName(Class<?> clazz) {
+ String name = clazz.getName();
+ name = name.substring(name.lastIndexOf(".") + 1);
@ -492,20 +505,19 @@ index 0000000000000000000000000000000000000000..6ddb198f86ccf3bc2471752d5fb2f59d
+}
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/PaperCustomGoal.java b/src/main/java/com/destroystokyo/paper/entity/ai/PaperCustomGoal.java
new file mode 100644
index 0000000000000000000000000000000000000000..14ddf844be10c04522aa3ec125fa7a0f540b10c2
index 0000000000000000000000000000000000000000..ee500489fca34c339175b5209ebcf3417640b166
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/ai/PaperCustomGoal.java
@@ -0,0 +1,55 @@
@@ -0,0 +1,54 @@
+package com.destroystokyo.paper.entity.ai;
+
+import GoalKey;
+import net.minecraft.world.entity.ai.goal.Goal;
+import org.bukkit.entity.Mob;
+import com.destroystokyo.paper.entity.ai.Goal;
+
+/**
+ * Wraps api in vanilla
+ */
+public class PaperCustomGoal<T extends Mob> extends Goal {
+public class PaperCustomGoal<T extends Mob> extends net.minecraft.world.entity.ai.goal.Goal {
+
+ private final Goal<T> handle;
+
@ -534,7 +546,7 @@ index 0000000000000000000000000000000000000000..14ddf844be10c04522aa3ec125fa7a0f
+ }
+
+ @Override
+ public void onTaskReset() {
+ public void stop() {
+ handle.stop();
+ }
+
@ -553,10 +565,10 @@ index 0000000000000000000000000000000000000000..14ddf844be10c04522aa3ec125fa7a0f
+}
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java b/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java
new file mode 100644
index 0000000000000000000000000000000000000000..615f571b08da27b0da7c53e3be172959e82e4ab1
index 0000000000000000000000000000000000000000..a17a8d8ced942e6e3f9072f199c75391dd57dc6a
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java
@@ -0,0 +1,222 @@
@@ -0,0 +1,221 @@
+package com.destroystokyo.paper.entity.ai;
+
+import java.util.Collection;
@ -567,7 +579,6 @@ index 0000000000000000000000000000000000000000..615f571b08da27b0da7c53e3be172959
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import net.minecraft.world.entity.ai.goal.Goal;
+import net.minecraft.world.entity.ai.goal.GoalSelector;
+import net.minecraft.world.entity.ai.goal.WrappedGoal;
+import org.bukkit.craftbukkit.entity.CraftMob;
@ -575,7 +586,7 @@ index 0000000000000000000000000000000000000000..615f571b08da27b0da7c53e3be172959
+
+public class PaperMobGoals implements MobGoals {
+
+ private final Map<Goal, PaperVanillaGoal<?>> instanceCache = new HashMap<>();
+ private final Map<net.minecraft.world.entity.ai.goal.Goal, PaperVanillaGoal<?>> instanceCache = new HashMap<>();
+
+ @Override
+ public <T extends Mob> void addGoal(T mob, int priority, Goal<T> goal) {
@ -587,12 +598,12 @@ index 0000000000000000000000000000000000000000..615f571b08da27b0da7c53e3be172959
+ public <T extends Mob> void removeGoal(T mob, Goal<T> goal) {
+ CraftMob craftMob = (CraftMob) mob;
+ if (goal instanceof PaperCustomGoal) {
+ getHandle(craftMob, goal.getTypes()).removeGoal((Goal) goal);
+ getHandle(craftMob, goal.getTypes()).removeGoal((net.minecraft.world.entity.ai.goal.Goal) goal);
+ } else if (goal instanceof PaperVanillaGoal) {
+ getHandle(craftMob, goal.getTypes()).removeGoal(((PaperVanillaGoal<?>) goal).getHandle());
+ } else {
+ List<Goal> toRemove = new LinkedList<>();
+ for (WrappedGoal item : getHandle(craftMob, goal.getTypes()).getTasks()) {
+ List<net.minecraft.world.entity.ai.goal.Goal> toRemove = new LinkedList<>();
+ for (WrappedGoal item : getHandle(craftMob, goal.getTypes()).availableGoals()) {
+ if (item.getGoal() instanceof PaperCustomGoal) {
+ //noinspection unchecked
+ if (((PaperCustomGoal<T>) item.getGoal()).getHandle() == goal) {
@ -601,7 +612,7 @@ index 0000000000000000000000000000000000000000..615f571b08da27b0da7c53e3be172959
+ }
+ }
+
+ for (Goal g : toRemove) {
+ for (net.minecraft.world.entity.ai.goal.Goal g : toRemove) {
+ getHandle(craftMob, goal.getTypes()).removeGoal(g);
+ }
+ }
@ -672,7 +683,7 @@ index 0000000000000000000000000000000000000000..615f571b08da27b0da7c53e3be172959
+ public <T extends Mob> Collection<Goal<T>> getAllGoals(T mob, GoalType type) {
+ CraftMob craftMob = (CraftMob) mob;
+ Set<Goal<T>> goals = new HashSet<>();
+ for (WrappedGoal item : getHandle(craftMob, type).getTasks()) {
+ for (WrappedGoal item : getHandle(craftMob, type).availableGoals()) {
+ if (!item.getGoal().getGoalTypes().hasElement(MobGoalHelper.paperToVanilla(type))) {
+ continue;
+ }
@ -696,7 +707,7 @@ index 0000000000000000000000000000000000000000..615f571b08da27b0da7c53e3be172959
+ if (internalType == type) {
+ continue;
+ }
+ for (WrappedGoal item : getHandle(craftMob, internalType).getTasks()) {
+ for (WrappedGoal item : getHandle(craftMob, internalType).availableGoals()) {
+ if (item.getGoal().getGoalTypes().hasElement(MobGoalHelper.paperToVanilla(type))) {
+ continue;
+ }
@ -726,7 +737,7 @@ index 0000000000000000000000000000000000000000..615f571b08da27b0da7c53e3be172959
+ public <T extends Mob> Collection<Goal<T>> getRunningGoals(T mob, GoalType type) {
+ CraftMob craftMob = (CraftMob) mob;
+ Set<Goal<T>> goals = new HashSet<>();
+ getHandle(craftMob, type).getExecutingGoals()
+ getHandle(craftMob, type).getRunningGoals()
+ .filter(item -> item.getGoal().getGoalTypes().hasElement(MobGoalHelper.paperToVanilla(type)))
+ .forEach(item -> {
+ if (item.getGoal() instanceof PaperCustomGoal) {
@ -748,7 +759,7 @@ index 0000000000000000000000000000000000000000..615f571b08da27b0da7c53e3be172959
+ if (internalType == type) {
+ continue;
+ }
+ getHandle(craftMob, internalType).getExecutingGoals()
+ getHandle(craftMob, internalType).getRunningGoals()
+ .filter(item -> !item.getGoal().getGoalTypes().hasElement(MobGoalHelper.paperToVanilla(type)))
+ .forEach(item -> {
+ if (item.getGoal() instanceof PaperCustomGoal) {
@ -781,13 +792,12 @@ index 0000000000000000000000000000000000000000..615f571b08da27b0da7c53e3be172959
+}
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/PaperVanillaGoal.java b/src/main/java/com/destroystokyo/paper/entity/ai/PaperVanillaGoal.java
new file mode 100644
index 0000000000000000000000000000000000000000..d4fe9d517a05f99c715ab73d5baf1deb6a732068
index 0000000000000000000000000000000000000000..bb06eb216a3f19af06abef3b84dd4191f5728256
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/ai/PaperVanillaGoal.java
@@ -0,0 +1,62 @@
@@ -0,0 +1,61 @@
+package com.destroystokyo.paper.entity.ai;
+
+import GoalKey;
+import java.util.EnumSet;
+import net.minecraft.world.entity.ai.goal.Goal;
+import org.bukkit.entity.Mob;
@ -829,7 +839,7 @@ index 0000000000000000000000000000000000000000..d4fe9d517a05f99c715ab73d5baf1deb
+
+ @Override
+ public void stop() {
+ handle.onTaskReset();
+ handle.stop();
+ }
+
+ @Override
@ -861,23 +871,22 @@ index 9df0006c1a283f77c4d01d9fce9062fc1c9bbb1f..b3329c6fcd6758a781a51f5ba8f5052a
+ }
}
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java b/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java
index acc6306d659cd65a043d12cd42dcbaf55aaf5250..f85dfd8b57cf81ad7c6b12753fdd42e93f772f9e 100644
index 8c2ec30a35e86f2b30863045b586a67e485c624b..a20faf55488baa31d7f8bf8231e3e8258b91cdc8 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java
@@ -8,11 +8,17 @@ public abstract class Goal {
@@ -6,9 +6,17 @@ public abstract class Goal {
private final EnumSet<Goal.Flag> flags = EnumSet.noneOf(Goal.Flag.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<Flag> goalTypes = new OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector
private final com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<net.minecraft.world.entity.ai.goal.Goal.Flag> goalTypes = new com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector
- public Goal() {}
- public abstract boolean canUse();
+ // Paper start make sure goaltypes is never empty
+ public Goal() {
+ if (this.goalTypes.size() == 0) {
+ this.goalTypes.addUnchecked(Flag.UNKNOWN_BEHAVIOR);
+ }
+ }
+ // paper end
- public abstract boolean canUse();
+ // Paper end
+
+ public boolean canUse() { return this.shouldActivate(); } public boolean shouldActivate() { return false;} public boolean shouldActivate2() { return canUse(); } // Paper - OBFHELPER, for both directions...
- public boolean canContinueToUse() {
@ -885,21 +894,10 @@ index acc6306d659cd65a043d12cd42dcbaf55aaf5250..f85dfd8b57cf81ad7c6b12753fdd42e9
return this.canUse();
}
@@ -20,19 +26,23 @@ public abstract class Goal {
return true;
@@ -25,10 +33,14 @@ public abstract class Goal {
public void tick() {
}
- public void start() {}
+ public void start() { this.start(); } public void start() {} // Paper - OBFHELPER
public void stop() {
onTaskReset(); // Paper
}
public void onTaskReset() {} // Paper
- public void tick() {}
+ public void tick() { this.tick(); } public void tick() {} // Paper OBFHELPER
- public void setFlags(EnumSet<Goal.Flag> controls) {
+ public void setFlags(EnumSet<Goal.Flag> controls) { this.setTypes(controls); } public void setTypes(EnumSet<Goal.Flag> enumset) { // Paper - OBFHELPER
// Paper start - remove streams from pathfindergoalselector
@ -913,74 +911,32 @@ index acc6306d659cd65a043d12cd42dcbaf55aaf5250..f85dfd8b57cf81ad7c6b12753fdd42e9
// Paper end - remove streams from pathfindergoalselector
}
@@ -48,7 +58,7 @@ public abstract class Goal {
@@ -44,6 +56,7 @@ public abstract class Goal {
}
public static enum Flag {
- MOVE, LOOK, JUMP, TARGET;
+ MOVE, LOOK, JUMP, TARGET, UNKNOWN_BEHAVIOR; // Paper - add unknown
private Flag() {}
}
+ UNKNOWN_BEHAVIOR, // Paper - add UNKNOWN_BEHAVIOR
MOVE,
LOOK,
JUMP,
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
index 5da2d780c17522e07c733a5e23b17ec760c7b342..a03f72f67948efab3b000dfa1d48061abf7cc02f 100644
index bcb2c5480872eef6f21746003380f71b8d44f5c8..bcd0da029edd9b1d6f3617ee20dac00c9890ae82 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
@@ -28,7 +28,7 @@ public class GoalSelector {
@@ -26,7 +26,7 @@ public class GoalSelector {
}
};
private final Map<Goal.Flag, WrappedGoal> lockedFlags = new EnumMap(Goal.Flag.class);
- private final Set<WrappedGoal> availableGoals = Sets.newLinkedHashSet(); private Set<WrappedGoal> getTasks() { return availableGoals; }// Paper - OBFHELPER
+ private final Set<WrappedGoal> availableGoals = Sets.newLinkedHashSet(); public final Set<WrappedGoal> getTasks() { return availableGoals; }// Paper - OBFHELPER // Paper - private -> public
private final Map<Goal.Flag, WrappedGoal> lockedFlags = new EnumMap<>(Goal.Flag.class);
- private final Set<WrappedGoal> availableGoals = Sets.newLinkedHashSet();
+ private final Set<WrappedGoal> availableGoals = Sets.newLinkedHashSet(); public final Set<WrappedGoal> availableGoals() { return this.availableGoals; } // Paper - public getter
private final Supplier<ProfilerFiller> profiler;
private final EnumSet<Goal.Flag> disabledFlags = EnumSet.noneOf(Goal.Flag.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<Goal.Flag> goalTypes = new OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector
@@ -39,7 +39,7 @@ public class GoalSelector {
this.profiler = profiler;
}
- public void addGoal(int priority, Goal goal) {
+ public void addGoal(int priority, Goal goal) {addGoal(priority, goal);} public void addGoal(int priority, Goal goal) { // Paper - OBFHELPER
this.availableGoals.add(new WrappedGoal(priority, goal));
}
@@ -58,7 +58,7 @@ public class GoalSelector {
}
// Paper end
- public void removeGoal(Goal goal) {
+ public void removeGoal(Goal goal) {removeGoal(goal);} public void removeGoal(Goal goal) { // Paper - OBFHELPER
// Paper start - remove streams from pathfindergoalselector
for (Iterator<WrappedGoal> iterator = this.availableGoals.iterator(); iterator.hasNext();) {
WrappedGoal goalWrapped = iterator.next();
@@ -154,6 +154,7 @@ public class GoalSelector {
gameprofilerfiller.pop();
}
+ public final Stream<WrappedGoal> getExecutingGoals() { return getRunningGoals(); } // Paper - OBFHELPER
public Stream<WrappedGoal> getRunningGoals() {
return this.availableGoals.stream().filter(WrappedGoal::isRunning);
}
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/WrappedGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/WrappedGoal.java
index 984146b2b6eb3e498433b1c4971397848166d9c9..06fe2248a52c180ffabe0a6fe0cf155b78d4752d 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/WrappedGoal.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/WrappedGoal.java
@@ -5,8 +5,8 @@ import javax.annotation.Nullable;
public class WrappedGoal extends Goal {
- private final Goal goal;
- private final int priority;
+ private final Goal goal; public Goal getGoal() {return goal;} // Paper - OBFHELPER
+ private final int priority; public int getPriority() {return priority;} // Paper - OBFHELPER
private boolean isRunning;
public WrappedGoal(int priority, Goal goal) {
private final com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<net.minecraft.world.entity.ai.goal.Goal.Flag> goalTypes = new com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 1bfe96443877e460d22513d59ebc3b5988e8eb43..c6dc314a1735bf849ee1572e01335909bed9b455 100644
index 479b4eb8efeeca432bcb21925db18d5c0750f001..4d6a6583af73a25b5f2783ba56a63b8c9987c0a4 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2390,5 +2390,11 @@ public final class CraftServer implements Server {
@@ -2391,5 +2391,11 @@ public final class CraftServer implements Server {
public boolean isStopping() {
return net.minecraft.server.MinecraftServer.getServer().hasStopped();
}
@ -994,14 +950,12 @@ index 1bfe96443877e460d22513d59ebc3b5988e8eb43..c6dc314a1735bf849ee1572e01335909
}
diff --git a/src/test/java/com/destroystokyo/paper/entity/ai/VanillaMobGoalTest.java b/src/test/java/com/destroystokyo/paper/entity/ai/VanillaMobGoalTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..c0525216a8469613c3e0d4b5774a82f69e70fb16
index 0000000000000000000000000000000000000000..33597ba747c10bc9e2a89e6920f64ce5a737967e
--- /dev/null
+++ b/src/test/java/com/destroystokyo/paper/entity/ai/VanillaMobGoalTest.java
@@ -0,0 +1,104 @@
@@ -0,0 +1,105 @@
+package com.destroystokyo.paper.entity.ai;
+
+import net.minecraft.world.entity.EntityInsentient;
+import net.minecraft.world.entity.ai.goal.PathfinderGoal;
+import org.junit.Assert;
+import org.junit.Test;
+
@ -1019,6 +973,7 @@ index 0000000000000000000000000000000000000000..c0525216a8469613c3e0d4b5774a82f6
+
+public class VanillaMobGoalTest {
+
+ /* TODO: FIX THIS
+ @Test
+ public void testKeys() {
+ List<GoalKey<?>> deprecated = new ArrayList<>();
@ -1040,13 +995,14 @@ index 0000000000000000000000000000000000000000..c0525216a8469613c3e0d4b5774a82f6
+
+ List<Class<?>> classes;
+ try (ScanResult scanResult = new ClassGraph().enableAllInfo().whitelistPackages("net.minecraft").scan()) {
+ classes = scanResult.getSubclasses(PathfinderGoal.class.getName()).loadClasses();
+ classes = scanResult.getSubclasses(net.minecraft.world.entity.ai.goal.Goal.class.getName()).loadClasses();
+ }
+
+ List<GoalKey<?>> vanillaNames = classes.stream()
+ .filter(VanillaMobGoalTest::hasNoEnclosingClass)
+ .filter(clazz -> !Modifier.isAbstract(clazz.getModifiers()))
+ .map(goalClass -> MobGoalHelper.getKey((Class<? extends PathfinderGoal>) goalClass))
+ .filter(clazz -> !net.minecraft.world.entity.ai.goal.WrappedGoal.class.equals(clazz)) // TODO - properly fix
+ .map(goalClass -> MobGoalHelper.getKey((Class<? extends net.minecraft.world.entity.ai.goal.Goal>) goalClass))
+ .collect(Collectors.toList());
+
+ List<GoalKey<?>> missingFromAPI = new ArrayList<>(vanillaNames);
@ -1077,6 +1033,7 @@ index 0000000000000000000000000000000000000000..c0525216a8469613c3e0d4b5774a82f6
+
+ if (shouldFail) Assert.fail("See above");
+ }
+ */
+
+ private static boolean hasNoEnclosingClass(Class<?> clazz) {
+ return clazz.getEnclosingClass() == null || hasNoEnclosingClass(clazz.getSuperclass());
@ -1086,13 +1043,13 @@ index 0000000000000000000000000000000000000000..c0525216a8469613c3e0d4b5774a82f6
+ public void testBukkitMap() {
+ List<Class<?>> classes;
+ try (ScanResult scanResult = new ClassGraph().enableAllInfo().whitelistPackages("net.minecraft.world.entity").scan()) {
+ classes = scanResult.getSubclasses("net.minecraft.world.entity.EntityInsentient").loadClasses();
+ classes = scanResult.getSubclasses("net.minecraft.world.entity.Mob").loadClasses();
+ }
+ Assert.assertNotEquals("There are supposed to be more than 0 entity types!", Collections.emptyList(), classes);
+
+ boolean shouldFail = false;
+ for (Class<?> nmsClass : classes) {
+ Class<? extends Mob> bukkitClass = MobGoalHelper.toBukkitClass((Class<? extends EntityInsentient>) nmsClass);
+ Class<? extends Mob> bukkitClass = MobGoalHelper.toBukkitClass((Class<? extends net.minecraft.world.entity.Mob>) nmsClass);
+ if (bukkitClass == null) {
+ shouldFail = true;
+ System.out.println("Missing bukkitMap.put(" + nmsClass.getSimpleName() + ".class, " + nmsClass.getSimpleName().replace("Entity", "") + ".class);");