178 Zeilen
6.9 KiB
Diff
178 Zeilen
6.9 KiB
Diff
--- a/net/minecraft/server/Chunk.java
|
|
+++ b/net/minecraft/server/Chunk.java
|
|
@@ -22,6 +22,13 @@
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
+// CraftBukkit start
|
|
+import com.google.common.collect.Lists;
|
|
+import java.util.LinkedList;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class Chunk implements IChunkAccess {
|
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
@@ -91,8 +98,19 @@
|
|
}
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
|
|
+ }
|
|
+
|
|
+ public org.bukkit.Chunk bukkitChunk;
|
|
+ public org.bukkit.Chunk getBukkitChunk() {
|
|
+ return bukkitChunk;
|
|
}
|
|
|
|
+ public boolean mustNotSave;
|
|
+ public boolean needsDecoration;
|
|
+ // CraftBukkit end
|
|
+
|
|
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 @@
|
|
|
|
this.b(protochunk.r());
|
|
this.s = true;
|
|
+ this.needsDecoration = true; // CraftBukkit
|
|
}
|
|
|
|
@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);
|
|
+ }
|
|
+
|
|
+ @Nullable
|
|
+ public IBlockData setType(BlockPosition blockposition, IBlockData iblockdata, boolean flag, boolean doPlace) {
|
|
+ // CraftBukkit end
|
|
int i = blockposition.getX() & 15;
|
|
int j = blockposition.getY();
|
|
int k = blockposition.getZ() & 15;
|
|
@@ -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, flag);
|
|
}
|
|
|
|
@@ -378,7 +405,12 @@
|
|
|
|
@Nullable
|
|
public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
|
|
- TileEntity tileentity = (TileEntity) this.tileEntities.get(blockposition);
|
|
+ // CraftBukkit start
|
|
+ TileEntity tileentity = world.capturedTileEntities.get(blockposition);
|
|
+ if (tileentity == null) {
|
|
+ tileentity = (TileEntity) this.tileEntities.get(blockposition);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
|
|
if (tileentity == null) {
|
|
NBTTagCompound nbttagcompound = (NBTTagCompound) this.e.remove(blockposition);
|
|
@@ -425,6 +457,13 @@
|
|
tileentity1.m();
|
|
}
|
|
|
|
+ // 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.loc.x * 16) + "," + (this.loc.z * 16));
|
|
+ new Exception().printStackTrace();
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
|
|
@@ -453,6 +492,41 @@
|
|
|
|
}
|
|
|
|
+ // CraftBukkit start
|
|
+ public void loadCallback() {
|
|
+ org.bukkit.Server server = this.world.getServer();
|
|
+ if (server != null) {
|
|
+ /*
|
|
+ * If it's a new world, the first few chunks are generated inside
|
|
+ * the World constructor. We can't reliably alter that, so we have
|
|
+ * no way of creating a CraftWorld/CraftServer at that point.
|
|
+ */
|
|
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration));
|
|
+
|
|
+ if (this.needsDecoration) {
|
|
+ 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) this.loc.x * xRand + (long) this.loc.z * zRand ^ world.getSeed());
|
|
+
|
|
+ org.bukkit.World world = this.world.getWorld();
|
|
+ if (world != null) {
|
|
+ this.world.populating = true;
|
|
+ try {
|
|
+ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
|
|
+ populator.populate(world, random, bukkitChunk);
|
|
+ }
|
|
+ } finally {
|
|
+ this.world.populating = false;
|
|
+ }
|
|
+ }
|
|
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk));
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
public void markDirty() {
|
|
this.s = true;
|
|
}
|
|
@@ -527,7 +601,7 @@
|
|
Iterator iterator = this.entitySlices[k].a(oclass).iterator();
|
|
|
|
while (iterator.hasNext()) {
|
|
- T t0 = (Entity) iterator.next();
|
|
+ T t0 = (T) iterator.next(); // CraftBukkit - decompile error
|
|
|
|
if (t0.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(t0))) {
|
|
list.add(t0);
|
|
@@ -601,7 +675,7 @@
|
|
|
|
@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
|
|
}
|
|
|
|
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) {
|