mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-01 04:37:09 +00:00
77 lines
4.5 KiB
Diff
77 lines
4.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Telesphoreo <me@telesphoreo.me>
|
|
Date: Sat, 11 May 2024 13:18:03 -0500
|
|
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
|
|
index 060c0ffe57a4648598870c6168be203bf3a8634d..5c697e5d85c5c65af0ec969dbd68c38e876fc02f 100644
|
|
--- a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
|
+++ b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
|
@@ -121,11 +121,11 @@ public interface MinMaxBounds<T extends Number> {
|
|
public static record Doubles(@Override Optional<Double> min, @Override Optional<Double> max, Optional<Double> minSq, Optional<Double> maxSq)
|
|
implements MinMaxBounds<Double> {
|
|
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);
|
|
+ public static final Codec<MinMaxBounds.Doubles> CODEC = MinMaxBounds.<Double, MinMaxBounds.Doubles>createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new); // Scissors - compile fixes
|
|
|
|
- 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
|
|
|
|
private static MinMaxBounds.Doubles create(StringReader reader, Optional<Double> min, Optional<Double> max) throws CommandSyntaxException {
|
|
if (min.isPresent() && max.isPresent() && min.get() > max.get()) {
|
|
@@ -177,7 +177,7 @@ public interface MinMaxBounds<T extends Number> {
|
|
public static record Ints(@Override Optional<Integer> min, @Override 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
|
|
|
|
private Ints(Optional<Integer> min, Optional<Integer> max) {
|
|
this(min, max, min.map(i -> i.longValue() * i.longValue()), squareOpt(max));
|
|
diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
|
index 676a1499747b071515479130875157263d3a8352..6a65850101b8ea348a4bfeaeca805a39987b06fc 100644
|
|
--- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
|
+++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
|
@@ -10,6 +10,8 @@ import java.util.function.BiConsumer;
|
|
import java.util.function.Function;
|
|
import java.util.function.Predicate;
|
|
import javax.annotation.Nullable;
|
|
+
|
|
+import me.totalfreedom.scissors.MathUtility;
|
|
import net.minecraft.advancements.critereon.MinMaxBounds;
|
|
import net.minecraft.commands.CommandSourceStack;
|
|
import net.minecraft.commands.arguments.EntityArgument;
|
|
@@ -60,9 +62,26 @@ public class EntitySelector {
|
|
this.includesEntities = includesNonPlayers;
|
|
this.worldLimited = localWorldOnly;
|
|
this.predicate = basePredicate;
|
|
- this.range = distance;
|
|
+ // Scissors start - Patch large selector distance crash
|
|
+ this.range = new MinMaxBounds.Doubles(
|
|
+ distance.min().map(min -> Math.min(min, 1024)),
|
|
+ distance.max().map(max -> Math.min(max, 1024))
|
|
+ );
|
|
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;
|