mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-22 08:29:28 +00:00
Fix cloud compat
This commit is contained in:
@@ -5,7 +5,7 @@ Subject: [PATCH] Cache function execution result
|
||||
|
||||
|
||||
diff --git a/net/minecraft/commands/arguments/EntityArgument.java b/net/minecraft/commands/arguments/EntityArgument.java
|
||||
index 8f6a1788b5ca396b79a638955fc6a6b3a276337f..595539574b4a71e0e9f8209569700cf0c7df8197 100644
|
||||
index 8f6a1788b5ca396b79a638955fc6a6b3a276337f..4acf68e42a9644612608c8521020a989cbdea4a9 100644
|
||||
--- a/net/minecraft/commands/arguments/EntityArgument.java
|
||||
+++ b/net/minecraft/commands/arguments/EntityArgument.java
|
||||
@@ -65,6 +65,37 @@ public class EntityArgument implements ArgumentType<EntitySelector> {
|
||||
@@ -13,7 +13,7 @@ index 8f6a1788b5ca396b79a638955fc6a6b3a276337f..595539574b4a71e0e9f8209569700cf0
|
||||
}
|
||||
|
||||
+ // Leaf start - Cache function getEntity calls
|
||||
+ public static final java.util.Map<String, List<? extends Entity>> TICK_ENTITY_CACHE = new java.util.concurrent.ConcurrentHashMap<>();
|
||||
+ public static final java.util.Map<String, Collection<? extends Entity>> TICK_ENTITY_CACHE = new java.util.concurrent.ConcurrentHashMap<>();
|
||||
+ public static Collection<? extends Entity> getOptionalEntitiesCachedAs(CommandContext<CommandSourceStack> context, String name) throws CommandSyntaxException {
|
||||
+ if (!(context.getSource().source instanceof net.minecraft.server.MinecraftServer)) return getOptionalEntities(context, name);
|
||||
+ EntitySelector selector = context.getArgument(name, EntitySelector.class);
|
||||
@@ -21,7 +21,7 @@ index 8f6a1788b5ca396b79a638955fc6a6b3a276337f..595539574b4a71e0e9f8209569700cf0
|
||||
+ int idxStart = nodes.get(1).getRange().getStart();
|
||||
+ int idxEnd = nodes.get(2).getRange().getEnd();
|
||||
+ String selectorString = context.getInput().substring(idxStart, idxEnd);
|
||||
+ List<? extends Entity> entities = TICK_ENTITY_CACHE.get(selectorString);
|
||||
+ Collection<? extends Entity> entities = TICK_ENTITY_CACHE.get(selectorString);
|
||||
+ if (entities == null) {
|
||||
+ entities = selector.findEntities(context.getSource());
|
||||
+ TICK_ENTITY_CACHE.put(selectorString, entities);
|
||||
@@ -35,7 +35,7 @@ index 8f6a1788b5ca396b79a638955fc6a6b3a276337f..595539574b4a71e0e9f8209569700cf0
|
||||
+ int idxStart = nodes.get(1).getRange().getStart();
|
||||
+ int idxEnd = nodes.get(3).getRange().getEnd();
|
||||
+ String selectorString = context.getInput().substring(idxStart, idxEnd);
|
||||
+ List<? extends Entity> entities = TICK_ENTITY_CACHE.get(selectorString);
|
||||
+ Collection<? extends Entity> entities = TICK_ENTITY_CACHE.get(selectorString);
|
||||
+ if (entities == null) {
|
||||
+ entities = selector.findEntities(context.getSource());
|
||||
+ TICK_ENTITY_CACHE.put(selectorString, entities);
|
||||
|
||||
Reference in New Issue
Block a user