3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 14:50:08 +01:00
Paper/nms-patches/World.patch

585 Zeilen
23 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/World.java
+++ b/net/minecraft/server/World.java
2018-12-25 22:00:00 +01:00
@@ -18,6 +18,22 @@
2018-07-15 02:00:00 +02:00
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import com.google.common.collect.Maps;
2018-12-25 22:00:00 +01:00
+import java.util.ArrayList;
+import java.util.Map;
+import org.bukkit.Bukkit;
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
2018-07-15 02:00:00 +02:00
+import org.bukkit.craftbukkit.block.CraftBlockState;
+import org.bukkit.craftbukkit.block.data.CraftBlockData;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.block.BlockPhysicsEvent;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
2016-02-29 22:32:46 +01:00
+import org.bukkit.generator.ChunkGenerator;
+// CraftBukkit end
+
2018-08-26 04:00:00 +02:00
public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAccess, AutoCloseable {
2018-07-15 02:00:00 +02:00
protected static final Logger e = LogManager.getLogger();
2018-12-25 22:00:00 +01:00
@@ -59,7 +75,52 @@
2018-07-15 02:00:00 +02:00
private final WorldBorder K;
2018-08-26 04:00:00 +02:00
int[] E;
2018-08-26 04:00:00 +02:00
- protected World(IDataManager idatamanager, @Nullable PersistentCollection persistentcollection, WorldData worlddata, WorldProvider worldprovider, MethodProfiler methodprofiler, boolean flag) {
+ // CraftBukkit start Added the following
+ private final CraftWorld world;
+ public boolean pvpMode;
+ public boolean keepSpawnInMemory = true;
+ public ChunkGenerator generator;
+
+ public boolean captureBlockStates = false;
+ public boolean captureTreeGeneration = false;
2018-07-15 02:00:00 +02:00
+ public ArrayList<CraftBlockState> capturedBlockStates = new ArrayList<CraftBlockState>() {
+ @Override
2018-07-15 02:00:00 +02:00
+ public boolean add(CraftBlockState blockState) {
+ Iterator<CraftBlockState> blockStateIterator = this.iterator();
+ while (blockStateIterator.hasNext()) {
+ BlockState blockState1 = blockStateIterator.next();
2018-07-15 02:00:00 +02:00
+ if (blockState1.getLocation().equals(blockState.getLocation())) {
2014-11-29 22:17:57 +01:00
+ return false;
+ }
+ }
+
2018-07-15 02:00:00 +02:00
+ return super.add(blockState);
+ }
+ };
+ public List<EntityItem> captureDrops;
+ public long ticksPerAnimalSpawns;
+ public long ticksPerMonsterSpawns;
+ public boolean populating;
+ private int tickPosition;
+
+ public CraftWorld getWorld() {
+ return this.world;
+ }
+
+ public CraftServer getServer() {
+ return (CraftServer) Bukkit.getServer();
+ }
+
+ public Chunk getChunkIfLoaded(int x, int z) {
2018-08-26 04:00:00 +02:00
+ return ((ChunkProviderServer) this.chunkProvider).getChunkAt(x, z, false, false);
+ }
+
2018-08-26 04:00:00 +02:00
+ protected World(IDataManager idatamanager, @Nullable PersistentCollection persistentcollection, WorldData worlddata, WorldProvider worldprovider, MethodProfiler methodprofiler, boolean flag, ChunkGenerator gen, org.bukkit.World.Environment env) {
+ this.generator = gen;
+ this.world = new CraftWorld((WorldServer) this, gen, env);
+ this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
+ this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
this.v = Lists.newArrayList(new IWorldAccess[] { this.u});
this.allowMonsters = true;
this.allowAnimals = true;
2018-12-25 22:00:00 +01:00
@@ -71,6 +132,36 @@
this.worldProvider = worldprovider;
2015-02-26 23:41:06 +01:00
this.isClientSide = flag;
2018-07-15 02:00:00 +02:00
this.K = worldprovider.getWorldBorder();
2016-03-01 01:20:42 +01:00
+ // CraftBukkit start
+ getWorldBorder().world = (WorldServer) this;
+ // From PlayerList.setPlayerFileData
+ getWorldBorder().a(new IWorldBorderListener() {
+ public void a(WorldBorder worldborder, double d0) {
+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE), worldborder.world);
+ }
+
+ public void a(WorldBorder worldborder, double d0, double d1, long i) {
+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE), worldborder.world);
+ }
+
+ public void a(WorldBorder worldborder, double d0, double d1) {
+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER), worldborder.world);
+ }
+
+ public void a(WorldBorder worldborder, int i) {
+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME), worldborder.world);
+ }
+
+ public void b(WorldBorder worldborder, int i) {
+ getServer().getHandle().sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS), worldborder.world);
+ }
+
+ public void b(WorldBorder worldborder, double d0) {}
+
+ public void c(WorldBorder worldborder, double d0) {}
+ });
2016-03-01 01:20:42 +01:00
+ this.getServer().addWorld(this.world);
+ // CraftBukkit end
}
2018-08-26 04:00:00 +02:00
public BiomeBase getBiome(BlockPosition blockposition) {
2018-12-25 22:00:00 +01:00
@@ -145,6 +236,26 @@
}
public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) {
+ // CraftBukkit start - tree generation
+ if (this.captureTreeGeneration) {
2018-07-15 02:00:00 +02:00
+ CraftBlockState blockstate = null;
+ Iterator<CraftBlockState> it = capturedBlockStates.iterator();
+ while (it.hasNext()) {
2018-07-15 02:00:00 +02:00
+ CraftBlockState previous = it.next();
+ if (previous.getPosition().equals(blockposition)) {
+ blockstate = previous;
+ it.remove();
+ break;
+ }
+ }
+ if (blockstate == null) {
2018-07-15 02:00:00 +02:00
+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, blockposition, i);
+ }
2018-07-15 02:00:00 +02:00
+ blockstate.setData(iblockdata);
+ this.capturedBlockStates.add(blockstate);
+ return true;
+ }
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
if (k(blockposition)) {
return false;
2015-02-26 23:41:06 +01:00
} else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) {
2018-12-25 22:00:00 +01:00
@@ -152,9 +263,23 @@
} else {
Chunk chunk = this.getChunkAtWorldCoords(blockposition);
Block block = iblockdata.getBlock();
2018-10-22 21:00:00 +02:00
- IBlockData iblockdata1 = chunk.setType(blockposition, iblockdata, (i & 64) != 0);
2015-02-26 23:41:06 +01:00
+
+ // CraftBukkit start - capture blockstates
2018-07-15 02:00:00 +02:00
+ CraftBlockState blockstate = null;
+ if (this.captureBlockStates) {
2018-07-15 02:00:00 +02:00
+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, blockposition, i);
+ this.capturedBlockStates.add(blockstate);
+ }
+ // CraftBukkit end
2015-02-26 23:41:06 +01:00
+
2018-10-22 21:00:00 +02:00
+ IBlockData iblockdata1 = chunk.setType(blockposition, iblockdata, (i & 64) != 0, (i & 1024) == 0); // CraftBukkit custom NO_PLACE flag
if (iblockdata1 == null) {
+ // CraftBukkit start - remove blockstate if failed
2014-11-29 22:17:57 +01:00
+ if (this.captureBlockStates) {
+ this.capturedBlockStates.remove(blockstate);
+ }
+ // CraftBukkit end
return false;
} else {
2018-07-15 02:00:00 +02:00
IBlockData iblockdata2 = this.getType(blockposition);
2018-12-25 22:00:00 +01:00
@@ -165,6 +290,7 @@
2018-12-13 01:00:00 +01:00
this.methodProfiler.exit();
}
+ /*
2018-07-15 02:00:00 +02:00
if (iblockdata2 == iblockdata) {
if (iblockdata1 != iblockdata2) {
this.a(blockposition, blockposition);
2018-12-25 22:00:00 +01:00
@@ -189,12 +315,63 @@
2018-07-15 02:00:00 +02:00
iblockdata.b(this, blockposition, j);
}
}
+ */
+
+ // CraftBukkit start
+ if (!this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates
+ // Modularize client and physic updates
2018-07-15 02:00:00 +02:00
+ notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, iblockdata2, i);
+ }
+ // CraftBukkit end
return true;
}
}
}
2016-11-17 02:41:03 +01:00
+ // CraftBukkit start - Split off from above in order to directly send client and physic updates
2018-07-15 02:00:00 +02:00
+ public void notifyAndUpdatePhysics(BlockPosition blockposition, Chunk chunk, IBlockData oldBlock, IBlockData newBlock, IBlockData actualBlock, int i) {
+ IBlockData iblockdata = newBlock;
+ IBlockData iblockdata1 = oldBlock;
+ IBlockData iblockdata2 = actualBlock;
+ if (iblockdata2 == iblockdata) {
+ if (iblockdata1 != iblockdata2) {
+ this.a(blockposition, blockposition);
+ }
+
2018-07-15 02:00:00 +02:00
+ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (chunk == null || chunk.isReady())) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement
+ this.notify(blockposition, iblockdata1, iblockdata, i);
+ }
+
+ if (!this.isClientSide && (i & 1) != 0) {
+ this.update(blockposition, iblockdata1.getBlock());
+ if (iblockdata.isComplexRedstone()) {
+ this.updateAdjacentComparators(blockposition, newBlock.getBlock());
+ }
+ }
+
+ if ((i & 16) == 0) {
+ int j = i & -2;
+
+ // CraftBukkit start
+ iblockdata1.b(this, blockposition, j); // Don't call an event for the old block to limit event spam
+ CraftWorld world = ((WorldServer) this).getWorld();
+ if (world != null) {
+ BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata));
+ this.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ }
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
+ iblockdata.a((GeneratorAccess) this, blockposition, j);
+ iblockdata.b(this, blockposition, j);
+ }
+ }
+ }
+ // CraftBukkit end
+
public boolean setAir(BlockPosition blockposition) {
2018-12-06 00:00:00 +01:00
Fluid fluid = this.getFluid(blockposition);
2018-07-15 02:00:00 +02:00
2018-12-25 22:00:00 +01:00
@@ -231,6 +408,11 @@
2018-07-15 02:00:00 +02:00
public void update(BlockPosition blockposition, Block block) {
if (this.worldData.getType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
+ // CraftBukkit start
+ if (populating) {
+ return;
+ }
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
this.applyPhysics(blockposition, block);
}
2018-12-25 22:00:00 +01:00
@@ -306,6 +488,17 @@
IBlockData iblockdata = this.getType(blockposition);
try {
+ // CraftBukkit start
+ CraftWorld world = ((WorldServer) this).getWorld();
+ if (world != null) {
+ BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata), world.getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()));
+ this.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ }
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
iblockdata.doPhysics(this, blockposition, block, blockposition1);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Exception while updating neighbours");
2018-12-25 22:00:00 +01:00
@@ -400,6 +593,17 @@
}
public IBlockData getType(BlockPosition blockposition) {
+ // CraftBukkit start - tree generation
+ if (captureTreeGeneration) {
2018-07-15 02:00:00 +02:00
+ Iterator<CraftBlockState> it = capturedBlockStates.iterator();
+ while (it.hasNext()) {
2018-07-15 02:00:00 +02:00
+ CraftBlockState previous = it.next();
+ if (previous.getPosition().equals(blockposition)) {
2018-07-15 02:00:00 +02:00
+ return previous.getHandle();
+ }
+ }
+ }
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
if (k(blockposition)) {
return Blocks.VOID_AIR.getBlockData();
} else {
2018-12-25 22:00:00 +01:00
@@ -646,6 +850,16 @@
}
public boolean addEntity(Entity entity) {
+ // CraftBukkit start - Used for entities other than creatures
+ return addEntity(entity, SpawnReason.DEFAULT);
+ }
+
+ public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
+ if (!CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) {
+ return false;
+ }
+ // CraftBukkit end
+
int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.floor(entity.locZ / 16.0D);
boolean flag = entity.attachedToPlayer;
2018-12-25 22:00:00 +01:00
@@ -676,6 +890,7 @@
2018-07-15 02:00:00 +02:00
((IWorldAccess) this.v.get(i)).a(entity);
}
+ entity.valid = true; // CraftBukkit
}
2016-02-29 22:32:46 +01:00
protected void c(Entity entity) {
2018-12-25 22:00:00 +01:00
@@ -683,6 +898,7 @@
2018-07-15 02:00:00 +02:00
((IWorldAccess) this.v.get(i)).b(entity);
}
+ entity.valid = false; // CraftBukkit
}
public void kill(Entity entity) {
2018-12-25 22:00:00 +01:00
@@ -718,7 +934,15 @@
this.getChunkAt(i, j).b(entity);
}
- this.entityList.remove(entity);
+ // CraftBukkit start - Decrement loop variable field if we've already ticked this entity
+ int index = this.entityList.indexOf(entity);
+ if (index != -1) {
+ if (index <= this.tickPosition) {
+ this.tickPosition--;
+ }
+ this.entityList.remove(index);
+ }
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
this.c(entity);
}
2018-12-25 22:00:00 +01:00
@@ -753,6 +977,11 @@
2016-12-20 21:00:00 +01:00
2018-07-15 02:00:00 +02:00
for (i = 0; i < this.k.size(); ++i) {
entity = (Entity) this.k.get(i);
+ // CraftBukkit start - Fixed an NPE
+ if (entity == null) {
+ continue;
+ }
+ // CraftBukkit end
try {
++entity.ticksLived;
2018-12-25 22:00:00 +01:00
@@ -801,8 +1030,10 @@
2016-02-29 22:32:46 +01:00
CrashReport crashreport1;
2018-12-06 00:00:00 +01:00
CrashReportSystemDetails crashreportsystemdetails1;
- for (i = 0; i < this.entityList.size(); ++i) {
- entity = (Entity) this.entityList.get(i);
+ // CraftBukkit start - Use field for loop variable
+ for (this.tickPosition = 0; this.tickPosition < this.entityList.size(); ++this.tickPosition) {
+ entity = (Entity) this.entityList.get(this.tickPosition);
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
Entity entity1 = entity.getVehicle();
2016-02-29 22:32:46 +01:00
if (entity1 != null) {
2018-12-25 22:00:00 +01:00
@@ -835,7 +1066,7 @@
2016-02-29 22:32:46 +01:00
this.getChunkAt(j, l).b(entity);
}
- this.entityList.remove(i--);
+ this.entityList.remove(this.tickPosition--); // CraftBukkit - Use field for loop variable
2016-02-29 22:32:46 +01:00
this.c(entity);
}
2018-12-25 22:00:00 +01:00
@@ -890,9 +1121,11 @@
2018-07-15 02:00:00 +02:00
TileEntity tileentity1 = (TileEntity) this.c.get(i1);
2018-07-15 02:00:00 +02:00
if (!tileentity1.x()) {
+ /* CraftBukkit start - Order matters, moved down
2016-02-29 22:32:46 +01:00
if (!this.tileEntityList.contains(tileentity1)) {
this.a(tileentity1);
}
+ // CraftBukkit end */
if (this.isLoaded(tileentity1.getPosition())) {
2016-02-29 22:32:46 +01:00
Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition());
2018-12-25 22:00:00 +01:00
@@ -900,6 +1133,12 @@
chunk.a(tileentity1.getPosition(), tileentity1);
this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3);
+ // CraftBukkit start
+ // From above, don't screw this up - SPIGOT-1746
+ if (!this.tileEntityList.contains(tileentity1)) {
+ this.a(tileentity1);
+ }
+ // CraftBukkit end
}
}
}
2018-12-25 22:00:00 +01:00
@@ -953,15 +1192,13 @@
2017-05-30 13:25:59 +02:00
int i;
int j;
- if (!(entity instanceof EntityHuman)) {
- i = MathHelper.floor(entity.locX);
- j = MathHelper.floor(entity.locZ);
- boolean flag1 = true;
-
- if (flag && !this.isAreaLoaded(i - 32, 0, j - 32, i + 32, 0, j + 32, true)) {
- return;
- }
+ // CraftBukkit start - check if chunks are loaded as done in previous versions
2017-05-30 13:25:59 +02:00
+ // TODO: Go back to Vanilla behaviour when comfortable
+ Chunk startingChunk = this.getChunkIfLoaded(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4);
+ if (flag && !(startingChunk != null && startingChunk.areNeighborsLoaded(2))) {
+ return;
2017-05-30 13:25:59 +02:00
}
+ // CraftBukkit end
2017-05-30 13:25:59 +02:00
2018-07-15 02:00:00 +02:00
entity.N = entity.locX;
entity.O = entity.locY;
2018-12-25 22:00:00 +01:00
@@ -977,6 +1214,7 @@
2018-08-26 04:00:00 +02:00
return IRegistry.ENTITY_TYPE.getKey(entity.P()).toString();
2018-07-22 04:00:00 +02:00
});
2018-07-15 02:00:00 +02:00
entity.tick();
2017-05-19 13:00:13 +02:00
+ entity.postTick(); // CraftBukkit
2018-12-13 01:00:00 +01:00
this.methodProfiler.exit();
}
2017-05-19 13:00:13 +02:00
}
2018-12-25 22:00:00 +01:00
@@ -1307,11 +1545,18 @@
}
}
+ public Map<BlockPosition, TileEntity> capturedTileEntities = Maps.newHashMap();
2016-05-10 13:47:39 +02:00
@Nullable
public TileEntity getTileEntity(BlockPosition blockposition) {
2018-07-15 02:00:00 +02:00
if (k(blockposition)) {
return null;
} else {
+ // CraftBukkit start
+ if (capturedTileEntities.containsKey(blockposition)) {
+ return capturedTileEntities.get(blockposition);
+ }
+ // CraftBukkit end
+
TileEntity tileentity = null;
2018-07-15 02:00:00 +02:00
if (this.J) {
2018-12-25 22:00:00 +01:00
@@ -1346,6 +1591,14 @@
2016-05-10 13:47:39 +02:00
public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) {
2018-07-15 02:00:00 +02:00
if (!k(blockposition)) {
if (tileentity != null && !tileentity.x()) {
+ // CraftBukkit start
+ if (captureBlockStates) {
+ tileentity.setWorld(this);
+ tileentity.setPosition(blockposition);
+ capturedTileEntities.put(blockposition, tileentity);
+ return;
+ }
+ // CraftBukkit end
if (this.J) {
2016-06-09 03:43:49 +02:00
tileentity.setPosition(blockposition);
2018-07-15 02:00:00 +02:00
Iterator iterator = this.c.iterator();
2018-12-25 22:00:00 +01:00
@@ -1506,6 +1759,14 @@
}
2018-07-15 02:00:00 +02:00
this.p = MathHelper.a(this.p, 0.0F, 1.0F);
2015-02-26 23:41:06 +01:00
+
+ // CraftBukkit start
+ for (int idx = 0; idx < this.players.size(); ++idx) {
+ if (((EntityPlayer) this.players.get(idx)).world == this) {
+ ((EntityPlayer) this.players.get(idx)).tickWeather();
+ }
+ }
2015-02-26 23:41:06 +01:00
+ // CraftBukkit end
}
}
}
2018-12-25 22:00:00 +01:00
@@ -1591,7 +1852,10 @@
}
public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) {
- if (!this.areChunksLoaded(blockposition, 17, false)) {
+ // CraftBukkit start - Use neighbor cache instead of looking up
+ Chunk chunk = this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4);
+ if (chunk == null || !chunk.areNeighborsLoaded(1) /*!this.areChunksLoaded(blockposition, 17, false)*/) {
+ // CraftBukkit end
return false;
} else {
int i = 0;
2018-12-25 22:00:00 +01:00
@@ -1734,7 +1998,7 @@
2018-08-26 04:00:00 +02:00
}
public Stream<VoxelShape> a(@Nullable Entity entity, VoxelShape voxelshape, VoxelShape voxelshape1, Set<Entity> set) {
2018-12-25 22:00:00 +01:00
- Stream<VoxelShape> stream = GeneratorAccess.super.a(entity, voxelshape, voxelshape1, set);
+ Stream<VoxelShape> stream = IIBlockAccess.super.a(entity, voxelshape, voxelshape1, set); // CraftBukkit - decompile error
2018-08-26 04:00:00 +02:00
return entity == null ? stream : Stream.concat(stream, this.a(entity, voxelshape, set));
}
2018-12-25 22:00:00 +01:00
@@ -1764,8 +2028,8 @@
2015-02-26 23:41:06 +01:00
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
2018-07-15 02:00:00 +02:00
- if (oclass.isAssignableFrom(entity.getClass()) && predicate.test(entity)) {
2018-12-25 22:00:00 +01:00
- list.add(entity);
+ if (oclass.isAssignableFrom(entity.getClass()) && predicate.test((T) entity)) { // CraftBukkit - decompile error
+ list.add((T) entity); // CraftBukkit - decompile error
2015-02-26 23:41:06 +01:00
}
}
2018-12-25 22:00:00 +01:00
@@ -1779,8 +2043,8 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
2015-02-26 23:41:06 +01:00
2018-07-15 02:00:00 +02:00
- if (oclass.isAssignableFrom(entity.getClass()) && predicate.test(entity)) {
2018-12-25 22:00:00 +01:00
- list.add(entity);
+ if (oclass.isAssignableFrom(entity.getClass()) && predicate.test((T) entity)) { // CraftBukkit - decompile error
+ list.add((T) entity); // CraftBukkit - decompile error
2015-02-26 23:41:06 +01:00
}
}
2018-12-25 22:00:00 +01:00
@@ -1816,7 +2080,7 @@
double d0 = Double.MAX_VALUE;
2015-02-26 23:41:06 +01:00
2018-12-25 22:00:00 +01:00
for (int i = 0; i < list.size(); ++i) {
- T t2 = (Entity) list.get(i);
+ T t2 = (T) list.get(i); // CraftBukkit - decompile error
if (t2 != t0 && IEntitySelector.f.test(t2)) {
double d1 = t0.h(t2);
@@ -1849,8 +2113,16 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
+ // CraftBukkit start - Split out persistent check, don't apply it to special persistent mobs
+ if (entity instanceof EntityInsentient) {
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
+ if (entityinsentient.isTypeNotPersistent() && entityinsentient.isPersistent()) {
+ continue;
+ }
+ }
- if (!(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) {
+ if (true || !(entity instanceof EntityInsentient) || !((EntityInsentient) entity).isPersistent()) {
+ // CraftBukkit end
if (oclass.isAssignableFrom(entity.getClass())) {
++j;
}
2018-12-25 22:00:00 +01:00
@@ -1969,6 +2241,11 @@
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
+ // CraftBukkit start - Fixed an NPE
+ if (entityhuman1 == null || entityhuman1.dead) {
+ continue;
+ }
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
if (predicate.test(entityhuman1)) {
2016-11-17 02:41:03 +01:00
double d5 = entityhuman1.d(d0, d1, d2);
2018-12-25 22:00:00 +01:00
@@ -2182,6 +2459,16 @@
public void everyoneSleeping() {}
+ // CraftBukkit start
+ // Calls the method that checks to see if players are sleeping
+ // Called by CraftPlayer.setPermanentSleeping()
+ public void checkSleepStatus() {
2015-02-26 23:41:06 +01:00
+ if (!this.isClientSide) {
+ this.everyoneSleeping();
+ }
+ }
+ // CraftBukkit end
+
2018-07-15 02:00:00 +02:00
public float g(float f) {
return (this.q + (this.r - this.q) * f) * this.i(f);
}
2018-12-25 22:00:00 +01:00
@@ -2343,7 +2630,7 @@
int l = j * 16 + 8 - blockposition.getZ();
2016-06-09 03:43:49 +02:00
boolean flag = true;
2016-06-09 03:43:49 +02:00
- return k >= -128 && k <= 128 && l >= -128 && l <= 128;
+ return k >= -128 && k <= 128 && l >= -128 && l <= 128 && this.keepSpawnInMemory; // CraftBukkit - Added 'this.keepSpawnInMemory'
}
2016-02-29 22:32:46 +01:00
2018-08-26 04:00:00 +02:00
public LongSet ag() {