Paper/patches/api/0014-Add-view-distance-API.patch
Shane Freeder 3996e6ef29
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
c7c11188 SPIGOT-2620: Add Player#sendBlockChanges()
f63d2b44 Improve annotation test on parameters
3372e7b4 SPIGOT-1244, SPIGOT-6860, SPIGOT-6874: Various Javadoc and formatting fixes
a1e8a9ab PR-793: Ignore .checkstyle file generated by Eclipse IDE

CraftBukkit Changes:
c2c39089e SPIGOT-2620: Add Player#sendBlockChanges()
8209158db PR-1113: Ignore .checkstyle file generated by Eclipse IDE

Spigot Changes:
4aa5ead2 Rebuild patches
2022-09-24 02:38:12 +01:00

160 lines
5.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Mon, 29 Feb 2016 18:05:37 -0600
Subject: [PATCH] Add view distance API
Add per player no-tick, tick, and send view distances.
Also add send/no-tick view distance to World.
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 425cad3b6c365560f6614767d763ad61a92e6722..75a87b221cc0f6334c5283130a7b2bfdf4eedd03 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -2673,6 +2673,62 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
int getSimulationDistance();
// Spigot end
+ // Paper start - view distance api
+ /**
+ * Sets the view distance for this world.
+ * @param viewDistance view distance in [2, 32]
+ */
+ void setViewDistance(int viewDistance);
+
+ /**
+ * Sets the simulation distance for this world.
+ * @param simulationDistance simulation distance in [2, 32]
+ */
+ void setSimulationDistance(int simulationDistance);
+
+ /**
+ * 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.
+ * @deprecated Use {@link #getViewDistance()}
+ */
+ @Deprecated
+ 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]
+ * @deprecated Use {@link #setViewDistance(int)}
+ */
+ @Deprecated
+ void setNoTickViewDistance(int viewDistance);
+
+ /**
+ * Gets the sending view distance for this world.
+ * <p>
+ * Sending view distance is the view distance where chunks will load in for players in this world.
+ * </p>
+ * @return The sending view distance for this world.
+ */
+ int getSendViewDistance();
+
+ /**
+ * Sets the sending view distance for this world.
+ * <p>
+ * Sending view distance is the view distance where chunks will load in for players in this world.
+ * </p>
+ * @param viewDistance view distance in [2, 32] or -1
+ */
+ void setSendViewDistance(int viewDistance);
+ // Paper 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 7c13de51561df662691a36ca1cc91ca7997d773a..292f7827df666c10d7b82aa9b1688bf3f0da5c7b 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -1864,6 +1864,78 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* @param affects Whether the player can affect mob spawning
*/
public void setAffectsSpawning(boolean affects);
+
+ /**
+ * Gets the view distance for this player
+ *
+ * @return the player's view distance
+ * @see org.bukkit.World#getViewDistance()
+ */
+ public int getViewDistance();
+
+ /**
+ * Sets the view distance for this player
+ *
+ * @param viewDistance the player's view distance
+ * @see org.bukkit.World#setViewDistance(int)
+ */
+ public void setViewDistance(int viewDistance);
+
+ /**
+ * Gets the simulation distance for this player
+ *
+ * @return the player's simulation distance
+ */
+ public int getSimulationDistance();
+
+ /**
+ * Sets the simulation distance for this player
+ *
+ * @param simulationDistance the player's new simulation distance
+ */
+ public void setSimulationDistance(int simulationDistance);
+
+ /**
+ * Gets the no-ticking 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.
+ * @deprecated Use {@link #getViewDistance()}
+ */
+ @Deprecated
+ public int getNoTickViewDistance();
+
+ /**
+ * Sets the no-ticking 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>
+ * @param viewDistance view distance in [2, 32] or -1
+ * @deprecated Use {@link #setViewDistance(int)}
+ */
+ @Deprecated
+ public void setNoTickViewDistance(int viewDistance);
+
+ /**
+ * Gets the sending view distance for this player.
+ * <p>
+ * Sending view distance is the view distance where chunks will load in for players.
+ * </p>
+ * @return The sending view distance for this player.
+ */
+ public int getSendViewDistance();
+
+ /**
+ * Sets the sending view distance for this player.
+ * <p>
+ * Sending view distance is the view distance where chunks will load in for players.
+ * </p>
+ * @param viewDistance view distance in [2, 32] or -1
+ */
+ public void setSendViewDistance(int viewDistance);
// Paper end
/**