Fix more runtime stuff

Remove chunk neighbour system until we can figure out the chunk system
This commit is contained in:
Spottedleaf
2019-05-06 17:05:41 -07:00
parent b372f891aa
commit 96b32aa6bc
17 changed files with 30 additions and 120 deletions

View File

@@ -322,39 +322,9 @@ index 8b91e27c66..fd23d45346 100644
private final float frictionFactor;
protected final BlockStateList<Block, IBlockData> blockStateList;
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 9cce929c3e..1a2cc0258a 100644
index 9cce929c3e..5c34fe52a4 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
return removed;
}
}
+ public boolean areNeighborsLoaded(final int radius) {
+ switch (radius) {
+ case 2:
+ return this.neighbors == Integer.MAX_VALUE >> 6;
+ case 1:
+ final int mask =
+ // x z offset x z offset x z offset
+ (0x1 << (1 * 5 + 1 + 12)) | (0x1 << (0 * 5 + 1 + 12)) | (0x1 << (-1 * 5 + 1 + 12)) |
+ (0x1 << (1 * 5 + 0 + 12)) | (0x1 << (0 * 5 + 0 + 12)) | (0x1 << (-1 * 5 + 0 + 12)) |
+ (0x1 << (1 * 5 + -1 + 12)) | (0x1 << (0 * 5 + -1 + 12)) | (0x1 << (-1 * 5 + -1 + 12));
+ return (this.neighbors & mask) == mask;
+ default:
+ throw new UnsupportedOperationException(String.valueOf(radius));
+ }
+ }
+
+ public void setNeighborLoaded(final int x, final int z) {
+ this.neighbors |= 0x1 << (x * 5 + 12 + z);
+ }
+
+ public void setNeighborUnloaded(final int x, final int z) {
+ this.neighbors &= ~(0x1 << (x * 5 + 12 + z));
+ }
// Paper end
public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, BiomeBase[] abiomebase, ChunkConverter chunkconverter, TickList<Block> ticklist, TickList<FluidType> ticklist1, long i, @Nullable ChunkSection[] achunksection, @Nullable Consumer<Chunk> consumer) {
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration));
@@ -792,7 +762,7 @@ index 4de927416b..4c1c914132 100644
this.methodProfiler.exit();
}
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 755c0406e1..5816c7bcc7 100644
index 755c0406e1..036577dd0e 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -0,0 +0,0 @@
@@ -804,58 +774,6 @@ index 755c0406e1..5816c7bcc7 100644
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.mojang.datafixers.DataFixer;
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
playerchunk = new PlayerChunk(new ChunkCoordIntPair(i), j, this.lightEngine, this.q, this);
}
+ // TODO: VERIFY THIS
+ ChunkCoordIntPair currentChunkPair = new ChunkCoordIntPair(i);
+ for (int x = -2; x < 3; x++) {
+ for (int z = -2; z < 3; z++) {
+ if (x == 0 && z == 0) {
+ continue;
+ }
+
+
+ PlayerChunk neighborPlayer = getUpdatingChunk(ChunkCoordIntPair.pair(currentChunkPair.x + x, currentChunkPair.z + z));
+ if (neighborPlayer != null) {
+ Chunk neighbor = neighborPlayer.getChunk();
+ Chunk player = playerchunk.getChunk();
+ if (neighbor != null && player != null) {
+ neighbor.setNeighborLoaded(-x, -z);
+ player.setNeighborLoaded(x, z);
+ }
+ }
+ }
+ }
+
this.updatingChunks.put(i, playerchunk);
this.updatingChunksModified = true;
}
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk, chunk.isNeedsSaving());
this.world.getServer().getPluginManager().callEvent(event);
this.saveChunk(ichunkaccess, event.isSaveChunk());
+ // TODO: VERIFY THIS
+ // Paper - Update neighbor counts
+ for (int x = -2; x < 3; x++) {
+ for (int z = -2; z < 3; z++) {
+ if (x == 0 && z == 0) {
+ continue;
+ }
+
+
+ Chunk neighbor = ((Chunk) ichunkaccess).world.getChunkProvider().getChunkAt(event.getChunk().getX(), event.getChunk().getZ(), false);
+ if (neighbor != null) {
+ neighbor.setNeighborUnloaded(-x, -z);
+ ((Chunk) ichunkaccess).setNeighborUnloaded(x, z);
+ }
+ }
+ }
+ // Paper
// CraftBukkit end
chunk.c(false);
@@ -0,0 +0,0 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
});
@@ -1632,7 +1550,7 @@ index 06728e53d5..783676b747 100644
* This helper class represents the different NBT Tags.
* <p>
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 76b060a126..bf35950867 100644
index 76b060a126..2daecf5049 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -0,0 +0,0 @@ import net.minecraft.server.EntityWither;
@@ -1689,14 +1607,6 @@ index 76b060a126..bf35950867 100644
isActive = false;
}
- SpigotTimings.checkIfActiveTimer.stopTiming();
+ int x = MathHelper.floor( entity.locX );
+ int z = MathHelper.floor( entity.locZ );
+ // Make sure not on edge of unloaded chunk
+ Chunk chunk = entity.world.getChunkIfLoaded( x >> 4, z >> 4 );
+ if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) )
+ {
+ isActive = false;
+ }
return isActive;
}
}