-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use lazy lookups + don't use hashmap
- Loading branch information
Showing
19 changed files
with
351 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 30 additions & 30 deletions
60
paper-server/patches/features/0017-Moonrise-optimisation-patches.patch
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
paper-server/patches/sources/io/papermc/paper/entity/goal/TemptGoalLookup.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- /dev/null | ||
+++ b/io/papermc/paper/entity/goal/TemptGoalLookup.java | ||
@@ -1,0 +_,64 @@ | ||
+package io.papermc.paper.entity.goal; | ||
+ | ||
+import java.util.ArrayList; | ||
+import java.util.BitSet; | ||
+import java.util.List; | ||
+import java.util.function.Predicate; | ||
+ | ||
+import net.minecraft.tags.ItemTags; | ||
+import net.minecraft.world.item.ItemStack; | ||
+import net.minecraft.world.item.Items; | ||
+ | ||
+public class TemptGoalLookup { | ||
+ public static final TemptGoalPredicate BEE_TEMPT = register(stack -> stack.is(ItemTags.BEE_FOOD)); | ||
+ public static final TemptGoalPredicate CHICKEN_TEMPT = register(stack -> stack.is(ItemTags.CHICKEN_FOOD)); | ||
+ public static final TemptGoalPredicate COW_TEMPT = register(stack -> stack.is(ItemTags.COW_FOOD)); | ||
+ public static final TemptGoalPredicate PANDA_TEMPT = register(stack -> stack.is(ItemTags.PANDA_FOOD)); | ||
+ public static final TemptGoalPredicate PIG_TEMPT_STICK = register(stack -> stack.is(Items.CARROT_ON_A_STICK)); | ||
+ public static final TemptGoalPredicate PIG_TEMPT = register(stack -> stack.is(ItemTags.PIG_FOOD)); | ||
+ public static final TemptGoalPredicate RABBIT_TEMPT = register(stack -> stack.is(ItemTags.RABBIT_FOOD)); | ||
+ public static final TemptGoalPredicate SHEEP_TEMPT = register(stack -> stack.is(ItemTags.SHEEP_FOOD)); | ||
+ public static final TemptGoalPredicate TURTLE_TEMPT = register(stack -> stack.is(ItemTags.TURTLE_FOOD)); | ||
+ public static final TemptGoalPredicate HORSE_TEMPT = register(stack -> stack.is(ItemTags.HORSE_TEMPT_ITEMS)); | ||
+ public static final TemptGoalPredicate LLAMA_TEMPT = register(stack -> stack.is(ItemTags.LLAMA_TEMPT_ITEMS)); | ||
+ public static final TemptGoalPredicate STRIDER_TEMPT = register(stack -> stack.is(ItemTags.STRIDER_TEMPT_ITEMS)); | ||
+ | ||
+ public static final List<TemptGoalPredicate> REGISTERED_PREDICATES = new ArrayList<>(); | ||
+ | ||
+ public record TemptGoalPredicate(int index, Predicate<ItemStack> predicate) { | ||
+ } | ||
+ | ||
+ private static TemptGoalPredicate register(final Predicate<ItemStack> predicate) { | ||
+ final TemptGoalPredicate val = new TemptGoalPredicate(REGISTERED_PREDICATES.size(), predicate); | ||
+ REGISTERED_PREDICATES.add(val); | ||
+ return val; | ||
+ } | ||
+ | ||
+ private final List<BitSet> precalculatedTemptItems = new ArrayList<>(); | ||
+ private final BitSet calculatedThisTick = new java.util.BitSet(); | ||
+ | ||
+ { | ||
+ for (int i = 0; i < REGISTERED_PREDICATES.size(); i++) { | ||
+ this.precalculatedTemptItems.add(new BitSet()); | ||
+ } | ||
+ } | ||
+ | ||
+ public void reset() { | ||
+ for (int i = 0; i < REGISTERED_PREDICATES.size(); i++) { | ||
+ this.precalculatedTemptItems.get(i).clear(); | ||
+ } | ||
+ this.calculatedThisTick.clear(); | ||
+ } | ||
+ | ||
+ public boolean isCalculated(int index) { | ||
+ return this.calculatedThisTick.get(index); | ||
+ } | ||
+ | ||
+ public void setCalculated(int index) { | ||
+ this.calculatedThisTick.set(index); | ||
+ } | ||
+ | ||
+ public BitSet getBitSet(int index) { | ||
+ return this.precalculatedTemptItems.get(index); | ||
+ } | ||
+} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.