geforkt von Mirrors/Paper
re-inline Goal.Flag iteration
Dieser Commit ist enthalten in:
Ursprung
aa8a9905a9
Commit
82eff9628d
@ -734,21 +734,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ return types;
|
+ return types;
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/util/set/OptimizedSmallEnumSet.java b/src/main/java/com/destroystokyo/paper/util/set/OptimizedSmallEnumSet.java
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/com/destroystokyo/paper/util/set/OptimizedSmallEnumSet.java
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/util/set/OptimizedSmallEnumSet.java
|
|
||||||
@@ -0,0 +0,0 @@ public final class OptimizedSmallEnumSet<E extends Enum<E>> {
|
|
||||||
return (other.backingSet & this.backingSet) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ public boolean hasElement(final E element) {
|
|
||||||
+ return (this.backingSet & (1L << element.ordinal())) != 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
public void forEach(final E[] values, final Consumer<E> action) {
|
|
||||||
long iterator = this.getBackingSet();
|
|
||||||
int wrappedGoalSize = this.size();
|
|
||||||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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
|
||||||
|
@ -1957,8 +1957,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+package com.destroystokyo.paper.util.set;
|
+package com.destroystokyo.paper.util.set;
|
||||||
+
|
+
|
||||||
+import java.util.Collection;
|
+import java.util.Collection;
|
||||||
+import java.util.function.Consumer;
|
|
||||||
+import java.util.function.Predicate;
|
|
||||||
+
|
+
|
||||||
+/**
|
+/**
|
||||||
+ * @author Spottedleaf <Spottedleaf@users.noreply.github.com>
|
+ * @author Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||||
@ -2023,27 +2021,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ return (other.backingSet & this.backingSet) != 0;
|
+ return (other.backingSet & this.backingSet) != 0;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public void forEach(final E[] values, final Consumer<E> action) {
|
+ public boolean hasElement(final E element) {
|
||||||
+ long iterator = this.getBackingSet();
|
+ return (this.backingSet & (1L << element.ordinal())) != 0;
|
||||||
+ int wrappedGoalSize = this.size();
|
|
||||||
+ for (int i = 0; i < wrappedGoalSize; ++i) {
|
|
||||||
+ final E type = values[Long.numberOfTrailingZeros(iterator)];
|
|
||||||
+ iterator ^= io.papermc.paper.util.IntegerUtil.getTrailingBit(iterator);
|
|
||||||
+ action.accept(type);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public boolean anyMatch(final E[] values, final Predicate<E> predicate) {
|
|
||||||
+ long iterator = this.getBackingSet();
|
|
||||||
+ int wrappedGoalSize = this.size();
|
|
||||||
+ for (int i = 0; i < wrappedGoalSize; ++i) {
|
|
||||||
+ final E type = values[Long.numberOfTrailingZeros(iterator)];
|
|
||||||
+ iterator ^= io.papermc.paper.util.IntegerUtil.getTrailingBit(iterator);
|
|
||||||
+ if (predicate.test(type)) {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ return false;
|
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/chunk/SingleThreadChunkRegionManager.java b/src/main/java/io/papermc/paper/chunk/SingleThreadChunkRegionManager.java
|
diff --git a/src/main/java/io/papermc/paper/chunk/SingleThreadChunkRegionManager.java b/src/main/java/io/papermc/paper/chunk/SingleThreadChunkRegionManager.java
|
||||||
|
@ -85,10 +85,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ WrappedGoal goalWrapped = iterator.next();
|
+ WrappedGoal goalWrapped = iterator.next();
|
||||||
+ if (goalWrapped.getGoal() != goal) {
|
+ if (goalWrapped.getGoal() != goal) {
|
||||||
+ continue;
|
+ continue;
|
||||||
+ }
|
}
|
||||||
+ if (goalWrapped.isRunning()) {
|
+ if (goalWrapped.isRunning()) {
|
||||||
+ goalWrapped.stop();
|
+ goalWrapped.stop();
|
||||||
}
|
+ }
|
||||||
+ iterator.remove();
|
+ iterator.remove();
|
||||||
}
|
}
|
||||||
+ // Paper end - remove streams from pathfindergoalselector
|
+ // Paper end - remove streams from pathfindergoalselector
|
||||||
@ -102,20 +102,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
private static boolean goalCanBeReplacedForAllFlags(WrappedGoal goal, Map<Goal.Flag, WrappedGoal> goalsByControl) {
|
private static boolean goalCanBeReplacedForAllFlags(WrappedGoal goal, Map<Goal.Flag, WrappedGoal> goalsByControl) {
|
||||||
- for(Goal.Flag flag : goal.getFlags()) {
|
- for(Goal.Flag flag : goal.getFlags()) {
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ return !goal.getFlags().anyMatch(GOAL_FLAG_VALUES, flag -> {
|
+ long flagIterator = goal.getFlags().getBackingSet();
|
||||||
|
+ int wrappedGoalSize = goal.getFlags().size();
|
||||||
|
+ for (int i = 0; i < wrappedGoalSize; ++i) {
|
||||||
|
+ final Goal.Flag flag = GOAL_FLAG_VALUES[Long.numberOfTrailingZeros(flagIterator)];
|
||||||
|
+ flagIterator ^= io.papermc.paper.util.IntegerUtil.getTrailingBit(flagIterator);
|
||||||
|
+ // Paper end
|
||||||
if (!goalsByControl.getOrDefault(flag, NO_GOAL).canBeReplacedBy(goal)) {
|
if (!goalsByControl.getOrDefault(flag, NO_GOAL).canBeReplacedBy(goal)) {
|
||||||
- return false;
|
return false;
|
||||||
+ return true;
|
|
||||||
}
|
}
|
||||||
- }
|
|
||||||
-
|
|
||||||
- return true;
|
|
||||||
+ return false;
|
|
||||||
+ });
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
||||||
|
|
||||||
public void tick() {
|
|
||||||
@@ -0,0 +0,0 @@ public class GoalSelector {
|
@@ -0,0 +0,0 @@ public class GoalSelector {
|
||||||
profilerFiller.push("goalCleanup");
|
profilerFiller.push("goalCleanup");
|
||||||
|
|
||||||
@ -133,16 +128,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
- for(Goal.Flag flag : wrappedGoal2.getFlags()) {
|
- for(Goal.Flag flag : wrappedGoal2.getFlags()) {
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ if (!wrappedGoal2.isRunning() && !goalContainsAnyFlags(wrappedGoal2, this.goalTypes) && goalCanBeReplacedForAllFlags(wrappedGoal2, this.lockedFlags) && wrappedGoal2.canUse()) {
|
+ if (!wrappedGoal2.isRunning() && !goalContainsAnyFlags(wrappedGoal2, this.goalTypes) && goalCanBeReplacedForAllFlags(wrappedGoal2, this.lockedFlags) && wrappedGoal2.canUse()) {
|
||||||
+ wrappedGoal2.getFlags().forEach(GOAL_FLAG_VALUES, flag -> {
|
+ long flagIterator = wrappedGoal2.getFlags().getBackingSet();
|
||||||
|
+ int wrappedGoalSize = wrappedGoal2.getFlags().size();
|
||||||
|
+ for (int i = 0; i < wrappedGoalSize; ++i) {
|
||||||
|
+ final Goal.Flag flag = GOAL_FLAG_VALUES[Long.numberOfTrailingZeros(flagIterator)];
|
||||||
|
+ flagIterator ^= io.papermc.paper.util.IntegerUtil.getTrailingBit(flagIterator);
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
WrappedGoal wrappedGoal3 = this.lockedFlags.getOrDefault(flag, NO_GOAL);
|
WrappedGoal wrappedGoal3 = this.lockedFlags.getOrDefault(flag, NO_GOAL);
|
||||||
wrappedGoal3.stop();
|
wrappedGoal3.stop();
|
||||||
this.lockedFlags.put(flag, wrappedGoal2);
|
this.lockedFlags.put(flag, wrappedGoal2);
|
||||||
- }
|
|
||||||
+ }); // Paper
|
|
||||||
|
|
||||||
wrappedGoal2.start();
|
|
||||||
}
|
|
||||||
@@ -0,0 +0,0 @@ public class GoalSelector {
|
@@ -0,0 +0,0 @@ public class GoalSelector {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren