mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 12:42:05 -07:00
SPIGOT-227: Add entity persistent flag
Non-persistent entities won't get saved when the chunk saves the entities. Entities that are passengers of a non-persistent entity won't get saved. Players won't save their vehicle, if the player is directly or indirectly riding a non-persistent entity.
This commit is contained in:
@@ -55,11 +55,12 @@
|
||||
protected static final Logger i = LogManager.getLogger();
|
||||
private static final List<ItemStack> a = Collections.emptyList();
|
||||
private static final AxisAlignedBB b = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
|
||||
@@ -107,6 +153,15 @@
|
||||
@@ -107,6 +153,16 @@
|
||||
private boolean aK;
|
||||
private final double[] aL;
|
||||
private long aM;
|
||||
+ // CraftBukkit start
|
||||
+ public boolean persist = true;
|
||||
+ public boolean valid;
|
||||
+ public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
|
||||
+ public boolean forceExplosionKnockback; // SPIGOT-949
|
||||
@@ -71,7 +72,7 @@
|
||||
|
||||
public Entity(EntityTypes<?> entitytypes, World world) {
|
||||
this.id = Entity.entityCount++;
|
||||
@@ -212,6 +267,33 @@
|
||||
@@ -212,6 +268,33 @@
|
||||
}
|
||||
|
||||
protected void setYawPitch(float f, float f1) {
|
||||
@@ -105,7 +106,7 @@
|
||||
this.yaw = f % 360.0F;
|
||||
this.pitch = f1 % 360.0F;
|
||||
}
|
||||
@@ -234,6 +316,51 @@
|
||||
@@ -234,6 +317,51 @@
|
||||
this.W();
|
||||
}
|
||||
|
||||
@@ -157,7 +158,7 @@
|
||||
public void W() {
|
||||
this.world.methodProfiler.a("entityBaseTick");
|
||||
if (this.isPassenger() && this.getVehicle().dead) {
|
||||
@@ -250,6 +377,8 @@
|
||||
@@ -250,6 +378,8 @@
|
||||
this.lastZ = this.locZ;
|
||||
this.lastPitch = this.pitch;
|
||||
this.lastYaw = this.yaw;
|
||||
@@ -166,7 +167,7 @@
|
||||
if (!this.world.isClientSide && this.world instanceof WorldServer) {
|
||||
this.world.methodProfiler.a("portal");
|
||||
if (this.an) {
|
||||
@@ -289,6 +418,7 @@
|
||||
@@ -289,6 +419,7 @@
|
||||
this.E();
|
||||
this.world.methodProfiler.e();
|
||||
}
|
||||
@@ -174,7 +175,7 @@
|
||||
|
||||
this.av();
|
||||
this.r();
|
||||
@@ -340,6 +470,27 @@
|
||||
@@ -340,6 +471,27 @@
|
||||
protected void burnFromLava() {
|
||||
if (!this.fireProof) {
|
||||
this.damageEntity(DamageSource.LAVA, 4.0F);
|
||||
@@ -202,7 +203,7 @@
|
||||
this.setOnFire(15);
|
||||
}
|
||||
}
|
||||
@@ -505,7 +656,7 @@
|
||||
@@ -505,7 +657,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +212,7 @@
|
||||
double d11;
|
||||
|
||||
if (this.Q > 0.0F && flag && (d7 != d0 || d9 != d2)) {
|
||||
@@ -592,7 +743,7 @@
|
||||
@@ -592,7 +744,7 @@
|
||||
this.world.methodProfiler.a("rest");
|
||||
this.recalcPosition();
|
||||
this.positionChanged = d7 != d0 || d9 != d2;
|
||||
@@ -220,7 +221,7 @@
|
||||
this.onGround = this.C && d8 < 0.0D;
|
||||
this.D = this.positionChanged || this.C;
|
||||
int k = MathHelper.floor(this.locX);
|
||||
@@ -627,6 +778,28 @@
|
||||
@@ -627,6 +779,28 @@
|
||||
block1.a((IBlockAccess) this.world, this);
|
||||
}
|
||||
|
||||
@@ -249,7 +250,7 @@
|
||||
if (this.playStepSound() && (!this.onGround || !this.isSneaking() || !(this instanceof EntityHuman)) && !this.isPassenger()) {
|
||||
double d22 = this.locX - d4;
|
||||
double d23 = this.locY - d5;
|
||||
@@ -679,7 +852,14 @@
|
||||
@@ -679,7 +853,14 @@
|
||||
if (!flag1) {
|
||||
++this.fireTicks;
|
||||
if (this.fireTicks == 0) {
|
||||
@@ -265,7 +266,7 @@
|
||||
}
|
||||
}
|
||||
} else if (this.fireTicks <= 0) {
|
||||
@@ -875,7 +1055,7 @@
|
||||
@@ -875,7 +1056,7 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -274,7 +275,7 @@
|
||||
if (!this.fireProof) {
|
||||
this.damageEntity(DamageSource.FIRE, (float) i);
|
||||
}
|
||||
@@ -1094,6 +1274,13 @@
|
||||
@@ -1094,6 +1275,13 @@
|
||||
}
|
||||
|
||||
public void spawnIn(World world) {
|
||||
@@ -288,7 +289,15 @@
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@@ -1318,6 +1505,18 @@
|
||||
@@ -1311,13 +1499,25 @@
|
||||
}
|
||||
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
- return this.isPassenger() ? false : this.c(nbttagcompound);
|
||||
+ return !this.persist || this.isPassenger() ? false : this.c(nbttagcompound); // CraftBukkit - persist flag
|
||||
}
|
||||
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
try {
|
||||
nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY, this.locZ}));
|
||||
nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ}));
|
||||
@@ -307,7 +316,7 @@
|
||||
nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch}));
|
||||
nbttagcompound.setFloat("FallDistance", this.fallDistance);
|
||||
nbttagcompound.setShort("Fire", (short) this.fireTicks);
|
||||
@@ -1327,6 +1526,12 @@
|
||||
@@ -1327,6 +1527,12 @@
|
||||
nbttagcompound.setBoolean("Invulnerable", this.invulnerable);
|
||||
nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
|
||||
nbttagcompound.a("UUID", this.getUniqueID());
|
||||
@@ -320,7 +329,7 @@
|
||||
IChatBaseComponent ichatbasecomponent = this.getCustomName();
|
||||
|
||||
if (ichatbasecomponent != null) {
|
||||
@@ -1403,6 +1608,8 @@
|
||||
@@ -1403,6 +1609,8 @@
|
||||
this.motX = nbttaglist1.k(0);
|
||||
this.motY = nbttaglist1.k(1);
|
||||
this.motZ = nbttaglist1.k(2);
|
||||
@@ -329,7 +338,7 @@
|
||||
if (Math.abs(this.motX) > 10.0D) {
|
||||
this.motX = 0.0D;
|
||||
}
|
||||
@@ -1414,6 +1621,7 @@
|
||||
@@ -1414,6 +1622,7 @@
|
||||
if (Math.abs(this.motZ) > 10.0D) {
|
||||
this.motZ = 0.0D;
|
||||
}
|
||||
@@ -337,7 +346,7 @@
|
||||
|
||||
this.locX = nbttaglist.k(0);
|
||||
this.locY = nbttaglist.k(1);
|
||||
@@ -1470,6 +1678,57 @@
|
||||
@@ -1470,6 +1679,57 @@
|
||||
this.setPosition(this.locX, this.locY, this.locZ);
|
||||
}
|
||||
|
||||
@@ -395,7 +404,7 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
|
||||
@@ -1543,6 +1802,12 @@
|
||||
@@ -1543,6 +1803,12 @@
|
||||
if (itemstack.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -408,7 +417,7 @@
|
||||
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
|
||||
|
||||
entityitem.n();
|
||||
@@ -1678,7 +1943,7 @@
|
||||
@@ -1678,7 +1944,7 @@
|
||||
Entity entity = this.ax;
|
||||
|
||||
this.ax = null;
|
||||
@@ -417,7 +426,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1687,6 +1952,24 @@
|
||||
@@ -1687,6 +1953,24 @@
|
||||
if (entity.getVehicle() != this) {
|
||||
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
|
||||
} else {
|
||||
@@ -442,7 +451,7 @@
|
||||
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.bO() instanceof EntityHuman)) {
|
||||
this.passengers.add(0, entity);
|
||||
} else {
|
||||
@@ -1696,13 +1979,30 @@
|
||||
@@ -1696,13 +1980,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +483,7 @@
|
||||
}
|
||||
|
||||
protected boolean q(Entity entity) {
|
||||
@@ -1799,6 +2099,13 @@
|
||||
@@ -1799,6 +2100,13 @@
|
||||
}
|
||||
|
||||
public void setSwimming(boolean flag) {
|
||||
@@ -488,7 +497,7 @@
|
||||
this.setFlag(4, flag);
|
||||
}
|
||||
|
||||
@@ -1859,14 +2166,49 @@
|
||||
@@ -1859,14 +2167,49 @@
|
||||
}
|
||||
|
||||
public void setAirTicks(int i) {
|
||||
@@ -541,7 +550,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2035,19 +2377,76 @@
|
||||
@@ -2035,19 +2378,76 @@
|
||||
if (!this.world.isClientSide && !this.dead) {
|
||||
this.world.methodProfiler.a("changeDimension");
|
||||
MinecraftServer minecraftserver = this.bK();
|
||||
@@ -621,7 +630,7 @@
|
||||
BlockPosition blockposition;
|
||||
|
||||
if (i == 1) {
|
||||
@@ -2076,12 +2475,18 @@
|
||||
@@ -2076,12 +2476,18 @@
|
||||
blockposition = new BlockPosition(this);
|
||||
}
|
||||
|
||||
@@ -641,7 +650,7 @@
|
||||
if (j == 1 && i == 1) {
|
||||
BlockPosition blockposition1 = worldserver1.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver1.getSpawn());
|
||||
|
||||
@@ -2089,6 +2494,7 @@
|
||||
@@ -2089,6 +2495,7 @@
|
||||
} else {
|
||||
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
|
||||
}
|
||||
@@ -649,7 +658,7 @@
|
||||
|
||||
boolean flag = entity.attachedToPlayer;
|
||||
|
||||
@@ -2096,13 +2502,21 @@
|
||||
@@ -2096,13 +2503,21 @@
|
||||
worldserver1.addEntity(entity);
|
||||
entity.attachedToPlayer = flag;
|
||||
worldserver1.entityJoinedWorld(entity, false);
|
||||
@@ -672,7 +681,7 @@
|
||||
return entity;
|
||||
} else {
|
||||
return null;
|
||||
@@ -2242,7 +2656,26 @@
|
||||
@@ -2242,7 +2657,26 @@
|
||||
}
|
||||
|
||||
public void a(AxisAlignedBB axisalignedbb) {
|
||||
|
Reference in New Issue
Block a user