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.

By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
CraftBukkit/Spigot 2018-06-14 19:59:21 +02:00
parent 888b0dc31b
commit 94950beea7
3 changed files with 109 additions and 67 deletions

View file

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

View file

@ -51,7 +51,7 @@
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) { public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
super((World) worldserver, gameprofile); super((World) worldserver, gameprofile);
playerinteractmanager.player = this; playerinteractmanager.player = this;
@@ -65,7 +96,49 @@ @@ -65,8 +96,50 @@
this.cg = minecraftserver.getPlayerList().h(this); this.cg = minecraftserver.getPlayerList().h(this);
this.Q = 1.0F; this.Q = 1.0F;
this.a(worldserver); this.a(worldserver);
@ -60,8 +60,8 @@
+ this.displayName = this.getName(); + this.displayName = this.getName();
+ this.canPickUpLoot = true; + this.canPickUpLoot = true;
+ this.maxHealthCache = this.getMaxHealth(); + this.maxHealthCache = this.getMaxHealth();
+ } }
+
+ // Yes, this doesn't match Vanilla, but it's the best we can do for now. + // Yes, this doesn't match Vanilla, but it's the best we can do for now.
+ // If this is an issue, PRs are welcome + // If this is an issue, PRs are welcome
+ public final BlockPosition getSpawnPoint(WorldServer worldserver) { + public final BlockPosition getSpawnPoint(WorldServer worldserver) {
@ -96,11 +96,12 @@
+ } + }
+ +
+ return blockposition; + return blockposition;
} + }
+ // CraftBukkit end + // CraftBukkit end
+
private void a(WorldServer worldserver) { private void a(WorldServer worldserver) {
BlockPosition blockposition = worldserver.getSpawn(); BlockPosition blockposition = worldserver.getSpawn();
@@ -133,6 +206,7 @@ @@ -133,6 +206,7 @@
if (nbttagcompound.hasKeyOfType("recipeBook", 10)) { if (nbttagcompound.hasKeyOfType("recipeBook", 10)) {
this.cz.a(nbttagcompound.getCompound("recipeBook")); this.cz.a(nbttagcompound.getCompound("recipeBook"));
@ -109,7 +110,29 @@
} }
@@ -163,8 +237,34 @@ @@ -152,7 +226,20 @@
Entity entity = this.getRootVehicle();
Entity entity1 = this.getVehicle();
- if (entity1 != null && entity != this && entity.bR()) {
+ // CraftBukkit start - handle non-persistent vehicles
+ boolean persistVehicle = true;
+ if (entity1 != null) {
+ Entity vehicle;
+ for (vehicle = entity1; vehicle != null; vehicle = vehicle.getVehicle()) {
+ if (!vehicle.persist) {
+ persistVehicle = false;
+ break;
+ }
+ }
+ }
+
+ if (persistVehicle && entity1 != null && entity != this && entity.bR()) {
+ // CraftBukkit end
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
@@ -163,8 +250,34 @@
} }
nbttagcompound.set("recipeBook", this.cz.e()); nbttagcompound.set("recipeBook", this.cz.e());
@ -144,7 +167,7 @@
public void a(int i) { public void a(int i) {
float f = (float) this.getExpToLevel(); float f = (float) this.getExpToLevel();
float f1 = (f - 1.0F) / f; float f1 = (f - 1.0F) / f;
@@ -211,6 +311,11 @@ @@ -211,6 +324,11 @@
} }
public void tick() { public void tick() {
@ -156,7 +179,7 @@
this.playerInteractManager.a(); this.playerInteractManager.a();
--this.invulnerableTicks; --this.invulnerableTicks;
if (this.noDamageTicks > 0) { if (this.noDamageTicks > 0) {
@@ -276,7 +381,7 @@ @@ -276,7 +394,7 @@
} }
if (this.getHealth() != this.lastHealthSent || this.cp != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.cq) { if (this.getHealth() != this.lastHealthSent || this.cp != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.cq) {
@ -165,7 +188,7 @@
this.lastHealthSent = this.getHealth(); this.lastHealthSent = this.getHealth();
this.cp = this.foodData.getFoodLevel(); this.cp = this.foodData.getFoodLevel();
this.cq = this.foodData.getSaturationLevel() == 0.0F; this.cq = this.foodData.getSaturationLevel() == 0.0F;
@@ -307,6 +412,12 @@ @@ -307,6 +425,12 @@
this.a(IScoreboardCriteria.k, MathHelper.f((float) this.cn)); this.a(IScoreboardCriteria.k, MathHelper.f((float) this.cn));
} }
@ -178,7 +201,7 @@
if (this.expLevel != this.cm) { if (this.expLevel != this.cm) {
this.cm = this.expLevel; this.cm = this.expLevel;
this.a(IScoreboardCriteria.l, MathHelper.f((float) this.cm)); this.a(IScoreboardCriteria.l, MathHelper.f((float) this.cm));
@@ -321,6 +432,16 @@ @@ -321,6 +445,16 @@
CriterionTriggers.p.a(this); CriterionTriggers.p.a(this);
} }
@ -195,7 +218,7 @@
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Ticking player"); CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");
@@ -331,7 +452,8 @@ @@ -331,7 +465,8 @@
} }
private void a(IScoreboardCriteria iscoreboardcriteria, int i) { private void a(IScoreboardCriteria iscoreboardcriteria, int i) {
@ -205,7 +228,7 @@
scoreboardscore.setScore(i); scoreboardscore.setScore(i);
}); });
} }
@@ -340,27 +462,59 @@ @@ -340,27 +475,59 @@
boolean flag = this.world.getGameRules().getBoolean("showDeathMessages"); boolean flag = this.world.getGameRules().getBoolean("showDeathMessages");
this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag)); this.playerConnection.sendPacket(new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, flag));
@ -225,17 +248,17 @@
+ } + }
+ } + }
+ } + }
+
+ IChatBaseComponent chatmessage = this.getCombatTracker().getDeathMessage();
+
+ String deathmessage = chatmessage.getString();
+ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory);
- if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) { - if (scoreboardteambase != null && scoreboardteambase.getDeathMessageVisibility() != ScoreboardTeamBase.EnumNameTagVisibility.ALWAYS) {
- if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) { - if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) {
- this.server.getPlayerList().a((EntityHuman) this, this.getCombatTracker().getDeathMessage()); - this.server.getPlayerList().a((EntityHuman) this, this.getCombatTracker().getDeathMessage());
- } else if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) { - } else if (scoreboardteambase.getDeathMessageVisibility() == ScoreboardTeamBase.EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) {
- this.server.getPlayerList().b((EntityHuman) this, this.getCombatTracker().getDeathMessage()); - this.server.getPlayerList().b((EntityHuman) this, this.getCombatTracker().getDeathMessage());
+ IChatBaseComponent chatmessage = this.getCombatTracker().getDeathMessage();
+
+ String deathmessage = chatmessage.getString();
+ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory);
+
+ String deathMessage = event.getDeathMessage(); + String deathMessage = event.getDeathMessage();
+ +
+ if (deathMessage != null && deathMessage.length() > 0 && flag) { // TODO: allow plugins to override? + if (deathMessage != null && deathMessage.length() > 0 && flag) { // TODO: allow plugins to override?
@ -277,7 +300,7 @@
EntityLiving entityliving = this.cv(); EntityLiving entityliving = this.cv();
if (entityliving != null) { if (entityliving != null) {
@@ -383,10 +537,12 @@ @@ -383,10 +550,12 @@
String s = this.getName(); String s = this.getName();
String s1 = entity.getName(); String s1 = entity.getName();
@ -292,7 +315,7 @@
} else { } else {
this.a(StatisticList.MOB_KILLS); this.a(StatisticList.MOB_KILLS);
} }
@@ -404,7 +560,8 @@ @@ -404,7 +573,8 @@
int i = scoreboardteam.getColor().b(); int i = scoreboardteam.getColor().b();
if (i >= 0 && i < aiscoreboardcriteria.length) { if (i >= 0 && i < aiscoreboardcriteria.length) {
@ -302,7 +325,7 @@
} }
} }
@@ -445,12 +602,14 @@ @@ -445,12 +615,14 @@
} }
private boolean canPvP() { private boolean canPvP() {
@ -319,7 +342,7 @@
if (this.dimension == 0 && i == -1) { if (this.dimension == 0 && i == -1) {
this.cD = new Vec3D(this.locX, this.locY, this.locZ); this.cD = new Vec3D(this.locX, this.locY, this.locZ);
} else if (this.dimension != -1 && i != 0) { } else if (this.dimension != -1 && i != 0) {
@@ -458,6 +617,7 @@ @@ -458,6 +630,7 @@
} }
if (this.dimension == 1 && i == 1) { if (this.dimension == 1 && i == 1) {
@ -327,7 +350,7 @@
this.world.kill(this); this.world.kill(this);
if (!this.viewingCredits) { if (!this.viewingCredits) {
this.viewingCredits = true; this.viewingCredits = true;
@@ -471,7 +631,10 @@ @@ -471,7 +644,10 @@
i = 1; i = 1;
} }
@ -339,7 +362,7 @@
this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false)); this.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1032, BlockPosition.ZERO, 0, false));
this.lastSentExp = -1; this.lastSentExp = -1;
this.lastHealthSent = -1.0F; this.lastHealthSent = -1.0F;
@@ -517,6 +680,7 @@ @@ -517,6 +693,7 @@
} }
public void a(boolean flag, boolean flag1, boolean flag2) { public void a(boolean flag, boolean flag1, boolean flag2) {
@ -347,7 +370,7 @@
if (this.isSleeping()) { if (this.isSleeping()) {
this.getWorldServer().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2)); this.getWorldServer().getTracker().sendPacketToEntity(this, new PacketPlayOutAnimation(this, 2));
} }
@@ -595,23 +759,55 @@ @@ -595,23 +772,55 @@
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition())); this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
} }
@ -406,7 +429,7 @@
if (iinventory instanceof ILootable && ((ILootable) iinventory).Q_() != null && this.isSpectator()) { if (iinventory instanceof ILootable && ((ILootable) iinventory).Q_() != null && this.isSpectator()) {
this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true); this.a((new ChatMessage("container.spectatorCantOpen", new Object[0])).a(EnumChatFormat.RED), true);
} else { } else {
@@ -625,18 +821,21 @@ @@ -625,18 +834,21 @@
if (itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator()) { if (itileinventory.isLocked() && !this.a(itileinventory.getLock()) && !this.isSpectator()) {
this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), ChatMessageType.GAME_INFO)); this.playerConnection.sendPacket(new PacketPlayOutChat(new ChatMessage("container.isLocked", new Object[] { iinventory.getScoreboardDisplayName()}), ChatMessageType.GAME_INFO));
this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F)); this.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.locX, this.locY, this.locZ, 1.0F, 1.0F));
@ -430,7 +453,7 @@
this.activeContainer.windowId = this.containerCounter; this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this); this.activeContainer.addSlotListener(this);
@@ -644,8 +843,14 @@ @@ -644,8 +856,14 @@
} }
public void openTrade(IMerchant imerchant) { public void openTrade(IMerchant imerchant) {
@ -446,7 +469,7 @@
this.activeContainer.windowId = this.containerCounter; this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this); this.activeContainer.addSlotListener(this);
InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).d(); InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).d();
@@ -665,13 +870,20 @@ @@ -665,13 +883,20 @@
} }
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@ -468,7 +491,7 @@
this.activeContainer.windowId = this.containerCounter; this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this); this.activeContainer.addSlotListener(this);
} }
@@ -712,6 +924,11 @@ @@ -712,6 +937,11 @@
public void a(Container container, NonNullList<ItemStack> nonnulllist) { public void a(Container container, NonNullList<ItemStack> nonnulllist) {
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist)); this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist));
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried())); this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried()));
@ -480,7 +503,7 @@
} }
public void setContainerData(Container container, int i, int j) { public void setContainerData(Container container, int i, int j) {
@@ -726,6 +943,7 @@ @@ -726,6 +956,7 @@
} }
public void closeInventory() { public void closeInventory() {
@ -488,7 +511,7 @@
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId)); this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
this.m(); this.m();
} }
@@ -759,14 +977,14 @@ @@ -759,14 +990,14 @@
public void a(Statistic<?> statistic, int i) { public void a(Statistic<?> statistic, int i) {
this.ch.b(this, statistic, i); this.ch.b(this, statistic, i);
@ -505,7 +528,7 @@
} }
public int a(Collection<IRecipe> collection) { public int a(Collection<IRecipe> collection) {
@@ -814,8 +1032,17 @@ @@ -814,8 +1045,17 @@
public void triggerHealthUpdate() { public void triggerHealthUpdate() {
this.lastHealthSent = -1.0E8F; this.lastHealthSent = -1.0E8F;
@ -523,7 +546,7 @@
public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { public void a(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT)); this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT));
} }
@@ -866,7 +1093,7 @@ @@ -866,7 +1106,7 @@
this.lastSentExp = -1; this.lastSentExp = -1;
this.lastHealthSent = -1.0F; this.lastHealthSent = -1.0F;
this.cp = -1; this.cp = -1;
@ -532,7 +555,7 @@
this.removeQueue.addAll(entityplayer.removeQueue); this.removeQueue.addAll(entityplayer.removeQueue);
this.cy = entityplayer.cy; this.cy = entityplayer.cy;
this.cD = entityplayer.cD; this.cD = entityplayer.cD;
@@ -925,6 +1152,18 @@ @@ -925,6 +1165,18 @@
} }
public void a(EnumGamemode enumgamemode) { public void a(EnumGamemode enumgamemode) {
@ -551,7 +574,7 @@
this.playerInteractManager.setGameMode(enumgamemode); this.playerInteractManager.setGameMode(enumgamemode);
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId())); this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, (float) enumgamemode.getId()));
if (enumgamemode == EnumGamemode.SPECTATOR) { if (enumgamemode == EnumGamemode.SPECTATOR) {
@@ -968,6 +1207,16 @@ @@ -968,6 +1220,16 @@
} }
public void a(PacketPlayInSettings packetplayinsettings) { public void a(PacketPlayInSettings packetplayinsettings) {
@ -568,7 +591,7 @@
this.locale = packetplayinsettings.b(); this.locale = packetplayinsettings.b();
this.ct = packetplayinsettings.d(); this.ct = packetplayinsettings.d();
this.cu = packetplayinsettings.e(); this.cu = packetplayinsettings.e();
@@ -1033,7 +1282,7 @@ @@ -1033,7 +1295,7 @@
this.cw = (Entity) (entity == null ? this : entity); this.cw = (Entity) (entity == null ? this : entity);
if (entity1 != this.cw) { if (entity1 != this.cw) {
this.playerConnection.sendPacket(new PacketPlayOutCamera(this.cw)); this.playerConnection.sendPacket(new PacketPlayOutCamera(this.cw));
@ -577,7 +600,7 @@
} }
} }
@@ -1060,7 +1309,7 @@ @@ -1060,7 +1322,7 @@
@Nullable @Nullable
public IChatBaseComponent getPlayerListName() { public IChatBaseComponent getPlayerListName() {
@ -586,7 +609,7 @@
} }
public void a(EnumHand enumhand) { public void a(EnumHand enumhand) {
@@ -1077,12 +1326,17 @@ @@ -1077,12 +1339,17 @@
} }
public void J() { public void J() {
@ -604,7 +627,7 @@
} }
public AdvancementDataPlayer getAdvancementData() { public AdvancementDataPlayer getAdvancementData() {
@@ -1094,9 +1348,16 @@ @@ -1094,9 +1361,16 @@
return this.cD; return this.cD;
} }
@ -621,7 +644,7 @@
if (worldserver == this.world) { if (worldserver == this.world) {
this.playerConnection.a(d0, d1, d2, f, f1); this.playerConnection.a(d0, d1, d2, f, f1);
} else { } else {
@@ -1121,6 +1382,149 @@ @@ -1121,6 +1395,149 @@
this.server.getPlayerList().b(this, worldserver); this.server.getPlayerList().b(this, worldserver);
this.server.getPlayerList().updateClient(this); this.server.getPlayerList().updateClient(this);
} }

View file

@ -356,6 +356,16 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return server; return server;
} }
@Override
public boolean isPersistent() {
return entity.persist;
}
@Override
public void setPersistent(boolean persistent) {
entity.persist = persistent;
}
public Vector getMomentum() { public Vector getMomentum() {
return getVelocity(); return getVelocity();
} }