mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-06 23:22:10 -07:00
clean up view distance api diff
This commit is contained in:
@@ -22,16 +22,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||||
@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||||
public int getSimulationDistance() {
|
|
||||||
return world.spigotConfig.simulationDistance;
|
return world.spigotConfig.simulationDistance;
|
||||||
}
|
}
|
||||||
+
|
// Spigot end
|
||||||
|
+ // Paper start - view distance api
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void setViewDistance(int viewDistance) {
|
+ public void setViewDistance(int viewDistance) {
|
||||||
+ throw new UnsupportedOperationException(); //TODO
|
+ throw new UnsupportedOperationException(); //TODO
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
|
+ public void setSimulationDistance(int simulationDistance) {
|
||||||
|
+ throw new UnsupportedOperationException(); //TODO
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
+ public int getNoTickViewDistance() {
|
+ public int getNoTickViewDistance() {
|
||||||
+ throw new UnsupportedOperationException(); //TODO
|
+ throw new UnsupportedOperationException(); //TODO
|
||||||
+ }
|
+ }
|
||||||
@@ -50,9 +55,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ public void setSendViewDistance(int viewDistance) {
|
+ public void setSendViewDistance(int viewDistance) {
|
||||||
+ throw new UnsupportedOperationException(); //TODO
|
+ throw new UnsupportedOperationException(); //TODO
|
||||||
+ }
|
+ }
|
||||||
// Spigot end
|
+ // Paper end - view distance api
|
||||||
|
|
||||||
// Spigot start
|
// Spigot start
|
||||||
|
private final org.bukkit.World.Spigot spigot = new org.bukkit.World.Spigot()
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||||
@@ -73,6 +79,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
|
+ public int getSimulationDistance() {
|
||||||
|
+ throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void setSimulationDistance(int simulationDistance) {
|
||||||
|
+ throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
+ public int getNoTickViewDistance() {
|
+ public int getNoTickViewDistance() {
|
||||||
+ throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
+ throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
||||||
+ }
|
+ }
|
||||||
|
@@ -2114,7 +2114,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
- return world.spigotConfig.simulationDistance;
|
- return world.spigotConfig.simulationDistance;
|
||||||
+ return getHandle().getChunkSource().chunkMap.playerChunkManager.getTargetTickViewDistance(); // Paper - replace old player chunk management
|
+ return getHandle().getChunkSource().chunkMap.playerChunkManager.getTargetTickViewDistance(); // Paper - replace old player chunk management
|
||||||
}
|
}
|
||||||
|
// Spigot end
|
||||||
|
// Paper start - view distance api
|
||||||
@Override
|
@Override
|
||||||
public void setViewDistance(int viewDistance) {
|
public void setViewDistance(int viewDistance) {
|
||||||
- throw new UnsupportedOperationException(); //TODO
|
- throw new UnsupportedOperationException(); //TODO
|
||||||
@@ -2125,11 +2126,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ net.minecraft.server.level.ChunkMap chunkMap = getHandle().getChunkSource().chunkMap;
|
+ net.minecraft.server.level.ChunkMap chunkMap = getHandle().getChunkSource().chunkMap;
|
||||||
+ chunkMap.setViewDistance(viewDistance);
|
+ chunkMap.setViewDistance(viewDistance);
|
||||||
+ // Paper end - replace old player chunk management
|
+ // Paper end - replace old player chunk management
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ // Paper start - replace old player chunk management
|
+ // Paper start - replace old player chunk management
|
||||||
+ @Override
|
@Override
|
||||||
+ public void setSimulationDistance(int simulationDistance) {
|
public void setSimulationDistance(int simulationDistance) {
|
||||||
|
- throw new UnsupportedOperationException(); //TODO
|
||||||
+ // Paper start - replace old player chunk management
|
+ // Paper start - replace old player chunk management
|
||||||
+ if (simulationDistance < 2 || simulationDistance > 32) {
|
+ if (simulationDistance < 2 || simulationDistance > 32) {
|
||||||
+ throw new IllegalArgumentException("Simulation distance " + simulationDistance + " is out of range of [2, 32]");
|
+ throw new IllegalArgumentException("Simulation distance " + simulationDistance + " is out of range of [2, 32]");
|
||||||
@@ -2162,7 +2164,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
- throw new UnsupportedOperationException(); //TODO
|
- throw new UnsupportedOperationException(); //TODO
|
||||||
+ getHandle().getChunkSource().chunkMap.playerChunkManager.setSendDistance(viewDistance); // Paper - replace old player chunk management
|
+ getHandle().getChunkSource().chunkMap.playerChunkManager.setSendDistance(viewDistance); // Paper - replace old player chunk management
|
||||||
}
|
}
|
||||||
// Spigot end
|
// Paper end - view distance api
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
@@ -2174,28 +2176,49 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
+ // Paper start - implement view distances
|
+ // Paper start - implement view distances
|
||||||
@Override
|
@Override
|
||||||
- public int getViewDistance() {
|
public int getViewDistance() {
|
||||||
- throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
- throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
||||||
+ public int getSendViewDistance() {
|
|
||||||
+ net.minecraft.server.level.ChunkMap chunkMap = this.getHandle().getLevel().getChunkSource().chunkMap;
|
+ net.minecraft.server.level.ChunkMap chunkMap = this.getHandle().getLevel().getChunkSource().chunkMap;
|
||||||
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = chunkMap.playerChunkManager.getData(this.getHandle());
|
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = chunkMap.playerChunkManager.getData(this.getHandle());
|
||||||
+ if (data == null) {
|
+ if (data == null) {
|
||||||
+ return chunkMap.playerChunkManager.getTargetSendDistance();
|
+ return chunkMap.playerChunkManager.getTargetNoTickViewDistance();
|
||||||
+ }
|
+ }
|
||||||
+ return data.getTargetSendViewDistance();
|
+ return data.getTargetNoTickViewDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
- public void setViewDistance(int viewDistance) {
|
public void setViewDistance(int viewDistance) {
|
||||||
- throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
- throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
||||||
+ public void setSendViewDistance(int viewDistance) {
|
|
||||||
+ net.minecraft.server.level.ChunkMap chunkMap = this.getHandle().getLevel().getChunkSource().chunkMap;
|
+ net.minecraft.server.level.ChunkMap chunkMap = this.getHandle().getLevel().getChunkSource().chunkMap;
|
||||||
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = chunkMap.playerChunkManager.getData(this.getHandle());
|
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = chunkMap.playerChunkManager.getData(this.getHandle());
|
||||||
+ if (data == null) {
|
+ if (data == null) {
|
||||||
+ throw new IllegalStateException("Player is not attached to world");
|
+ throw new IllegalStateException("Player is not attached to world");
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ data.setTargetSendViewDistance(viewDistance);
|
+ data.setTargetNoTickViewDistance(viewDistance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSimulationDistance() {
|
||||||
|
- throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
||||||
|
+ net.minecraft.server.level.ChunkMap chunkMap = this.getHandle().getLevel().getChunkSource().chunkMap;
|
||||||
|
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = chunkMap.playerChunkManager.getData(this.getHandle());
|
||||||
|
+ if (data == null) {
|
||||||
|
+ return chunkMap.playerChunkManager.getTargetTickViewDistance();
|
||||||
|
+ }
|
||||||
|
+ return data.getTargetTickViewDistance();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSimulationDistance(int simulationDistance) {
|
||||||
|
- throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
||||||
|
+ net.minecraft.server.level.ChunkMap chunkMap = this.getHandle().getLevel().getChunkSource().chunkMap;
|
||||||
|
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = chunkMap.playerChunkManager.getData(this.getHandle());
|
||||||
|
+ if (data == null) {
|
||||||
|
+ throw new IllegalStateException("Player is not attached to world");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ data.setTargetTickViewDistance(simulationDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2211,49 +2234,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
- public int getSendViewDistance() {
|
public int getSendViewDistance() {
|
||||||
- throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
- throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
||||||
+ public int getViewDistance() {
|
|
||||||
+ net.minecraft.server.level.ChunkMap chunkMap = this.getHandle().getLevel().getChunkSource().chunkMap;
|
+ net.minecraft.server.level.ChunkMap chunkMap = this.getHandle().getLevel().getChunkSource().chunkMap;
|
||||||
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = chunkMap.playerChunkManager.getData(this.getHandle());
|
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = chunkMap.playerChunkManager.getData(this.getHandle());
|
||||||
+ if (data == null) {
|
+ if (data == null) {
|
||||||
+ return chunkMap.playerChunkManager.getTargetNoTickViewDistance();
|
+ return chunkMap.playerChunkManager.getTargetSendDistance();
|
||||||
+ }
|
+ }
|
||||||
+ return data.getTargetNoTickViewDistance();
|
+ return data.getTargetSendViewDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
- public void setSendViewDistance(int viewDistance) {
|
public void setSendViewDistance(int viewDistance) {
|
||||||
- throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
- throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
|
||||||
+ public void setViewDistance(int viewDistance) {
|
|
||||||
+ net.minecraft.server.level.ChunkMap chunkMap = this.getHandle().getLevel().getChunkSource().chunkMap;
|
+ net.minecraft.server.level.ChunkMap chunkMap = this.getHandle().getLevel().getChunkSource().chunkMap;
|
||||||
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = chunkMap.playerChunkManager.getData(this.getHandle());
|
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = chunkMap.playerChunkManager.getData(this.getHandle());
|
||||||
+ if (data == null) {
|
+ if (data == null) {
|
||||||
+ throw new IllegalStateException("Player is not attached to world");
|
+ throw new IllegalStateException("Player is not attached to world");
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ data.setTargetNoTickViewDistance(viewDistance);
|
+ data.setTargetSendViewDistance(viewDistance);
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public int getSimulationDistance() {
|
|
||||||
+ net.minecraft.server.level.ChunkMap chunkMap = this.getHandle().getLevel().getChunkSource().chunkMap;
|
|
||||||
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = chunkMap.playerChunkManager.getData(this.getHandle());
|
|
||||||
+ if (data == null) {
|
|
||||||
+ return chunkMap.playerChunkManager.getTargetTickViewDistance();
|
|
||||||
+ }
|
|
||||||
+ return data.getTargetTickViewDistance();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public void setSimulationDistance(int simulationDistance) {
|
|
||||||
+ net.minecraft.server.level.ChunkMap chunkMap = this.getHandle().getLevel().getChunkSource().chunkMap;
|
|
||||||
+ io.papermc.paper.chunk.PlayerChunkLoader.PlayerLoaderData data = chunkMap.playerChunkManager.getData(this.getHandle());
|
|
||||||
+ if (data == null) {
|
|
||||||
+ throw new IllegalStateException("Player is not attached to world");
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ data.setTargetTickViewDistance(simulationDistance);
|
|
||||||
}
|
}
|
||||||
+ // Paper end - implement view distances
|
+ // Paper end - implement view distances
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user