Paper/patches/api/0013-Add-view-distance-API.patch
Nassim Jahnke ada930bf8d
Updated Upstream (Bukkit/CraftBukkit) (#6872)
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:
cfd18bd0 SPIGOT-6436: Add Player#stopAllSounds

CraftBukkit Changes:
b58f4299 SPIGOT-6436: Add Player#stopAllSounds
eb191612 SPIGOT-6783: Items do not appear in custom anvil inventories
376edf4f SPIGOT-6779: Fix LivingEntity#attack for Player entities
747a73ec SPIGOT-6772: Use entity mailbox and re-schedule entities if they get unloaded
2021-11-05 15:08:24 +01:00

133 lines
4.6 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 3f7658c5347aad369fde6750d969f5fa63e922de..49be21d2676a93c384f37c09fe84eba2ffc11781 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -2443,6 +2443,51 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
int getViewDistance();
// 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);
+
+ /**
+ * 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);
+
+ /**
+ * 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.
+ */
+ public 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
+ */
+ public 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 9381180b7ffce8f9c8f6697d9e0b6c47032ad8a4..a351a6aeff52a406cae686e4525bea1d25285895 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -1497,6 +1497,62 @@ 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()
+ * @see org.bukkit.World#getNoTickViewDistance()
+ */
+ public int getViewDistance();
+
+ /**
+ * Sets the view distance for this player
+ *
+ * @param viewDistance the player's view distance
+ * @see org.bukkit.World#setViewDistance(int)
+ * @see org.bukkit.World#setNoTickViewDistance(int)
+ */
+ public void setViewDistance(int viewDistance);
+
+ /**
+ * 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.
+ */
+ 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
+ */
+ 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
/**