diff --git a/build-data/reobf-mappings-patch.tiny b/build-data/reobf-mappings-patch.tiny index 53640748fc..355733ef7e 100644 --- a/build-data/reobf-mappings-patch.tiny +++ b/build-data/reobf-mappings-patch.tiny @@ -48,3 +48,7 @@ c net/minecraft/world/level/Level net/minecraft/world/level/World # Paper changes type c net/minecraft/core/MappedRegistry net/minecraft/core/RegistryMaterials f Lit/unimi/dsi/fastutil/objects/Reference2IntOpenHashMap; toId bw + +# Remove streams from Mob AI System changes type from EnumSet to com.destroystokyo.paper.util.set.OptimizedSmallEnumSet +c net/minecraft/world/entity/ai/goal/Goal net/minecraft/world/entity/ai/goal/PathfinderGoal + m ()Lcom/destroystokyo/paper/util/set/OptimizedSmallEnumSet; getFlags i diff --git a/patches/server/0400-Remove-streams-from-Mob-AI-System.patch b/patches/server/0400-Remove-streams-from-Mob-AI-System.patch index ea45515dbf..f546485714 100644 --- a/patches/server/0400-Remove-streams-from-Mob-AI-System.patch +++ b/patches/server/0400-Remove-streams-from-Mob-AI-System.patch @@ -10,7 +10,7 @@ Also optimise the stream.anyMatch statement to move to a bitset where we can replace the call with a single bitwise operation. 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 d92ddc8a4c0f5249b7ff4f97af1ea3db413b2983..8c2ec30a35e86f2b30863045b586a67e485c624b 100644 +index d92ddc8a4c0f5249b7ff4f97af1ea3db413b2983..fabd20265863751ad980ee4a697f3f0d47df101f 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 @@ -3,7 +3,8 @@ package net.minecraft.world.entity.ai.goal; @@ -43,14 +43,14 @@ index d92ddc8a4c0f5249b7ff4f97af1ea3db413b2983..8c2ec30a35e86f2b30863045b586a67e - public EnumSet getFlags() { - return this.flags; + // Paper start - remove streams from pathfindergoalselector -+ public com.destroystokyo.paper.util.set.OptimizedSmallEnumSet getGoalTypes() { ++ public com.destroystokyo.paper.util.set.OptimizedSmallEnumSet getFlags() { + return this.goalTypes; + // Paper end - remove streams from pathfindergoalselector } public static enum Flag { 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 69bf112655615337e0df3ea56b9e42fa5ff70430..f779f202985d34cb7e379b0f3d5690dd20f091ba 100644 +index 69bf112655615337e0df3ea56b9e42fa5ff70430..a96831d5df2b88203aec8fe2a5909708764b38ee 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,10 +28,12 @@ public class GoalSelector { @@ -105,7 +105,7 @@ index 69bf112655615337e0df3ea56b9e42fa5ff70430..f779f202985d34cb7e379b0f3d5690dd - this.lockedFlags.remove(flag); + continue; + } -+ if (!this.goalTypes.hasCommonElements(wrappedGoal.getGoalTypes()) && wrappedGoal.canContinueToUse()) { ++ if (!this.goalTypes.hasCommonElements(wrappedGoal.getFlags()) && wrappedGoal.canContinueToUse()) { + continue; + } + wrappedGoal.stop(); @@ -141,7 +141,7 @@ index 69bf112655615337e0df3ea56b9e42fa5ff70430..f779f202985d34cb7e379b0f3d5690dd + continue; + } + -+ com.destroystokyo.paper.util.set.OptimizedSmallEnumSet wrappedGoalSet = wrappedGoal.getGoalTypes(); ++ com.destroystokyo.paper.util.set.OptimizedSmallEnumSet wrappedGoalSet = wrappedGoal.getFlags(); + + if (this.goalTypes.hasCommonElements(wrappedGoalSet)) { + continue; @@ -205,7 +205,7 @@ index 69bf112655615337e0df3ea56b9e42fa5ff70430..f779f202985d34cb7e379b0f3d5690dd public void setControlFlag(Goal.Flag control, boolean enabled) { 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 1e915b999f4261fb27846a0e559ea22e4b09b4db..037cc5d2b41161e040fc9b264a0dd04827c29681 100644 +index 1e915b999f4261fb27846a0e559ea22e4b09b4db..eb3492962e58cad8f2927e53a0d3518d1b06bdf9 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 @@ -58,9 +58,10 @@ public class WrappedGoal extends Goal { @@ -214,10 +214,9 @@ index 1e915b999f4261fb27846a0e559ea22e4b09b4db..037cc5d2b41161e040fc9b264a0dd048 - @Override - public EnumSet getFlags() { -- return this.goal.getFlags(); + // Paper start - remove streams from pathfindergoalselector -+ public com.destroystokyo.paper.util.set.OptimizedSmallEnumSet getGoalTypes() { -+ return this.goal.getGoalTypes(); ++ public com.destroystokyo.paper.util.set.OptimizedSmallEnumSet getFlags() { + return this.goal.getFlags(); + // Paper end - remove streams from pathfindergoalselector } diff --git a/patches/server/0430-Implement-Mob-Goal-API.patch b/patches/server/0430-Implement-Mob-Goal-API.patch index c9d193f050..45dd7b6475 100644 --- a/patches/server/0430-Implement-Mob-Goal-API.patch +++ b/patches/server/0430-Implement-Mob-Goal-API.patch @@ -391,14 +391,13 @@ index 0000000000000000000000000000000000000000..181abe014baba9ac51064c003381281a +} 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..ddf1a34ef6aba584d30a5419a5109ad66385975c +index 0000000000000000000000000000000000000000..26c745dd9ccdfdd5c5039f2acc5201b9b91fb274 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/entity/ai/PaperCustomGoal.java -@@ -0,0 +1,54 @@ +@@ -0,0 +1,53 @@ +package com.destroystokyo.paper.entity.ai; + +import org.bukkit.entity.Mob; -+import com.destroystokyo.paper.entity.ai.Goal; + +/** + * Wraps api in vanilla @@ -411,8 +410,8 @@ index 0000000000000000000000000000000000000000..ddf1a34ef6aba584d30a5419a5109ad6 + this.handle = handle; + + this.setFlags(MobGoalHelper.paperToVanilla(handle.getTypes())); -+ if (this.getGoalTypes().size() == 0) { -+ this.getGoalTypes().addUnchecked(Flag.UNKNOWN_BEHAVIOR); ++ if (this.getFlags().size() == 0) { ++ this.getFlags().addUnchecked(Flag.UNKNOWN_BEHAVIOR); + } + } + @@ -451,7 +450,7 @@ index 0000000000000000000000000000000000000000..ddf1a34ef6aba584d30a5419a5109ad6 +} 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..52c86ed3abd411daf406aaab1dba409889d6c3e2 +index 0000000000000000000000000000000000000000..336cc3c3b43bacf4f3661fa0bb0736b273f65418 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java @@ -0,0 +1,213 @@ @@ -566,7 +565,7 @@ index 0000000000000000000000000000000000000000..52c86ed3abd411daf406aaab1dba4098 + CraftMob craftMob = (CraftMob) mob; + Set> goals = new HashSet<>(); + for (WrappedGoal item : getHandle(craftMob, type).availableGoals) { -+ if (!item.getGoal().getGoalTypes().hasElement(MobGoalHelper.paperToVanilla(type))) { ++ if (!item.getGoal().getFlags().hasElement(MobGoalHelper.paperToVanilla(type))) { + continue; + } + @@ -589,7 +588,7 @@ index 0000000000000000000000000000000000000000..52c86ed3abd411daf406aaab1dba4098 + continue; + } + for (WrappedGoal item : getHandle(craftMob, internalType).availableGoals) { -+ if (item.getGoal().getGoalTypes().hasElement(MobGoalHelper.paperToVanilla(type))) { ++ if (item.getGoal().getFlags().hasElement(MobGoalHelper.paperToVanilla(type))) { + continue; + } + @@ -618,7 +617,7 @@ index 0000000000000000000000000000000000000000..52c86ed3abd411daf406aaab1dba4098 + CraftMob craftMob = (CraftMob) mob; + Set> goals = new HashSet<>(); + getHandle(craftMob, type).getRunningGoals() -+ .filter(item -> item.getGoal().getGoalTypes().hasElement(MobGoalHelper.paperToVanilla(type))) ++ .filter(item -> item.getGoal().getFlags().hasElement(MobGoalHelper.paperToVanilla(type))) + .forEach(item -> { + if (item.getGoal() instanceof PaperCustomGoal) { + //noinspection unchecked @@ -639,7 +638,7 @@ index 0000000000000000000000000000000000000000..52c86ed3abd411daf406aaab1dba4098 + continue; + } + getHandle(craftMob, internalType).getRunningGoals() -+ .filter(item -> !item.getGoal().getGoalTypes().hasElement(MobGoalHelper.paperToVanilla(type))) ++ .filter(item -> !item.getGoal().getFlags().hasElement(MobGoalHelper.paperToVanilla(type))) + .forEach(item -> { + if (item.getGoal() instanceof PaperCustomGoal) { + //noinspection unchecked @@ -670,7 +669,7 @@ index 0000000000000000000000000000000000000000..52c86ed3abd411daf406aaab1dba4098 +} 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..6ab8ecb56d2ea885782a03d2ba3adbd9e3fd5642 +index 0000000000000000000000000000000000000000..0d30e0b21b9024df939a9d070bd4a99b217e7c12 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/entity/ai/PaperVanillaGoal.java @@ -0,0 +1,61 @@ @@ -693,7 +692,7 @@ index 0000000000000000000000000000000000000000..6ab8ecb56d2ea885782a03d2ba3adbd9 + public PaperVanillaGoal(Goal handle) { + this.handle = handle; + this.key = MobGoalHelper.getKey(handle.getClass()); -+ this.types = MobGoalHelper.vanillaToPaper(handle.getGoalTypes()); ++ this.types = MobGoalHelper.vanillaToPaper(handle.getFlags()); + } + + public Goal getHandle() { @@ -749,7 +748,7 @@ 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 8c2ec30a35e86f2b30863045b586a67e485c624b..848cac4426346b6d2ed575f33bf01c0e122acaa2 100644 +index fabd20265863751ad980ee4a697f3f0d47df101f..3a4da2bb86a742985d309eb325dc843ae405cd8b 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 @@ -6,6 +6,14 @@ public abstract class Goal {