mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-23 15:00:30 +01:00
SPIGOT-5902: PlayerRespawnEvent places player at spawn before event is called
This commit is contained in:
parent
aa8f3d5a41
commit
fb4e54ad7b
1 changed files with 53 additions and 58 deletions
|
@ -49,7 +49,7 @@
|
|||
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
|
||||
super(worldserver, worldserver.getSpawn(), gameprofile);
|
||||
this.spawnDimension = World.OVERWORLD;
|
||||
@@ -66,8 +101,55 @@
|
||||
@@ -66,7 +101,51 @@
|
||||
this.advancementDataPlayer = minecraftserver.getPlayerList().f(this);
|
||||
this.G = 1.0F;
|
||||
this.b(worldserver);
|
||||
|
@ -58,8 +58,8 @@
|
|||
+ this.displayName = this.getName();
|
||||
+ this.canPickUpLoot = true;
|
||||
+ this.maxHealthCache = this.getMaxHealth();
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ // Yes, this doesn't match Vanilla, but it's the best we can do for now.
|
||||
+ // If this is an issue, PRs are welcome
|
||||
+ public final BlockPosition getSpawnPoint(WorldServer worldserver) {
|
||||
|
@ -90,22 +90,18 @@
|
|||
+ BlockPosition blockposition1 = WorldProviderNormal.a(worldserver, blockposition.getX() + j2 - i, blockposition.getZ() + k2 - i, false);
|
||||
+
|
||||
+ if (blockposition1 != null) {
|
||||
+ this.setPositionRotation(blockposition1, 0.0F, 0.0F);
|
||||
+ if (worldserver.getCubes(this)) {
|
||||
+ break;
|
||||
+ }
|
||||
+ return blockposition1;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return blockposition;
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
private void b(WorldServer worldserver) {
|
||||
BlockPosition blockposition = worldserver.getSpawn();
|
||||
|
||||
@@ -137,11 +219,20 @@
|
||||
@@ -137,11 +216,20 @@
|
||||
if (nbttagcompound.hasKeyOfType("recipeBook", 10)) {
|
||||
this.recipeBook.a(nbttagcompound.getCompound("recipeBook"), this.server.getCraftingManager());
|
||||
}
|
||||
|
@ -126,7 +122,7 @@
|
|||
if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) {
|
||||
this.spawn = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
|
||||
this.spawnForced = nbttagcompound.getBoolean("SpawnForced");
|
||||
@@ -174,7 +265,20 @@
|
||||
@@ -174,7 +262,20 @@
|
||||
Entity entity = this.getRootVehicle();
|
||||
Entity entity1 = this.getVehicle();
|
||||
|
||||
|
@ -148,7 +144,7 @@
|
|||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
|
||||
|
||||
@@ -191,7 +295,7 @@
|
||||
@@ -191,7 +292,7 @@
|
||||
nbttagcompound.setInt("SpawnY", this.spawn.getY());
|
||||
nbttagcompound.setInt("SpawnZ", this.spawn.getZ());
|
||||
nbttagcompound.setBoolean("SpawnForced", this.spawnForced);
|
||||
|
@ -157,13 +153,13 @@
|
|||
Logger logger = EntityPlayer.LOGGER;
|
||||
|
||||
logger.getClass();
|
||||
@@ -199,9 +303,33 @@
|
||||
@@ -199,8 +300,32 @@
|
||||
nbttagcompound.set("SpawnDimension", nbtbase);
|
||||
});
|
||||
}
|
||||
+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
|
||||
|
||||
}
|
||||
+
|
||||
+ }
|
||||
|
||||
+ // CraftBukkit start - World fallback code, either respawn location or global spawn
|
||||
+ public void spawnIn(World world) {
|
||||
|
@ -185,13 +181,12 @@
|
|||
+ this.setPosition(position.getX(), position.getY(), position.getZ());
|
||||
+ }
|
||||
+ this.playerInteractManager.a((WorldServer) world);
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
public void a(int i) {
|
||||
float f = (float) this.getExpToLevel();
|
||||
float f1 = (f - 1.0F) / f;
|
||||
@@ -255,6 +383,11 @@
|
||||
@@ -255,6 +380,11 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
@ -203,7 +198,7 @@
|
|||
this.playerInteractManager.a();
|
||||
--this.invulnerableTicks;
|
||||
if (this.noDamageTicks > 0) {
|
||||
@@ -322,7 +455,7 @@
|
||||
@@ -322,7 +452,7 @@
|
||||
}
|
||||
|
||||
if (this.getHealth() != this.lastHealthSent || this.lastFoodSent != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastSentSaturationZero) {
|
||||
|
@ -212,7 +207,7 @@
|
|||
this.lastHealthSent = this.getHealth();
|
||||
this.lastFoodSent = this.foodData.getFoodLevel();
|
||||
this.lastSentSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
|
||||
@@ -353,6 +486,12 @@
|
||||
@@ -353,6 +483,12 @@
|
||||
this.a(IScoreboardCriteria.XP, MathHelper.f((float) this.lastExpTotalScored));
|
||||
}
|
||||
|
||||
|
@ -225,7 +220,7 @@
|
|||
if (this.expLevel != this.lastExpLevelScored) {
|
||||
this.lastExpLevelScored = this.expLevel;
|
||||
this.a(IScoreboardCriteria.LEVEL, MathHelper.f((float) this.lastExpLevelScored));
|
||||
@@ -367,6 +506,16 @@
|
||||
@@ -367,6 +503,16 @@
|
||||
CriterionTriggers.p.a(this);
|
||||
}
|
||||
|
||||
|
@ -242,7 +237,7 @@
|
|||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");
|
||||
@@ -377,7 +526,8 @@
|
||||
@@ -377,7 +523,8 @@
|
||||
}
|
||||
|
||||
private void a(IScoreboardCriteria iscoreboardcriteria, int i) {
|
||||
|
@ -252,7 +247,7 @@
|
|||
scoreboardscore.setScore(i);
|
||||
});
|
||||
}
|
||||
@@ -385,9 +535,46 @@
|
||||
@@ -385,9 +532,46 @@
|
||||
@Override
|
||||
public void die(DamageSource damagesource) {
|
||||
boolean flag = this.world.getGameRules().getBoolean(GameRules.SHOW_DEATH_MESSAGES);
|
||||
|
@ -301,7 +296,7 @@
|
|||
|
||||
this.playerConnection.a((Packet) (new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, ichatbasecomponent)), (future) -> {
|
||||
if (!future.isSuccess()) {
|
||||
@@ -421,12 +608,18 @@
|
||||
@@ -421,12 +605,18 @@
|
||||
if (this.world.getGameRules().getBoolean(GameRules.FORGIVE_DEAD_PLAYERS)) {
|
||||
this.eW();
|
||||
}
|
||||
|
@ -324,7 +319,7 @@
|
|||
EntityLiving entityliving = this.getKillingEntity();
|
||||
|
||||
if (entityliving != null) {
|
||||
@@ -462,10 +655,12 @@
|
||||
@@ -462,10 +652,12 @@
|
||||
String s = this.getName();
|
||||
String s1 = entity.getName();
|
||||
|
||||
|
@ -339,7 +334,7 @@
|
|||
} else {
|
||||
this.a(StatisticList.MOB_KILLS);
|
||||
}
|
||||
@@ -483,7 +678,8 @@
|
||||
@@ -483,7 +675,8 @@
|
||||
int i = scoreboardteam.getColor().b();
|
||||
|
||||
if (i >= 0 && i < aiscoreboardcriteria.length) {
|
||||
|
@ -349,7 +344,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -527,17 +723,27 @@
|
||||
@@ -527,17 +720,27 @@
|
||||
}
|
||||
|
||||
private boolean canPvP() {
|
||||
|
@ -381,7 +376,7 @@
|
|||
this.decouple();
|
||||
this.getWorldServer().removePlayer(this);
|
||||
if (!this.viewingCredits) {
|
||||
@@ -548,6 +754,8 @@
|
||||
@@ -548,6 +751,8 @@
|
||||
|
||||
return this;
|
||||
} else {
|
||||
|
@ -390,7 +385,7 @@
|
|||
WorldData worlddata = worldserver.getWorldData();
|
||||
|
||||
this.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.getTypeKey(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.playerInteractManager.getGameMode(), this.playerInteractManager.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true));
|
||||
@@ -557,6 +765,8 @@
|
||||
@@ -557,6 +762,8 @@
|
||||
playerlist.d(this);
|
||||
worldserver1.removePlayer(this);
|
||||
this.dead = false;
|
||||
|
@ -399,7 +394,7 @@
|
|||
double d0 = this.locX();
|
||||
double d1 = this.locY();
|
||||
double d2 = this.locZ();
|
||||
@@ -567,7 +777,8 @@
|
||||
@@ -567,7 +774,8 @@
|
||||
worldserver1.getMethodProfiler().enter("moving");
|
||||
double d3;
|
||||
|
||||
|
@ -409,7 +404,7 @@
|
|||
BlockPosition blockposition = WorldServer.a;
|
||||
|
||||
d0 = (double) blockposition.getX();
|
||||
@@ -576,7 +787,7 @@
|
||||
@@ -576,7 +784,7 @@
|
||||
f1 = 90.0F;
|
||||
f = 0.0F;
|
||||
} else {
|
||||
|
@ -418,7 +413,7 @@
|
|||
this.cp = this.getPositionVector();
|
||||
}
|
||||
|
||||
@@ -593,7 +804,26 @@
|
||||
@@ -593,7 +801,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,7 +441,7 @@
|
|||
worldserver1.getMethodProfiler().exit();
|
||||
worldserver1.getMethodProfiler().enter("placing");
|
||||
double d4 = Math.min(-2.9999872E7D, worldserver.getWorldBorder().e() + 16.0D);
|
||||
@@ -604,25 +834,74 @@
|
||||
@@ -604,25 +831,74 @@
|
||||
|
||||
d0 = MathHelper.a(d0, d4, d5);
|
||||
d2 = MathHelper.a(d2, d3, d6);
|
||||
|
@ -534,7 +529,7 @@
|
|||
this.playerInteractManager.a(worldserver);
|
||||
this.playerConnection.sendPacket(new PacketPlayOutAbilities(this.abilities));
|
||||
playerlist.a(this, worldserver);
|
||||
@@ -639,6 +918,11 @@
|
||||
@@ -639,6 +915,11 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastHealthSent = -1.0F;
|
||||
this.lastFoodSent = -1;
|
||||
|
@ -546,7 +541,7 @@
|
|||
return this;
|
||||
}
|
||||
}
|
||||
@@ -680,10 +964,8 @@
|
||||
@@ -680,10 +961,8 @@
|
||||
this.activeContainer.c();
|
||||
}
|
||||
|
||||
|
@ -559,7 +554,7 @@
|
|||
if (!this.isSleeping() && this.isAlive()) {
|
||||
if (!this.world.getDimensionManager().isNatural()) {
|
||||
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE);
|
||||
@@ -709,7 +991,36 @@
|
||||
@@ -709,7 +988,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -597,7 +592,7 @@
|
|||
this.a(StatisticList.SLEEP_IN_BED);
|
||||
CriterionTriggers.q.a(this);
|
||||
});
|
||||
@@ -718,9 +1029,8 @@
|
||||
@@ -718,9 +1026,8 @@
|
||||
return either;
|
||||
}
|
||||
}
|
||||
|
@ -608,7 +603,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -747,6 +1057,7 @@
|
||||
@@ -747,6 +1054,7 @@
|
||||
|
||||
@Override
|
||||
public void wakeup(boolean flag, boolean flag1) {
|
||||
|
@ -616,7 +611,7 @@
|
|||
if (this.isSleeping()) {
|
||||
this.getWorldServer().getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAnimation(this, 2));
|
||||
}
|
||||
@@ -818,8 +1129,9 @@
|
||||
@@ -818,8 +1126,9 @@
|
||||
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
|
||||
}
|
||||
|
||||
|
@ -627,7 +622,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -834,6 +1146,24 @@
|
||||
@@ -834,6 +1143,24 @@
|
||||
this.nextContainerCounter();
|
||||
Container container = itileinventory.createMenu(this.containerCounter, this.inventory, this);
|
||||
|
||||
|
@ -652,7 +647,7 @@
|
|||
if (container == null) {
|
||||
if (this.isSpectator()) {
|
||||
this.a((IChatBaseComponent) (new ChatMessage("container.spectatorCantOpen")).a(EnumChatFormat.RED), true);
|
||||
@@ -841,9 +1171,11 @@
|
||||
@@ -841,9 +1168,11 @@
|
||||
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
|
@ -666,7 +661,7 @@
|
|||
return OptionalInt.of(this.containerCounter);
|
||||
}
|
||||
}
|
||||
@@ -856,13 +1188,24 @@
|
||||
@@ -856,13 +1185,24 @@
|
||||
|
||||
@Override
|
||||
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
|
||||
|
@ -693,7 +688,7 @@
|
|||
this.activeContainer.addSlotListener(this);
|
||||
}
|
||||
|
||||
@@ -907,6 +1250,11 @@
|
||||
@@ -907,6 +1247,11 @@
|
||||
public void a(Container container, NonNullList<ItemStack> nonnulllist) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist));
|
||||
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried()));
|
||||
|
@ -705,7 +700,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -916,6 +1264,7 @@
|
||||
@@ -916,6 +1261,7 @@
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
|
@ -713,7 +708,7 @@
|
|||
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
|
||||
this.o();
|
||||
}
|
||||
@@ -950,7 +1299,7 @@
|
||||
@@ -950,7 +1296,7 @@
|
||||
@Override
|
||||
public void a(Statistic<?> statistic, int i) {
|
||||
this.serverStatisticManager.b(this, statistic, i);
|
||||
|
@ -722,7 +717,7 @@
|
|||
scoreboardscore.addScore(i);
|
||||
});
|
||||
}
|
||||
@@ -958,7 +1307,7 @@
|
||||
@@ -958,7 +1304,7 @@
|
||||
@Override
|
||||
public void a(Statistic<?> statistic) {
|
||||
this.serverStatisticManager.setStatistic(this, statistic, 0);
|
||||
|
@ -731,7 +726,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1007,7 +1356,16 @@
|
||||
@@ -1007,7 +1353,16 @@
|
||||
|
||||
public void triggerHealthUpdate() {
|
||||
this.lastHealthSent = -1.0E8F;
|
||||
|
@ -748,7 +743,7 @@
|
|||
|
||||
@Override
|
||||
public void a(IChatBaseComponent ichatbasecomponent, boolean flag) {
|
||||
@@ -1062,12 +1420,14 @@
|
||||
@@ -1062,12 +1417,14 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastHealthSent = -1.0F;
|
||||
this.lastFoodSent = -1;
|
||||
|
@ -764,7 +759,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1135,6 +1495,18 @@
|
||||
@@ -1135,6 +1492,18 @@
|
||||
|
||||
@Override
|
||||
public void a(EnumGamemode enumgamemode) {
|
||||
|
@ -783,7 +778,7 @@
|
|||
this.playerInteractManager.setGameMode(enumgamemode);
|
||||
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.d, (float) enumgamemode.getId()));
|
||||
if (enumgamemode == EnumGamemode.SPECTATOR) {
|
||||
@@ -1184,7 +1556,20 @@
|
||||
@@ -1184,7 +1553,20 @@
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -804,7 +799,7 @@
|
|||
this.cf = packetplayinsettings.d();
|
||||
this.cg = packetplayinsettings.e();
|
||||
this.getDataWatcher().set(EntityPlayer.bp, (byte) packetplayinsettings.f());
|
||||
@@ -1220,13 +1605,13 @@
|
||||
@@ -1220,13 +1602,13 @@
|
||||
if (entity instanceof EntityHuman) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[]{entity.getId()}));
|
||||
} else {
|
||||
|
@ -820,7 +815,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1250,7 +1635,7 @@
|
||||
@@ -1250,7 +1632,7 @@
|
||||
this.spectatedEntity = (Entity) (entity == null ? this : entity);
|
||||
if (entity1 != this.spectatedEntity) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity));
|
||||
|
@ -829,7 +824,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -1279,7 +1664,7 @@
|
||||
@@ -1279,7 +1661,7 @@
|
||||
|
||||
@Nullable
|
||||
public IChatBaseComponent getPlayerListName() {
|
||||
|
@ -838,7 +833,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1300,9 +1685,16 @@
|
||||
@@ -1300,9 +1682,16 @@
|
||||
return this.advancementDataPlayer;
|
||||
}
|
||||
|
||||
|
@ -855,7 +850,7 @@
|
|||
if (worldserver == this.world) {
|
||||
this.playerConnection.a(d0, d1, d2, f, f1);
|
||||
} else {
|
||||
@@ -1323,6 +1715,9 @@
|
||||
@@ -1323,6 +1712,9 @@
|
||||
this.server.getPlayerList().a(this, worldserver);
|
||||
this.server.getPlayerList().updateClient(this);
|
||||
}
|
||||
|
@ -865,7 +860,7 @@
|
|||
|
||||
}
|
||||
|
||||
@@ -1409,4 +1804,144 @@
|
||||
@@ -1409,4 +1801,144 @@
|
||||
return entityitem;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue