3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 21:10:17 +01:00

[Bleeding] Prevent update inconsistencies on generation/decoration that span chunks. Fixes BUKKIT-871

Dieser Commit ist enthalten in:
Mike Primm 2012-03-21 16:01:11 -05:00 committet von EvilSeph
Ursprung 09a73d352c
Commit f188afe794
12 geänderte Dateien mit 44 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -30,6 +30,7 @@ public class Chunk {
public long n;
private int s;
boolean o;
public boolean sentToClient; // CraftBukkit - flag if chunk has been seen
public Chunk(World world, int i, int j) {
this.sections = new ChunkSection[16];

Datei anzeigen

@ -51,6 +51,13 @@ public class ChunkProviderFlat implements IChunkProvider {
if (this.c) {
this.d.a(this, this.a, i, j, abyte);
}
// CraftBukkit start - prime biome data to prevent uninitialized values racing to client
BiomeBase[] bb = this.a.getWorldChunkManager().getBiomeBlock(null, i * 16, j * 16, 16, 16);
byte[] biomes = chunk.l();
for(int idx = 0; idx < biomes.length; idx++) {
biomes[idx] = (byte) bb[idx].id;
}
// CraftBukkit end
chunk.initLighting();
return chunk;

Datei anzeigen

@ -192,6 +192,13 @@ public class ChunkProviderHell implements IChunkProvider {
this.t.a(this, this.o, i, j, abyte);
this.c.a(this, this.o, i, j, abyte);
Chunk chunk = new Chunk(this.o, abyte, i, j);
// CraftBukkit start - prime biome data to prevent uninitialized values racing to client
BiomeBase[] bb = this.o.getWorldChunkManager().getBiomeBlock(null, i * 16, j * 16, 16, 16);
byte[] biomes = chunk.l();
for(int idx = 0; idx < biomes.length; idx++) {
biomes[idx] = (byte) bb[idx].id;
}
// CraftBukkit end
chunk.m();
return chunk;

Datei anzeigen

@ -142,6 +142,13 @@ public class ChunkProviderTheEnd implements IChunkProvider {
this.b(i, j, abyte, this.o);
Chunk chunk = new Chunk(this.m, abyte, i, j);
// CraftBukkit start - prime biome data to prevent uninitialized values racing to client
byte[] biomes = chunk.l();
for(int idx = 0; idx < biomes.length; idx++) {
biomes[idx] = (byte) this.o[idx].id;
}
// CraftBukkit end
chunk.initLighting();
return chunk;
}

Datei anzeigen

@ -31,6 +31,7 @@ public class Packet51MapChunk extends Packet {
this.f = flag;
if (flag) {
i = '\uffff';
chunk.sentToClient = true; // CraftBukkit - flag as seen
}
ChunkSection[] achunksection = chunk.h();

Datei anzeigen

@ -60,7 +60,7 @@ public class WorldGenForest extends WorldGenerator implements BlockSapling.TreeG
} else {
i1 = world.getTypeId(i, j - 1, k);
if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 256 - l - 1) {
world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
this.setTypeAndData(world, i, j - 1, k, Block.DIRT.id, 0); // CraftBukkit
int i2;

Datei anzeigen

@ -31,7 +31,7 @@ public class WorldGenGroundBush extends WorldGenerator implements BlockSapling.T
if (i1 == Block.DIRT.id || i1 == Block.GRASS.id) {
++j;
world.setRawTypeIdAndData(i, j, k, Block.LOG.id, this.b);
this.setTypeAndData(world, i, j, k, Block.LOG.id, this.b); // CraftBukkit
for (int j1 = j; j1 <= j + 2; ++j1) {
int k1 = j1 - j;

Datei anzeigen

@ -59,7 +59,7 @@ public class WorldGenSwampTree extends WorldGenerator implements BlockSapling.T
} else {
i1 = world.getTypeId(i, j - 1, k);
if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 128 - l - 1) {
world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
this.setTypeAndData(world, i, j - 1, k, Block.DIRT.id, 0); // CraftBukkit
int i2;
int j2;
@ -75,7 +75,7 @@ public class WorldGenSwampTree extends WorldGenerator implements BlockSapling.T
int l2 = k2 - k;
if ((Math.abs(i2) != k1 || Math.abs(l2) != k1 || random.nextInt(2) != 0 && j1 != 0) && !Block.n[world.getTypeId(l1, j2, k2)]) {
world.setRawTypeId(l1, j2, k2, Block.LEAVES.id);
this.setTypeAndData(world, l1, j2, k2, Block.LEAVES.id, 0); // CraftBukkit
}
}
}
@ -84,7 +84,7 @@ public class WorldGenSwampTree extends WorldGenerator implements BlockSapling.T
for (j2 = 0; j2 < l; ++j2) {
j1 = world.getTypeId(i, j + j2, k);
if (j1 == 0 || j1 == Block.LEAVES.id || j1 == Block.WATER.id || j1 == Block.STATIONARY_WATER.id) {
world.setRawTypeId(i, j + j2, k, Block.LOG.id);
this.setTypeAndData(world, i, j + j2, k, Block.LOG.id, 0); // CraftBukkit
}
}
@ -126,7 +126,7 @@ public class WorldGenSwampTree extends WorldGenerator implements BlockSapling.T
}
private void a(org.bukkit.BlockChangeDelegate world, int i, int j, int k, int l) { // CraftBukkit - change signature
world.setTypeIdAndData(i, j, k, Block.VINE.id, l);
this.setTypeAndData(world, i, j, k, Block.VINE.id, l); // CraftBukkit
int i1 = 4;
while (true) {
@ -135,7 +135,7 @@ public class WorldGenSwampTree extends WorldGenerator implements BlockSapling.T
return;
}
world.setTypeIdAndData(i, j, k, Block.VINE.id, l);
this.setTypeAndData(world, i, j, k, Block.VINE.id, l); // CraftBukkit
--i1;
}
}

Datei anzeigen

@ -60,7 +60,7 @@ public class WorldGenTaiga1 extends WorldGenerator implements BlockSapling.TreeG
} else {
l1 = world.getTypeId(i, j - 1, k);
if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < 128 - l - 1) {
world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
this.setTypeAndData(world, i, j - 1, k, Block.DIRT.id, 0); // CraftBukkit
l2 = 0;
for (i2 = j + l; i2 >= j + i1; --i2) {
@ -71,7 +71,7 @@ public class WorldGenTaiga1 extends WorldGenerator implements BlockSapling.TreeG
int j3 = i3 - k;
if ((Math.abs(k2) != l2 || Math.abs(j3) != l2 || l2 <= 0) && !Block.n[world.getTypeId(j2, i2, i3)]) {
world.setRawTypeIdAndData(j2, i2, i3, Block.LEAVES.id, 1);
this.setTypeAndData(world, j2, i2, i3, Block.LEAVES.id, 1); // CraftBukkit
}
}
}
@ -86,7 +86,7 @@ public class WorldGenTaiga1 extends WorldGenerator implements BlockSapling.TreeG
for (i2 = 0; i2 < l - 1; ++i2) {
j2 = world.getTypeId(i, j + i2, k);
if (j2 == 0 || j2 == Block.LEAVES.id) {
world.setRawTypeIdAndData(i, j + i2, k, Block.LOG.id, 1);
this.setTypeAndData(world, i, j + i2, k, Block.LOG.id, 1); // CraftBukkit
}
}

Datei anzeigen

@ -61,7 +61,7 @@ public class WorldGenTaiga2 extends WorldGenerator implements BlockSapling.TreeG
} else {
l1 = world.getTypeId(i, j - 1, k);
if ((l1 == Block.GRASS.id || l1 == Block.DIRT.id) && j < 256 - l - 1) {
world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
this.setTypeAndData(world, i, j - 1, k, Block.DIRT.id, 0); // CraftBukkit
k2 = random.nextInt(2);
i2 = 1;
byte b0 = 0;

Datei anzeigen

@ -72,7 +72,7 @@ public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGe
} else {
i1 = world.getTypeId(i, j - 1, k);
if ((i1 == Block.GRASS.id || i1 == Block.DIRT.id) && j < 256 - l - 1) {
world.setRawTypeId(i, j - 1, k, Block.DIRT.id);
this.setTypeAndData(world, i, j - 1, k, Block.DIRT.id, 0); // CraftBukkit
b0 = 3;
byte b1 = 0;
@ -162,7 +162,7 @@ public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGe
// CraftBukkit - Changed world to BlockChangeDelegate
private void a(BlockChangeDelegate world, int i, int j, int k, int l) {
world.setTypeIdAndData(i, j, k, Block.VINE.id, l);
this.setTypeAndData(world, i, j, k, Block.VINE.id, l); // CraftBukkit
int i1 = 4;
while (true) {
@ -171,7 +171,7 @@ public class WorldGenTrees extends WorldGenerator implements BlockSapling.TreeGe
return;
}
world.setTypeIdAndData(i, j, k, Block.VINE.id, l);
this.setTypeAndData(world, i, j, k, Block.VINE.id, l); // CraftBukkit
--i1;
}
}

Datei anzeigen

@ -24,6 +24,13 @@ public abstract class WorldGenerator {
protected void setTypeAndData(BlockChangeDelegate world, int i, int j, int k, int l, int i1) {
if (this.a) {
world.setTypeIdAndData(i, j, k, l, i1);
// CraftBukkit start - do equiv of setTypeIdAndData, but skip doing physics to prevent fades
}
else if ((world instanceof World) && ((World) world).getChunkAt(i >> 4, k >> 4).sentToClient) {
if (world.setRawTypeIdAndData(i, j, k, l, i1)) {
((World) world).notify(i, j, k);
}
// CraftBukkt end
} else {
world.setRawTypeIdAndData(i, j, k, l, i1);
}