3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00

Remove method rename and fix reobf for Goal#getFlags (#6528)

Dieser Commit ist enthalten in:
Jason 2021-09-09 12:12:22 -05:00 committet von GitHub
Ursprung 1b383d7e9b
Commit 8a2b23a6a4
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 24 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -48,3 +48,7 @@ c net/minecraft/world/level/Level net/minecraft/world/level/World
# Paper changes type # Paper changes type
c net/minecraft/core/MappedRegistry net/minecraft/core/RegistryMaterials c net/minecraft/core/MappedRegistry net/minecraft/core/RegistryMaterials
f Lit/unimi/dsi/fastutil/objects/Reference2IntOpenHashMap; toId bw 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

Datei anzeigen

@ -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. 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 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 --- a/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java
+++ b/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; @@ -3,7 +3,8 @@ package net.minecraft.world.entity.ai.goal;
@ -43,14 +43,14 @@ index d92ddc8a4c0f5249b7ff4f97af1ea3db413b2983..8c2ec30a35e86f2b30863045b586a67e
- public EnumSet<Goal.Flag> getFlags() { - public EnumSet<Goal.Flag> getFlags() {
- return this.flags; - return this.flags;
+ // Paper start - remove streams from pathfindergoalselector + // Paper start - remove streams from pathfindergoalselector
+ public com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<Goal.Flag> getGoalTypes() { + public com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<Goal.Flag> getFlags() {
+ return this.goalTypes; + return this.goalTypes;
+ // Paper end - remove streams from pathfindergoalselector + // Paper end - remove streams from pathfindergoalselector
} }
public static enum Flag { 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 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 --- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
+++ b/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 { @@ -28,10 +28,12 @@ public class GoalSelector {
@ -105,7 +105,7 @@ index 69bf112655615337e0df3ea56b9e42fa5ff70430..f779f202985d34cb7e379b0f3d5690dd
- this.lockedFlags.remove(flag); - this.lockedFlags.remove(flag);
+ continue; + continue;
+ } + }
+ if (!this.goalTypes.hasCommonElements(wrappedGoal.getGoalTypes()) && wrappedGoal.canContinueToUse()) { + if (!this.goalTypes.hasCommonElements(wrappedGoal.getFlags()) && wrappedGoal.canContinueToUse()) {
+ continue; + continue;
+ } + }
+ wrappedGoal.stop(); + wrappedGoal.stop();
@ -141,7 +141,7 @@ index 69bf112655615337e0df3ea56b9e42fa5ff70430..f779f202985d34cb7e379b0f3d5690dd
+ continue; + continue;
+ } + }
+ +
+ com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<net.minecraft.world.entity.ai.goal.Goal.Flag> wrappedGoalSet = wrappedGoal.getGoalTypes(); + com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<net.minecraft.world.entity.ai.goal.Goal.Flag> wrappedGoalSet = wrappedGoal.getFlags();
+ +
+ if (this.goalTypes.hasCommonElements(wrappedGoalSet)) { + if (this.goalTypes.hasCommonElements(wrappedGoalSet)) {
+ continue; + continue;
@ -205,7 +205,7 @@ index 69bf112655615337e0df3ea56b9e42fa5ff70430..f779f202985d34cb7e379b0f3d5690dd
public void setControlFlag(Goal.Flag control, boolean enabled) { 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 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 --- a/src/main/java/net/minecraft/world/entity/ai/goal/WrappedGoal.java
+++ b/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 { @@ -58,9 +58,10 @@ public class WrappedGoal extends Goal {
@ -214,10 +214,9 @@ index 1e915b999f4261fb27846a0e559ea22e4b09b4db..037cc5d2b41161e040fc9b264a0dd048
- @Override - @Override
- public EnumSet<Goal.Flag> getFlags() { - public EnumSet<Goal.Flag> getFlags() {
- return this.goal.getFlags();
+ // Paper start - remove streams from pathfindergoalselector + // Paper start - remove streams from pathfindergoalselector
+ public com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<Goal.Flag> getGoalTypes() { + public com.destroystokyo.paper.util.set.OptimizedSmallEnumSet<Goal.Flag> getFlags() {
+ return this.goal.getGoalTypes(); return this.goal.getFlags();
+ // Paper end - remove streams from pathfindergoalselector + // Paper end - remove streams from pathfindergoalselector
} }

Datei anzeigen

@ -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 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 new file mode 100644
index 0000000000000000000000000000000000000000..ddf1a34ef6aba584d30a5419a5109ad66385975c index 0000000000000000000000000000000000000000..26c745dd9ccdfdd5c5039f2acc5201b9b91fb274
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/ai/PaperCustomGoal.java +++ 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; +package com.destroystokyo.paper.entity.ai;
+ +
+import org.bukkit.entity.Mob; +import org.bukkit.entity.Mob;
+import com.destroystokyo.paper.entity.ai.Goal;
+ +
+/** +/**
+ * Wraps api in vanilla + * Wraps api in vanilla
@ -411,8 +410,8 @@ index 0000000000000000000000000000000000000000..ddf1a34ef6aba584d30a5419a5109ad6
+ this.handle = handle; + this.handle = handle;
+ +
+ this.setFlags(MobGoalHelper.paperToVanilla(handle.getTypes())); + this.setFlags(MobGoalHelper.paperToVanilla(handle.getTypes()));
+ if (this.getGoalTypes().size() == 0) { + if (this.getFlags().size() == 0) {
+ this.getGoalTypes().addUnchecked(Flag.UNKNOWN_BEHAVIOR); + 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 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 new file mode 100644
index 0000000000000000000000000000000000000000..52c86ed3abd411daf406aaab1dba409889d6c3e2 index 0000000000000000000000000000000000000000..336cc3c3b43bacf4f3661fa0bb0736b273f65418
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java +++ b/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java
@@ -0,0 +1,213 @@ @@ -0,0 +1,213 @@
@ -566,7 +565,7 @@ index 0000000000000000000000000000000000000000..52c86ed3abd411daf406aaab1dba4098
+ CraftMob craftMob = (CraftMob) mob; + CraftMob craftMob = (CraftMob) mob;
+ Set<Goal<T>> goals = new HashSet<>(); + Set<Goal<T>> goals = new HashSet<>();
+ for (WrappedGoal item : getHandle(craftMob, type).availableGoals) { + for (WrappedGoal item : getHandle(craftMob, type).availableGoals) {
+ if (!item.getGoal().getGoalTypes().hasElement(MobGoalHelper.paperToVanilla(type))) { + if (!item.getGoal().getFlags().hasElement(MobGoalHelper.paperToVanilla(type))) {
+ continue; + continue;
+ } + }
+ +
@ -589,7 +588,7 @@ index 0000000000000000000000000000000000000000..52c86ed3abd411daf406aaab1dba4098
+ continue; + continue;
+ } + }
+ for (WrappedGoal item : getHandle(craftMob, internalType).availableGoals) { + for (WrappedGoal item : getHandle(craftMob, internalType).availableGoals) {
+ if (item.getGoal().getGoalTypes().hasElement(MobGoalHelper.paperToVanilla(type))) { + if (item.getGoal().getFlags().hasElement(MobGoalHelper.paperToVanilla(type))) {
+ continue; + continue;
+ } + }
+ +
@ -618,7 +617,7 @@ index 0000000000000000000000000000000000000000..52c86ed3abd411daf406aaab1dba4098
+ CraftMob craftMob = (CraftMob) mob; + CraftMob craftMob = (CraftMob) mob;
+ Set<Goal<T>> goals = new HashSet<>(); + Set<Goal<T>> goals = new HashSet<>();
+ getHandle(craftMob, type).getRunningGoals() + getHandle(craftMob, type).getRunningGoals()
+ .filter(item -> item.getGoal().getGoalTypes().hasElement(MobGoalHelper.paperToVanilla(type))) + .filter(item -> item.getGoal().getFlags().hasElement(MobGoalHelper.paperToVanilla(type)))
+ .forEach(item -> { + .forEach(item -> {
+ if (item.getGoal() instanceof PaperCustomGoal) { + if (item.getGoal() instanceof PaperCustomGoal) {
+ //noinspection unchecked + //noinspection unchecked
@ -639,7 +638,7 @@ index 0000000000000000000000000000000000000000..52c86ed3abd411daf406aaab1dba4098
+ continue; + continue;
+ } + }
+ getHandle(craftMob, internalType).getRunningGoals() + getHandle(craftMob, internalType).getRunningGoals()
+ .filter(item -> !item.getGoal().getGoalTypes().hasElement(MobGoalHelper.paperToVanilla(type))) + .filter(item -> !item.getGoal().getFlags().hasElement(MobGoalHelper.paperToVanilla(type)))
+ .forEach(item -> { + .forEach(item -> {
+ if (item.getGoal() instanceof PaperCustomGoal) { + if (item.getGoal() instanceof PaperCustomGoal) {
+ //noinspection unchecked + //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 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 new file mode 100644
index 0000000000000000000000000000000000000000..6ab8ecb56d2ea885782a03d2ba3adbd9e3fd5642 index 0000000000000000000000000000000000000000..0d30e0b21b9024df939a9d070bd4a99b217e7c12
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/ai/PaperVanillaGoal.java +++ b/src/main/java/com/destroystokyo/paper/entity/ai/PaperVanillaGoal.java
@@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
@ -693,7 +692,7 @@ index 0000000000000000000000000000000000000000..6ab8ecb56d2ea885782a03d2ba3adbd9
+ public PaperVanillaGoal(Goal handle) { + public PaperVanillaGoal(Goal handle) {
+ this.handle = handle; + this.handle = handle;
+ this.key = MobGoalHelper.getKey(handle.getClass()); + this.key = MobGoalHelper.getKey(handle.getClass());
+ this.types = MobGoalHelper.vanillaToPaper(handle.getGoalTypes()); + this.types = MobGoalHelper.vanillaToPaper(handle.getFlags());
+ } + }
+ +
+ public Goal getHandle() { + 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 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 --- a/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java
+++ b/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 { @@ -6,6 +6,14 @@ public abstract class Goal {