2023-04-03 04:18:55 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2023-12-11 01:20:31 +00:00
|
|
|
From: Telesphoreo <me@telesphoreo.me>
|
|
|
|
Date: Sun, 10 Dec 2023 18:57:50 -0600
|
2023-04-03 04:18:55 +00:00
|
|
|
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-12-11 01:20:31 +00:00
|
|
|
index d87ffb5ed4550757016c2fabaa2845a6aaac74d7..7e8cf65ac53f595292d161da0735bf97081e832a 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-12-11 01:20:31 +00:00
|
|
|
@@ -123,11 +123,11 @@ public interface MinMaxBounds<T extends Number> {
|
2023-10-15 22:45:13 +00:00
|
|
|
|
|
|
|
public static record Doubles(Optional<Double> min, Optional<Double> max, Optional<Double> minSq, Optional<Double> maxSq) implements MinMaxBounds<Double> {
|
2023-09-24 21:42:28 +00:00
|
|
|
public static final MinMaxBounds.Doubles ANY = new MinMaxBounds.Doubles(Optional.empty(), Optional.empty());
|
2023-10-15 22:45:13 +00:00
|
|
|
- public static final Codec<MinMaxBounds.Doubles> CODEC = MinMaxBounds.createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new);
|
|
|
|
+ public static final Codec<MinMaxBounds.Doubles> CODEC = MinMaxBounds.<Double, MinMaxBounds.Doubles>createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new); // Scissors - compile fixes
|
2023-09-24 21:42:28 +00:00
|
|
|
|
2023-12-11 01:20:31 +00:00
|
|
|
- private Doubles(Optional<Double> min, Optional<Double> max) {
|
|
|
|
+ public Doubles(Optional<Double> min, Optional<Double> max) {
|
|
|
|
this(min, max, squareOpt(min), squareOpt(max));
|
|
|
|
- }
|
|
|
|
+ } // Scissors - private -> public
|
2023-09-24 21:42:28 +00:00
|
|
|
|
2023-12-11 01:20:31 +00:00
|
|
|
private static MinMaxBounds.Doubles create(StringReader reader, Optional<Double> min, Optional<Double> max) throws CommandSyntaxException {
|
|
|
|
if (min.isPresent() && max.isPresent() && min.get() > max.get()) {
|
|
|
|
@@ -188,7 +188,7 @@ public interface MinMaxBounds<T extends Number> {
|
2023-10-15 22:45:13 +00:00
|
|
|
|
|
|
|
public static record Ints(Optional<Integer> min, Optional<Integer> max, Optional<Long> minSq, Optional<Long> maxSq) implements MinMaxBounds<Integer> {
|
|
|
|
public static final MinMaxBounds.Ints ANY = new MinMaxBounds.Ints(Optional.empty(), Optional.empty());
|
|
|
|
- public static final Codec<MinMaxBounds.Ints> CODEC = MinMaxBounds.createCodec(Codec.INT, MinMaxBounds.Ints::new);
|
|
|
|
+ public static final Codec<MinMaxBounds.Ints> CODEC = MinMaxBounds.<Integer, MinMaxBounds.Ints>createCodec(Codec.INT, MinMaxBounds.Ints::new); // Scissors - compile fixes
|
|
|
|
|
2023-12-11 01:20:31 +00:00
|
|
|
private Ints(Optional<Integer> min, Optional<Integer> max) {
|
|
|
|
this(min, max, min.map((i) -> {
|
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-12-11 01:20:31 +00:00
|
|
|
index 73c15a0c56a103ba4e62f0a51af8d42566b07245..f0a84efe86407ab3d7a9f064140c12df43265adc 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-12-11 01:20:31 +00:00
|
|
|
@@ -10,6 +10,8 @@ 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-12-11 01:20:31 +00:00
|
|
|
+
|
|
|
|
+import me.totalfreedom.scissors.MathUtility;
|
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-26 00:06:18 +00:00
|
|
|
@@ -60,9 +62,26 @@ 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-12-11 01:20:31 +00:00
|
|
|
+ distance.min().map(min -> Math.min(min, 1024)),
|
|
|
|
+ distance.max().map(max -> Math.min(max, 1024))
|
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;
|