Add entity tracker min Y distance config option (#9406)

This commit is contained in:
ruViolence
2023-08-21 16:05:49 +08:00
parent 1b4291893f
commit 79152ad03a
2 changed files with 66 additions and 0 deletions

View File

@@ -1520,6 +1520,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import net.minecraft.core.registries.BuiltInRegistries;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.Difficulty;
+import net.minecraft.world.entity.Display;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.EntityType;
+import net.minecraft.world.entity.MobCategory;
+import net.minecraft.world.entity.monster.Vindicator;
@@ -1530,6 +1532,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
+import org.slf4j.Logger;
+import org.spigotmc.SpigotWorldConfig;
+import org.spigotmc.TrackingRange;
+import org.spongepowered.configurate.objectmapping.ConfigSerializable;
+import org.spongepowered.configurate.objectmapping.meta.Required;
+import org.spongepowered.configurate.objectmapping.meta.Setting;
@@ -1773,6 +1776,42 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ }
+ }
+
+ public TrackingRangeY trackingRangeY;
+
+ public class TrackingRangeY extends ConfigurationPart {
+ public boolean enabled = false;
+ public IntOr.Default player = IntOr.Default.USE_DEFAULT;
+ public IntOr.Default animal = IntOr.Default.USE_DEFAULT;
+ public IntOr.Default monster = IntOr.Default.USE_DEFAULT;
+ public IntOr.Default misc = IntOr.Default.USE_DEFAULT;
+ public IntOr.Default display = IntOr.Default.USE_DEFAULT;
+ public IntOr.Default other = IntOr.Default.USE_DEFAULT;
+
+ public int get(Entity entity, int def) {
+ if (entity instanceof Display) return display.or(def);
+
+ switch (TrackingRange.getTrackingRangeType(entity)) {
+ case PLAYER -> {
+ return player.or(def);
+ }
+ case ANIMAL -> {
+ return animal.or(def);
+ }
+ case MONSTER -> {
+ return monster.or(def);
+ }
+ case MISC -> {
+ return misc.or(def);
+ }
+ case ENDERDRAGON -> {
+ return -1; // Ender dragon is exempt
+ }
+ }
+
+ return other.or(def);
+ }
+ }
+ }
+
+ public Lootables lootables;