Update to Minecraft 1.14-pre5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2019-04-23 12:00:00 +10:00
parent 0e98365784
commit a0f2b74c8d
560 changed files with 10642 additions and 10867 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/Chunk.java
+++ b/net/minecraft/server/Chunk.java
@@ -21,6 +21,13 @@
@@ -22,6 +22,13 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -13,74 +13,42 @@
+
public class Chunk implements IChunkAccess {
private static final Logger d = LogManager.getLogger();
@@ -56,6 +63,35 @@
private final AtomicInteger E;
private final ChunkCoordIntPair F;
private static final Logger b = LogManager.getLogger();
@@ -91,8 +98,19 @@
}
}
+ // CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking
+ private int neighbors = 0x1 << 12;
+ public long chunkKey;
+
+ 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));
+ }
+ // CraftBukkit end
+
public Chunk(World world, int i, int j, BiomeBase[] abiomebase, ChunkConverter chunkconverter, TickList<Block> ticklist, TickList<FluidType> ticklist1, long k) {
this.sections = new ChunkSection[16];
this.g = new boolean[256];
@@ -94,8 +130,16 @@
this.s = ticklist;
this.t = ticklist1;
this.z = k;
+ // CraftBukkit start
+ this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
+ this.chunkKey = ChunkCoordIntPair.a(this.locX, this.locZ);
+ }
+
+ public org.bukkit.Chunk bukkitChunk;
+ public org.bukkit.Chunk getBukkitChunk() {
+ return bukkitChunk;
}
+ public org.bukkit.Chunk bukkitChunk;
+ public boolean mustSave;
+ private boolean needsDecoration;
+ public boolean mustNotSave;
+ public boolean needsDecoration;
+ // CraftBukkit end
+
public Chunk(World world, ProtoChunk protochunk, int i, int j) {
this(world, i, j, protochunk.getBiomeIndex(), protochunk.v(), protochunk.k(), protochunk.l(), protochunk.m());
public Chunk(World world, ProtoChunk protochunk) {
this(world, protochunk.getPos(), protochunk.getBiomeIndex(), protochunk.p(), protochunk.n(), protochunk.o(), protochunk.q(), protochunk.getSections(), (Consumer) null);
Iterator iterator = protochunk.y().iterator();
@@ -134,6 +152,7 @@
@@ -143,6 +187,7 @@
this.x = true;
this.a(ChunkStatus.FULLCHUNK);
this.b(protochunk.r());
this.s = true;
+ this.needsDecoration = true; // CraftBukkit
}
public Set<BlockPosition> t() {
@@ -412,8 +457,15 @@
@Override
@@ -224,9 +243,16 @@
}
}
+ // CraftBukkit start
@Nullable
@Override
public IBlockData setType(BlockPosition blockposition, IBlockData iblockdata, boolean flag) {
+ return this.setType(blockposition, iblockdata, flag, true);
+ }
@@ -91,17 +59,17 @@
int i = blockposition.getX() & 15;
int j = blockposition.getY();
int k = blockposition.getZ() & 15;
@@ -473,7 +525,8 @@
@@ -278,7 +304,8 @@
}
}
- if (!this.world.isClientSide) {
+ // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled.
+ if (!this.world.isClientSide && doPlace && (!this.world.captureBlockStates || block instanceof BlockTileEntity)) {
iblockdata.onPlace(this.world, blockposition, iblockdata1);
iblockdata.onPlace(this.world, blockposition, iblockdata1, flag);
}
@@ -653,7 +706,12 @@
@@ -378,7 +405,12 @@
@Nullable
public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
@@ -114,39 +82,27 @@
+ // CraftBukkit end
if (tileentity == null) {
NBTTagCompound nbttagcompound = (NBTTagCompound) this.h.remove(blockposition);
@@ -700,6 +758,13 @@
NBTTagCompound nbttagcompound = (NBTTagCompound) this.e.remove(blockposition);
@@ -425,6 +457,13 @@
tileentity1.m();
}
tileentity.z();
this.tileEntities.put(blockposition.h(), tileentity);
+ // CraftBukkit start
+ } else {
+ System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.position.getX() + "," + tileentity.position.getY() + "," + tileentity.position.getZ()
+ + " (" + getType(blockposition) + ") where there was no entity tile!");
+ System.out.println("Chunk coordinates: " + (this.locX * 16) + "," + (this.locZ * 16));
+ System.out.println("Chunk coordinates: " + (this.loc.x * 16) + "," + (this.loc.z * 16));
+ new Exception().printStackTrace();
+ // CraftBukkit end
}
}
@@ -727,11 +792,53 @@
for (int j = 0; j < i; ++j) {
EntitySlice<Entity> entityslice = aentityslice[j];
@@ -453,6 +492,41 @@
+ // CraftBukkit start
+ List<Entity> toRemove = new LinkedList<>();
this.world.a(entityslice.stream().filter((entity) -> {
+ if (this.needsDecoration && !CraftEventFactory.doEntityAddEventCalling(this.world, entity, CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) { // Only call for new chunks
+ toRemove.add(entity);
+ return false;
+ }
return !(entity instanceof EntityHuman);
}));
+ entityslice.removeAll(toRemove);
+ // CraftBukkit end
}
}
+ // CraftBukkit start
+ // CraftBukkit start
+ public void loadCallback() {
+ org.bukkit.Server server = this.world.getServer();
+ if (server != null) {
+ /*
@@ -157,12 +113,11 @@
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration));
+
+ if (this.needsDecoration) {
+ BlockSand.instaFall = true;
+ java.util.Random random = new java.util.Random();
+ random.setSeed(world.getSeed());
+ long xRand = random.nextLong() / 2L * 2L + 1L;
+ long zRand = random.nextLong() / 2L * 2L + 1L;
+ random.setSeed((long) locX * xRand + (long) locZ * zRand ^ world.getSeed());
+ random.setSeed((long) this.loc.x * xRand + (long) this.loc.z * zRand ^ world.getSeed());
+
+ org.bukkit.World world = this.world.getWorld();
+ if (world != null) {
@@ -175,40 +130,17 @@
+ this.world.populating = false;
+ }
+ }
+ BlockSand.instaFall = false;
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk));
+ }
+ }
+ // CraftBukkit end
}
public void removeEntities() {
@@ -748,9 +855,21 @@
int i = aentityslice.length;
for (int j = 0; j < i; ++j) {
- EntitySlice<Entity> entityslice = aentityslice[j];
+ // CraftBukkit start
+ List<Entity> newList = Lists.newArrayList(aentityslice[j]);
+ java.util.Iterator<Entity> iter = newList.iterator();
+ while (iter.hasNext()) {
+ Entity entity = iter.next();
+ }
+ // CraftBukkit end
+
+ // Do not pass along players, as doing so can get them stuck outside of time.
+ // (which for example disables inventory icon updates and prevents block breaking)
+ if (entity instanceof EntityPlayer) {
+ iter.remove();
+ }
+ }
- this.world.b((Collection) entityslice);
+ this.world.b((Collection) newList);
+ // CraftBukkit end
}
public void markDirty() {
this.s = true;
}
@@ -810,7 +929,7 @@
Iterator iterator = this.entitySlices[k].c(oclass).iterator();
@@ -527,7 +601,7 @@
Iterator iterator = this.entitySlices[k].a(oclass).iterator();
while (iterator.hasNext()) {
- T t0 = (Entity) iterator.next();
@@ -216,19 +148,30 @@
if (t0.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(t0))) {
list.add(t0);
@@ -1073,13 +1192,13 @@
}
@@ -601,7 +675,7 @@
if (this.s instanceof ProtoChunkTickList) {
- ((ProtoChunkTickList) this.s).a(this.world.getBlockTickList(), (blockposition1) -> {
+ ((ProtoChunkTickList<Block>) this.s).a(this.world.getBlockTickList(), (blockposition1) -> { // CraftBukkit - decompile error
return this.world.getType(blockposition1).getBlock();
});
}
@Override
public boolean isNeedsSaving() {
- return this.s || this.q && this.world.getTime() != this.lastSaved;
+ return (this.s || this.q && this.world.getTime() != this.lastSaved) && !this.mustNotSave; // CraftBukkit
}
if (this.t instanceof ProtoChunkTickList) {
- ((ProtoChunkTickList) this.t).a(this.world.getFluidTickList(), (blockposition1) -> {
+ ((ProtoChunkTickList<FluidType>) this.t).a(this.world.getFluidTickList(), (blockposition1) -> { // CraftBukkit - decompile error
return this.world.getFluid(blockposition1).c();
});
}
public void d(boolean flag) {
@@ -691,7 +765,7 @@
}
if (this.o instanceof ProtoChunkTickList) {
- ((ProtoChunkTickList) this.o).a(this.world.getBlockTickList(), (blockposition1) -> {
+ ((ProtoChunkTickList<Block>) this.o).a(this.world.getBlockTickList(), (blockposition1) -> { // CraftBukkit - decompile error
return this.getType(blockposition1).getBlock();
});
} else if (this.o instanceof TickListChunk) {
@@ -700,7 +774,7 @@
}
if (this.p instanceof ProtoChunkTickList) {
- ((ProtoChunkTickList) this.p).a(this.world.getFluidTickList(), (blockposition1) -> {
+ ((ProtoChunkTickList<FluidType>) this.p).a(this.world.getFluidTickList(), (blockposition1) -> { // CraftBukkit - decompile error
return this.getFluid(blockposition1).getType();
});
} else if (this.p instanceof TickListChunk) {