mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 20:46:59 +01:00
Add entity tracker min Y distance config option (#9406)
This commit is contained in:
parent
1b96c64620
commit
7232506c22
@ -1481,10 +1481,10 @@ index 0000000000000000000000000000000000000000..f0d4ec73bc8872a85e34f5c6b4d342e7
|
|||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..d47c57afafc01e25b965f1844938b2516a7bd031
|
index 0000000000000000000000000000000000000000..4989f99c0d330da52aeaca5df08edfbd47b5bf3c
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
|
||||||
@@ -0,0 +1,484 @@
|
@@ -0,0 +1,523 @@
|
||||||
+package io.papermc.paper.configuration;
|
+package io.papermc.paper.configuration;
|
||||||
+
|
+
|
||||||
+import com.google.common.collect.HashBasedTable;
|
+import com.google.common.collect.HashBasedTable;
|
||||||
@ -1520,6 +1520,8 @@ index 0000000000000000000000000000000000000000..d47c57afafc01e25b965f1844938b251
|
|||||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
+import net.minecraft.resources.ResourceLocation;
|
+import net.minecraft.resources.ResourceLocation;
|
||||||
+import net.minecraft.world.Difficulty;
|
+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.EntityType;
|
||||||
+import net.minecraft.world.entity.MobCategory;
|
+import net.minecraft.world.entity.MobCategory;
|
||||||
+import net.minecraft.world.entity.monster.Vindicator;
|
+import net.minecraft.world.entity.monster.Vindicator;
|
||||||
@ -1530,6 +1532,7 @@ index 0000000000000000000000000000000000000000..d47c57afafc01e25b965f1844938b251
|
|||||||
+import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
+import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||||
+import org.slf4j.Logger;
|
+import org.slf4j.Logger;
|
||||||
+import org.spigotmc.SpigotWorldConfig;
|
+import org.spigotmc.SpigotWorldConfig;
|
||||||
|
+import org.spigotmc.TrackingRange;
|
||||||
+import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
+import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||||
+import org.spongepowered.configurate.objectmapping.meta.Required;
|
+import org.spongepowered.configurate.objectmapping.meta.Required;
|
||||||
+import org.spongepowered.configurate.objectmapping.meta.Setting;
|
+import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||||
@ -1773,6 +1776,42 @@ index 0000000000000000000000000000000000000000..d47c57afafc01e25b965f1844938b251
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ 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;
|
+ public Lootables lootables;
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: ruViolence <78062896+ruViolence@users.noreply.github.com>
|
||||||
|
Date: Tue, 27 Jun 2023 15:38:18 +0800
|
||||||
|
Subject: [PATCH] Configurable entity tracking range by Y coordinate
|
||||||
|
|
||||||
|
Options to configure entity tracking by Y coordinate, also for each entity category.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
index a4bf4ed615653ce30d2416a62e680d74e87b53fa..65d947df910d60f478e7a449eb161e5105e2c0c9 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||||
|
@@ -1554,6 +1554,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
|
double d1 = vec3d_dx * vec3d_dx + vec3d_dz * vec3d_dz; // Paper
|
||||||
|
double d2 = d0 * d0;
|
||||||
|
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player);
|
||||||
|
+ // Paper start - check Y
|
||||||
|
+ if (flag && level.paperConfig().entities.trackingRangeY.enabled) {
|
||||||
|
+ double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1);
|
||||||
|
+ if (rangeY != -1) {
|
||||||
|
+ double vec3d_dy = player.getY() - this.entity.getY();
|
||||||
|
+ flag = vec3d_dy * vec3d_dy <= rangeY * rangeY;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Paper end - check Y
|
||||||
|
|
||||||
|
// CraftBukkit start - respect vanish API
|
||||||
|
if (!player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) {
|
Loading…
Reference in New Issue
Block a user