Files
AkarinMC/patches/api/0003-Tuinity-View-distance-api.patch
ㄗㄠˋ ㄑㄧˊ 1b66f4548e Tuinity View distance api
Based on my Tuinity fork: caf081984d
2020-04-18 20:01:29 +08:00

86 lines
3.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E3=84=97=E3=84=A0=CB=8B=20=E3=84=91=E3=84=A7=CB=8A?=
<tsao-chi@the-lingo.org>
Date: Sat, 18 Apr 2020 19:53:16 +0800
Subject: [PATCH] Tuinity View distance api
Allow setting a view distance where entities and chunks do not tick.
This could allow some servers to look like they have a higher view
distance than they actually have.
Also add World#setViewDistance
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index db18f70ec37253232fb2cfd08ccd07d13c7c457d..be92b1a3e062cb7c54d5a1ea83ea22437b8562d4 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -3166,6 +3166,34 @@ public interface World extends PluginMessageRecipient, Metadatable {
int getViewDistance();
// Spigot end
+ // Tuinity start - view distance api
+ /**
+ * Sets the view distance for this world.
+ * @param viewDistance view distance in [2, 32]
+ */
+ void setViewDistance(int viewDistance);
+
+ /**
+ * Returns the no-tick view distance for this world.
+ * <p>
+ * No-tick view distance is the view distance where chunks will load, however the chunks and their entities will not
+ * be set to tick.
+ * </p>
+ * @return The no-tick view distance for this world.
+ */
+ int getNoTickViewDistance();
+
+ /**
+ * Sets the no-tick view distance for this world.
+ * <p>
+ * No-tick view distance is the view distance where chunks will load, however the chunks and their entities will not
+ * be set to tick.
+ * </p>
+ * @param viewDistance view distance in [2, 32]
+ */
+ void setNoTickViewDistance(int viewDistance);
+ // Tuinity end - view distance api
+
// Spigot start
public class Spigot {
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 787bb144b5918ef1e46d69cb72b84128d2b678f3..c542305c69da3b9e5c2485e3c0cdf7ec60b1239b 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -1732,6 +1732,29 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
<T> T getClientOption(@NotNull ClientOption<T> option);
// Paper end
+ // Tuinity start
+ /**
+ * Returns the no-tick view distance for this player.
+ * <p>
+ * No-tick view distance is the view distance where chunks will load, however the chunks and their entities will not
+ * be set to tick.
+ * </p>
+ * @return The no-tick view distance for this player.
+ */
+ int getNoTickViewDistance();
+
+ /**
+ * Sets the no-tick view distance for this player. Setting to a value of -1 will default to the world no-tick
+ * view distance.
+ * <p>
+ * No-tick view distance is the view distance where chunks will load, however the chunks and their entities will not
+ * be set to tick.
+ * </p>
+ * @param viewDistance view distance in [2, 32] or -1
+ */
+ void setNoTickViewDistance(int viewDistance);
+ // Tuinity end
+
// Spigot start
public class Spigot extends Entity.Spigot {