diff --git a/leaf-server/minecraft-patches/features/0268-Cache-function-execution-result.patch b/leaf-server/minecraft-patches/features/0268-Cache-function-execution-result.patch index e75ba658..be13d122 100644 --- a/leaf-server/minecraft-patches/features/0268-Cache-function-execution-result.patch +++ b/leaf-server/minecraft-patches/features/0268-Cache-function-execution-result.patch @@ -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 { @@ -13,7 +13,7 @@ index 8f6a1788b5ca396b79a638955fc6a6b3a276337f..595539574b4a71e0e9f8209569700cf0 } + // Leaf start - Cache function getEntity calls -+ public static final java.util.Map> TICK_ENTITY_CACHE = new java.util.concurrent.ConcurrentHashMap<>(); ++ public static final java.util.Map> TICK_ENTITY_CACHE = new java.util.concurrent.ConcurrentHashMap<>(); + public static Collection getOptionalEntitiesCachedAs(CommandContext 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 entities = TICK_ENTITY_CACHE.get(selectorString); ++ Collection 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 entities = TICK_ENTITY_CACHE.get(selectorString); ++ Collection entities = TICK_ENTITY_CACHE.get(selectorString); + if (entities == null) { + entities = selector.findEntities(context.getSource()); + TICK_ENTITY_CACHE.put(selectorString, entities); diff --git a/leaf-server/minecraft-patches/features/0273-Skip-inactive-entity-for-execute.patch b/leaf-server/minecraft-patches/features/0273-Skip-inactive-entity-for-execute.patch index 6e34df75..5ad9ace7 100644 --- a/leaf-server/minecraft-patches/features/0273-Skip-inactive-entity-for-execute.patch +++ b/leaf-server/minecraft-patches/features/0273-Skip-inactive-entity-for-execute.patch @@ -5,12 +5,12 @@ Subject: [PATCH] Skip inactive entity for execute diff --git a/net/minecraft/commands/arguments/EntityArgument.java b/net/minecraft/commands/arguments/EntityArgument.java -index 595539574b4a71e0e9f8209569700cf0c7df8197..747c38f1f1cdabae22c12196790b6b314418f48c 100644 +index 4acf68e42a9644612608c8521020a989cbdea4a9..76487244de9caad06696f2f4910c52c09547f775 100644 --- a/net/minecraft/commands/arguments/EntityArgument.java +++ b/net/minecraft/commands/arguments/EntityArgument.java @@ -76,7 +76,7 @@ public class EntityArgument implements ArgumentType { String selectorString = context.getInput().substring(idxStart, idxEnd); - List entities = TICK_ENTITY_CACHE.get(selectorString); + Collection entities = TICK_ENTITY_CACHE.get(selectorString); if (entities == null) { - entities = selector.findEntities(context.getSource()); + entities = org.dreeam.leaf.config.modules.opt.SkipInactiveEntityForExecute.skipInactiveEntityForExecute ? selector.findEntitiesSkipInactive(context.getSource()) : selector.findEntities(context.getSource()); @@ -19,7 +19,7 @@ index 595539574b4a71e0e9f8209569700cf0c7df8197..747c38f1f1cdabae22c12196790b6b31 return entities; @@ -90,14 +90,17 @@ public class EntityArgument implements ArgumentType { String selectorString = context.getInput().substring(idxStart, idxEnd); - List entities = TICK_ENTITY_CACHE.get(selectorString); + Collection entities = TICK_ENTITY_CACHE.get(selectorString); if (entities == null) { - entities = selector.findEntities(context.getSource()); + entities = org.dreeam.leaf.config.modules.opt.SkipInactiveEntityForExecute.skipInactiveEntityForExecute ? selector.findEntitiesSkipInactive(context.getSource()) : selector.findEntities(context.getSource()); // Leaf - Skip inactive entity for execute @@ -38,7 +38,7 @@ index 595539574b4a71e0e9f8209569700cf0c7df8197..747c38f1f1cdabae22c12196790b6b31 public static Collection getOptionalPlayers(CommandContext context, String name) throws CommandSyntaxException { diff --git a/net/minecraft/commands/arguments/selector/EntitySelector.java b/net/minecraft/commands/arguments/selector/EntitySelector.java -index bbaf1a29f86a9bfc13795249d545b6f7f1bb53eb..36847690c4827dc4b1e94a219be02fab2cad8479 100644 +index bbaf1a29f86a9bfc13795249d545b6f7f1bb53eb..60904d6b3046d28b8bba5c050225bf476f2f601a 100644 --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java @@ -165,6 +165,51 @@ public class EntitySelector { @@ -46,7 +46,7 @@ index bbaf1a29f86a9bfc13795249d545b6f7f1bb53eb..36847690c4827dc4b1e94a219be02fab } + // Leaf start - Skip inactive entity for execute -+ public List findEntitiesSkipInactive(CommandSourceStack source) throws CommandSyntaxException { ++ public java.util.Collection findEntitiesSkipInactive(CommandSourceStack source) throws CommandSyntaxException { + this.checkPermissions(source); + if (!this.includesEntities) { + return this.findPlayers(source);