9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00

Fix cloud compat

This commit is contained in:
HaHaWTH
2025-07-14 01:31:14 +14:00
parent 2f72924ec7
commit 1c63bd73e2
2 changed files with 9 additions and 9 deletions

View File

@@ -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);

View File

@@ -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<EntitySelector> {
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());
+ 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<EntitySelector> {
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());
+ 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<ServerPlayer> getOptionalPlayers(CommandContext<CommandSourceStack> 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<? extends Entity> findEntitiesSkipInactive(CommandSourceStack source) throws CommandSyntaxException {
+ public java.util.Collection<? extends Entity> findEntitiesSkipInactive(CommandSourceStack source) throws CommandSyntaxException {
+ this.checkPermissions(source);
+ if (!this.includesEntities) {
+ return this.findPlayers(source);