2021-11-23 12:15:10 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach@zachbr.io>
Date: Mon, 6 May 2019 01:29:25 -0400
Subject: [PATCH] Per-Player View Distance API placeholders
I hope to look at this more in-depth soon. It appears doable.
However this should not block the update.
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
2022-09-01 16:51:59 +00:00
index db7e2207612b56b0869a947edd03a6d3f9209e22..981e60c7bf2eee52e84f9894ff689631388a7715 100644
2021-11-23 12:15:10 +00:00
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
2022-09-01 16:51:59 +00:00
@@ -2253,4 +2253,6 @@ public class ServerPlayer extends Player {
2022-03-01 05:43:03 +00:00
return (CraftPlayer) super.getBukkitEntity();
}
// CraftBukkit end
2021-11-23 12:15:10 +00:00
+
2022-03-01 05:43:03 +00:00
+ public final int getViewDistance() { return this.getLevel().getChunkSource().chunkMap.viewDistance - 1; } // Paper - placeholder
}
2021-11-23 12:15:10 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
2022-09-01 16:51:59 +00:00
index 9a6820b10e4164cc38d269853b5c2a49175cb890..0ed46cdd443ac42a7d57ee59f6f04fd9e9259c16 100644
2021-11-23 12:15:10 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
2022-07-04 14:38:06 +00:00
@@ -1913,6 +1913,37 @@ public class CraftWorld extends CraftRegionAccessor implements World {
2021-11-23 12:15:10 +00:00
return world.spigotConfig.simulationDistance;
}
2022-03-01 03:00:17 +00:00
// Spigot end
+ // Paper start - view distance api
2021-11-23 12:15:10 +00:00
+ @Override
+ public void setViewDistance(int viewDistance) {
+ throw new UnsupportedOperationException(); //TODO
+ }
+
+ @Override
2022-03-01 03:00:17 +00:00
+ public void setSimulationDistance(int simulationDistance) {
+ throw new UnsupportedOperationException(); //TODO
+ }
+
+ @Override
2021-11-23 12:15:10 +00:00
+ public int getNoTickViewDistance() {
+ throw new UnsupportedOperationException(); //TODO
+ }
+
+ @Override
+ public void setNoTickViewDistance(int viewDistance) {
+ throw new UnsupportedOperationException(); //TODO
+ }
+
+ @Override
+ public int getSendViewDistance() {
+ throw new UnsupportedOperationException(); //TODO
+ }
+
+ @Override
+ public void setSendViewDistance(int viewDistance) {
+ throw new UnsupportedOperationException(); //TODO
+ }
2022-03-01 03:00:17 +00:00
+ // Paper end - view distance api
2021-11-23 12:15:10 +00:00
// Spigot start
2022-03-01 03:00:17 +00:00
private final org.bukkit.World.Spigot spigot = new org.bukkit.World.Spigot()
2021-11-23 12:15:10 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2022-09-01 16:51:59 +00:00
index 7f0dd0b718a08c850f07f3e0b0a0cf680f1bb2eb..82a640887a75c360539c1787dbbb32750f6b1379 100644
2021-11-23 12:15:10 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2022-06-08 07:49:02 +00:00
@@ -402,6 +402,46 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2021-11-23 12:15:10 +00:00
connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message);
}
}
+
+ @Override
+ public int getViewDistance() {
2022-06-07 21:01:12 +00:00
+ throw new UnsupportedOperationException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
2021-11-23 12:15:10 +00:00
+ }
+
+ @Override
+ public void setViewDistance(int viewDistance) {
2022-06-07 21:01:12 +00:00
+ throw new UnsupportedOperationException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
2021-11-23 12:15:10 +00:00
+ }
+
+ @Override
2022-03-01 03:00:17 +00:00
+ public int getSimulationDistance() {
2022-06-07 21:01:12 +00:00
+ throw new UnsupportedOperationException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
2022-03-01 03:00:17 +00:00
+ }
+
+ @Override
+ public void setSimulationDistance(int simulationDistance) {
2022-06-07 21:01:12 +00:00
+ throw new UnsupportedOperationException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
2022-03-01 03:00:17 +00:00
+ }
+
+ @Override
2021-11-23 12:15:10 +00:00
+ public int getNoTickViewDistance() {
2022-06-07 21:01:12 +00:00
+ throw new UnsupportedOperationException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
2021-11-23 12:15:10 +00:00
+ }
+
+ @Override
+ public void setNoTickViewDistance(int viewDistance) {
2022-06-07 21:01:12 +00:00
+ throw new UnsupportedOperationException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
2021-11-23 12:15:10 +00:00
+ }
+
+ @Override
+ public int getSendViewDistance() {
2022-06-07 21:01:12 +00:00
+ throw new UnsupportedOperationException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
2021-11-23 12:15:10 +00:00
+ }
+
+ @Override
+ public void setSendViewDistance(int viewDistance) {
2022-06-07 21:01:12 +00:00
+ throw new UnsupportedOperationException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
2021-11-23 12:15:10 +00:00
+ }
// Paper end
@Override