aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0018-Add-view-distance-API.patch
blob: 717285adffed7d65afa212d8fd80cdb02c39c9bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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 a9858c2559f0921613b19710135cc6e060488e96..890ae536fdaff11055b72b1be0fbf3766a41812c 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -2941,6 +2941,66 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
     @NotNull
     public Set<FeatureFlag> getFeatureFlags();
 
+    // 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
+    default int getNoTickViewDistance() {
+        return this.getViewDistance();
+    }
+
+    /**
+     * 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
+    default void setNoTickViewDistance(int viewDistance) {
+        this.setViewDistance(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
+
     /**
      * Gets all generated structures that intersect the chunk at the given
      * coordinates. <br>
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index f868eb1609f7c905fe6ebcf088a0a3030af55e92..5d5d37e2ebbbe4d2641177c7d174059ba29bb688 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -2544,6 +2544,82 @@ 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
+    default int getNoTickViewDistance() {
+        return this.getViewDistance();
+    }
+
+    /**
+     * 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
+    default void setNoTickViewDistance(int viewDistance) {
+        this.setViewDistance(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
 
     /**