Merge branch 'master' of github.com:Akarin-project/Paper
This commit is contained in:
@@ -7,6 +7,7 @@ import net.minecraft.server.IAnimal;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.World;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -90,7 +91,8 @@ public class PaperWorldEntityList extends ArrayList<Entity> {
|
||||
}
|
||||
|
||||
public void updateEntityCount(Entity entity, int amt) {
|
||||
if (!(entity instanceof IAnimal)) return;
|
||||
// Only count natural spawns so that mob
|
||||
if (!(entity instanceof IAnimal) || entity.spawnReason != SpawnReason.NATURAL) return;
|
||||
|
||||
if (entity instanceof EntityInsentient) {
|
||||
EntityInsentient entityinsentient = (EntityInsentient) entity;
|
||||
|
||||
@@ -64,6 +64,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
}
|
||||
};
|
||||
List<Entity> entitySlice = null;
|
||||
public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason;
|
||||
// Paper end
|
||||
static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
|
||||
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
||||
@@ -1687,6 +1688,9 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
if (origin != null) {
|
||||
nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ()));
|
||||
}
|
||||
if (spawnReason != null) {
|
||||
nbttagcompound.setString("Paper.SpawnReason", spawnReason.name());
|
||||
}
|
||||
// Save entity's from mob spawner status
|
||||
if (spawnedViaMobSpawner) {
|
||||
nbttagcompound.setBoolean("Paper.FromMobSpawner", true);
|
||||
@@ -1840,6 +1844,26 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
}
|
||||
|
||||
spawnedViaMobSpawner = nbttagcompound.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status
|
||||
if (nbttagcompound.hasKey("Paper.SpawnReason")) {
|
||||
String spawnReasonName = nbttagcompound.getString("Paper.SpawnReason");
|
||||
try {
|
||||
spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.valueOf(spawnReasonName);
|
||||
} catch (Exception ignored) {
|
||||
LogManager.getLogger().error("Unknown SpawnReason " + spawnReasonName + " for " + this);
|
||||
}
|
||||
}
|
||||
if (spawnReason == null) {
|
||||
if (spawnedViaMobSpawner) {
|
||||
spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER;
|
||||
} else if (this instanceof EntityInsentient && this instanceof IAnimal && !((EntityInsentient) this).isTypeNotPersistent()) {
|
||||
if (!nbttagcompound.getBoolean("PersistenceRequired")) {
|
||||
spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (spawnReason == null) {
|
||||
spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.minecraft.server;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutChat implements Packet<PacketListenerPlayOut> {
|
||||
|
||||
private static final int MAX_LENGTH = Short.MAX_VALUE * 8 + 8; // Paper
|
||||
private IChatBaseComponent a;
|
||||
public net.md_5.bungee.api.chat.BaseComponent[] components; // Spigot
|
||||
private ChatMessageType b;
|
||||
@@ -30,9 +30,9 @@ public class PacketPlayOutChat implements Packet<PacketListenerPlayOut> {
|
||||
//packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(components)); // Paper - comment, replaced with below
|
||||
// Paper start - don't nest if we don't need to so that we can preserve formatting
|
||||
if (this.components.length == 1) {
|
||||
packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(this.components[0]));
|
||||
packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(this.components[0]), MAX_LENGTH); // Paper - use proper max length
|
||||
} else {
|
||||
packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(this.components));
|
||||
packetdataserializer.a(net.md_5.bungee.chat.ComponentSerializer.toString(this.components), MAX_LENGTH); // Paper - use proper max length
|
||||
}
|
||||
// Paper end
|
||||
} else {
|
||||
|
||||
@@ -158,7 +158,7 @@ public final class SpawnerCreature {
|
||||
float f1 = (float) l3 + 0.5F;
|
||||
EntityHuman entityhuman1 = worldserver.a((double) f, (double) f1, -1.0D);
|
||||
|
||||
if (entityhuman1 != null) {
|
||||
if (entityhuman1 != null && worldserver.isLoadedAndInBounds(blockposition_mutableblockposition)) { // Paper - don't load chunks for mob spawn
|
||||
double d0 = entityhuman1.d((double) f, (double) k3, (double) f1);
|
||||
|
||||
if (d0 > 576.0D && blockposition.distanceSquared((double) f, (double) k3, (double) f1) >= 576.0D) {
|
||||
@@ -171,7 +171,7 @@ public final class SpawnerCreature {
|
||||
i4 = biomebase_biomemeta.c + worldserver.random.nextInt(1 + biomebase_biomemeta.d - biomebase_biomemeta.c);
|
||||
}
|
||||
|
||||
if (worldserver.isLoadedAndInBounds(blockposition_mutableblockposition) && worldserver.a(enumcreaturetype, biomebase_biomemeta, (BlockPosition) blockposition_mutableblockposition)) { // Paper - don't load chunks for mob spawn
|
||||
if (worldserver.a(enumcreaturetype, biomebase_biomemeta, (BlockPosition) blockposition_mutableblockposition)) {
|
||||
EntityPositionTypes.Surface entitypositiontypes_surface = EntityPositionTypes.a(biomebase_biomemeta.b);
|
||||
if (entitypositiontypes_surface != null && a(entitypositiontypes_surface, worldserver, blockposition_mutableblockposition, biomebase_biomemeta.b)) {
|
||||
EntityInsentient entityinsentient;
|
||||
|
||||
@@ -1089,6 +1089,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
||||
|
||||
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
|
||||
// Paper start
|
||||
if (entity.spawnReason == null) entity.spawnReason = spawnReason;
|
||||
if (regionLimited != null) {
|
||||
return regionLimited.addEntity(entity, spawnReason);
|
||||
}
|
||||
|
||||
@@ -1348,7 +1348,7 @@ public class CraftWorld implements World {
|
||||
height = 9;
|
||||
}
|
||||
|
||||
BlockFace[] faces = new BlockFace[]{BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH};
|
||||
BlockFace[] faces = new BlockFace[]{BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH, BlockFace.UP, BlockFace.DOWN};
|
||||
final BlockPosition pos = new BlockPosition((int) x, (int) y, (int) z);
|
||||
for (BlockFace dir : faces) {
|
||||
IBlockData nmsBlock = world.getType(pos.shift(CraftBlock.blockFaceToNotch(dir)));
|
||||
|
||||
@@ -845,5 +845,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
public boolean fromMobSpawner() {
|
||||
return getHandle().spawnedViaMobSpawner;
|
||||
}
|
||||
|
||||
public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason getEntitySpawnReason() {
|
||||
return getHandle().spawnReason;
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user