2023-04-03 04:18:55 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Luna <lunahatesgogle@gmail.com>
|
|
|
|
Date: Sun, 2 Apr 2023 16:29:51 -0300
|
|
|
|
Subject: [PATCH] Patch large selector distance crash
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
2023-09-24 21:42:28 +00:00
|
|
|
index 8897496323378080135127f53db004d576476c21..109fbcddd1814013692b1200d37fea09d069cfd5 100644
|
2023-04-03 04:18:55 +00:00
|
|
|
--- a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
|
|
|
+++ b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
2023-09-24 21:42:28 +00:00
|
|
|
@@ -131,7 +131,7 @@ public interface MinMaxBounds<T extends Number> {
|
|
|
|
public static final MinMaxBounds.Doubles ANY = new MinMaxBounds.Doubles(Optional.empty(), Optional.empty());
|
|
|
|
public static final Codec<MinMaxBounds.Doubles> CODEC = MinMaxBounds.createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new);
|
|
|
|
|
|
|
|
- private Doubles(Optional<Double> optional, Optional<Double> optional2) {
|
|
|
|
+ public Doubles(Optional<Double> optional, Optional<Double> optional2) {
|
|
|
|
this(optional, optional2, squareOpt(optional), squareOpt(optional2));
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -143,7 +143,7 @@ public interface MinMaxBounds<T extends Number> {
|
|
|
|
}
|
2023-04-03 04:18:55 +00:00
|
|
|
}
|
|
|
|
|
2023-09-24 21:42:28 +00:00
|
|
|
- private static Optional<Double> squareOpt(Optional<Double> optional) {
|
|
|
|
+ public static Optional<Double> squareOpt(Optional<Double> optional) {
|
|
|
|
return optional.map((double_) -> {
|
|
|
|
return double_ * double_;
|
|
|
|
});
|
2023-04-03 04:18:55 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
2023-09-24 21:42:28 +00:00
|
|
|
index 73c15a0c56a103ba4e62f0a51af8d42566b07245..ef54de7a77cda9793c723ce58403fb1a610a7956 100644
|
2023-04-03 04:18:55 +00:00
|
|
|
--- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
|
|
|
+++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
2023-09-24 21:42:28 +00:00
|
|
|
@@ -5,11 +5,13 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
+import java.util.Optional;
|
|
|
|
import java.util.UUID;
|
|
|
|
import java.util.function.BiConsumer;
|
2023-04-03 04:18:55 +00:00
|
|
|
import java.util.function.Function;
|
|
|
|
import java.util.function.Predicate;
|
|
|
|
import javax.annotation.Nullable;
|
2023-07-01 20:21:13 +00:00
|
|
|
+import me.totalfreedom.scissors.MathUtility; // Scissors
|
2023-04-03 04:18:55 +00:00
|
|
|
import net.minecraft.advancements.critereon.MinMaxBounds;
|
|
|
|
import net.minecraft.commands.CommandSourceStack;
|
|
|
|
import net.minecraft.commands.arguments.EntityArgument;
|
2023-09-24 21:42:28 +00:00
|
|
|
@@ -60,9 +62,27 @@ public class EntitySelector {
|
2023-04-03 04:18:55 +00:00
|
|
|
this.includesEntities = includesNonPlayers;
|
|
|
|
this.worldLimited = localWorldOnly;
|
|
|
|
this.predicate = basePredicate;
|
|
|
|
- this.range = distance;
|
|
|
|
+
|
|
|
|
+ // Scissors start - Patch large selector distance crash
|
|
|
|
+ this.range = new MinMaxBounds.Doubles(
|
2023-09-24 21:42:28 +00:00
|
|
|
+ distance.min().isPresent() ? Optional.of(Math.min(distance.min().get(), 1024)) : null,
|
|
|
|
+ distance.max().isPresent() ? Optional.of(Math.min(distance.max().get(), 1024)) : null
|
2023-04-03 04:18:55 +00:00
|
|
|
+ );
|
|
|
|
this.position = positionOffset;
|
|
|
|
- this.aabb = box;
|
|
|
|
+ if (box != null) {
|
|
|
|
+ this.aabb = new AABB(
|
|
|
|
+ MathUtility.clampDouble(box.minX, -1024, 1025),
|
|
|
|
+ MathUtility.clampDouble(box.minY, -1024, 1025),
|
|
|
|
+ MathUtility.clampDouble(box.minZ, -1024, 1025),
|
|
|
|
+ MathUtility.clampDouble(box.maxX, -1024, 1025),
|
|
|
|
+ MathUtility.clampDouble(box.maxY, -1024, 1025),
|
|
|
|
+ MathUtility.clampDouble(box.maxZ, -1024, 1025),
|
|
|
|
+ false
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ this.aabb = null;
|
|
|
|
+ }
|
|
|
|
+ // Scissors end
|
|
|
|
this.order = sorter;
|
|
|
|
this.currentEntity = senderOnly;
|
|
|
|
this.playerName = playerName;
|