mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 09:47:40 +01:00
#1091: Fix exit position in entity travel with portals
By: Doc <nachito94@msn.com>
This commit is contained in:
parent
d236296888
commit
7c33b52741
@ -1,10 +1,11 @@
|
||||
--- a/net/minecraft/server/level/EntityPlayer.java
|
||||
+++ b/net/minecraft/server/level/EntityPlayer.java
|
||||
@@ -147,6 +147,34 @@
|
||||
@@ -147,6 +147,35 @@
|
||||
import net.minecraft.world.scores.criteria.IScoreboardCriteria;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.core.Position;
|
||||
+import net.minecraft.nbt.NBTBase;
|
||||
+import net.minecraft.world.damagesource.CombatTracker;
|
||||
+import net.minecraft.world.food.FoodMetaData;
|
||||
@ -35,7 +36,7 @@
|
||||
public class EntityPlayer extends EntityHuman {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -201,6 +229,21 @@
|
||||
@@ -201,6 +230,21 @@
|
||||
public int latency;
|
||||
public boolean wonGame;
|
||||
|
||||
@ -57,7 +58,7 @@
|
||||
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, @Nullable ProfilePublicKey profilepublickey) {
|
||||
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile, profilepublickey);
|
||||
this.chatVisibility = EnumChatVisibility.FULL;
|
||||
@@ -263,12 +306,56 @@
|
||||
@@ -263,12 +307,56 @@
|
||||
this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this);
|
||||
this.maxUpStep = 1.0F;
|
||||
this.fudgeSpawnLocation(worldserver);
|
||||
@ -115,7 +116,7 @@
|
||||
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
|
||||
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
|
||||
|
||||
@@ -326,17 +413,26 @@
|
||||
@@ -326,17 +414,26 @@
|
||||
if (nbttagcompound.contains("recipeBook", 10)) {
|
||||
this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager());
|
||||
}
|
||||
@ -143,7 +144,7 @@
|
||||
Logger logger = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -363,7 +459,20 @@
|
||||
@@ -363,7 +460,20 @@
|
||||
Entity entity = this.getRootVehicle();
|
||||
Entity entity1 = this.getVehicle();
|
||||
|
||||
@ -165,7 +166,7 @@
|
||||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
|
||||
|
||||
@@ -381,7 +490,7 @@
|
||||
@@ -381,7 +491,7 @@
|
||||
nbttagcompound.putInt("SpawnZ", this.respawnPosition.getZ());
|
||||
nbttagcompound.putBoolean("SpawnForced", this.respawnForced);
|
||||
nbttagcompound.putFloat("SpawnAngle", this.respawnAngle);
|
||||
@ -174,7 +175,7 @@
|
||||
Logger logger = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -389,8 +498,32 @@
|
||||
@@ -389,8 +499,32 @@
|
||||
nbttagcompound.put("SpawnDimension", nbtbase);
|
||||
});
|
||||
}
|
||||
@ -207,7 +208,7 @@
|
||||
|
||||
public void setExperiencePoints(int i) {
|
||||
float f = (float) this.getXpNeededForNextLevel();
|
||||
@@ -450,6 +583,11 @@
|
||||
@@ -450,6 +584,11 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@ -219,7 +220,7 @@
|
||||
this.gameMode.tick();
|
||||
--this.spawnInvulnerableTime;
|
||||
if (this.invulnerableTime > 0) {
|
||||
@@ -505,7 +643,7 @@
|
||||
@@ -505,7 +644,7 @@
|
||||
}
|
||||
|
||||
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
|
||||
@ -228,7 +229,7 @@
|
||||
this.lastSentHealth = this.getHealth();
|
||||
this.lastSentFood = this.foodData.getFoodLevel();
|
||||
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
|
||||
@@ -536,6 +674,12 @@
|
||||
@@ -536,6 +675,12 @@
|
||||
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
|
||||
}
|
||||
|
||||
@ -241,7 +242,7 @@
|
||||
if (this.experienceLevel != this.lastRecordedLevel) {
|
||||
this.lastRecordedLevel = this.experienceLevel;
|
||||
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
|
||||
@@ -550,6 +694,20 @@
|
||||
@@ -550,6 +695,20 @@
|
||||
CriterionTriggers.LOCATION.trigger(this);
|
||||
}
|
||||
|
||||
@ -262,7 +263,7 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
|
||||
@@ -592,7 +750,8 @@
|
||||
@@ -592,7 +751,8 @@
|
||||
}
|
||||
|
||||
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
|
||||
@ -272,7 +273,7 @@
|
||||
scoreboardscore.setScore(i);
|
||||
});
|
||||
}
|
||||
@@ -601,9 +760,47 @@
|
||||
@@ -601,9 +761,47 @@
|
||||
public void die(DamageSource damagesource) {
|
||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
@ -322,7 +323,7 @@
|
||||
|
||||
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), (future) -> {
|
||||
if (!future.isSuccess()) {
|
||||
@@ -637,12 +834,18 @@
|
||||
@@ -637,12 +835,18 @@
|
||||
if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
|
||||
this.tellNeutralMobsThatIDied();
|
||||
}
|
||||
@ -345,7 +346,7 @@
|
||||
EntityLiving entityliving = this.getKillCredit();
|
||||
|
||||
if (entityliving != null) {
|
||||
@@ -680,10 +883,12 @@
|
||||
@@ -680,10 +884,12 @@
|
||||
String s = this.getScoreboardName();
|
||||
String s1 = entity.getScoreboardName();
|
||||
|
||||
@ -360,7 +361,7 @@
|
||||
} else {
|
||||
this.awardStat(StatisticList.MOB_KILLS);
|
||||
}
|
||||
@@ -701,7 +906,8 @@
|
||||
@@ -701,7 +907,8 @@
|
||||
int i = scoreboardteam.getColor().getId();
|
||||
|
||||
if (i >= 0 && i < aiscoreboardcriteria.length) {
|
||||
@ -370,7 +371,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -745,18 +951,20 @@
|
||||
@@ -745,18 +952,20 @@
|
||||
}
|
||||
|
||||
private boolean isPvpAllowed() {
|
||||
@ -394,7 +395,7 @@
|
||||
} else {
|
||||
return shapedetectorshape;
|
||||
}
|
||||
@@ -765,11 +973,20 @@
|
||||
@@ -765,11 +974,20 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public Entity changeDimension(WorldServer worldserver) {
|
||||
@ -418,7 +419,7 @@
|
||||
this.unRide();
|
||||
this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
if (!this.wonGame) {
|
||||
@@ -780,6 +997,8 @@
|
||||
@@ -780,6 +998,8 @@
|
||||
|
||||
return this;
|
||||
} else {
|
||||
@ -427,7 +428,7 @@
|
||||
WorldData worlddata = worldserver.getLevelData();
|
||||
|
||||
this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true, this.getLastDeathLocation()));
|
||||
@@ -789,22 +1008,52 @@
|
||||
@@ -789,22 +1009,52 @@
|
||||
playerlist.sendPlayerPermissionLevel(this);
|
||||
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
this.unsetRemoved();
|
||||
@ -486,7 +487,7 @@
|
||||
worldserver1.getProfiler().pop();
|
||||
this.triggerDimensionChangeTriggers(worldserver1);
|
||||
this.connection.send(new PacketPlayOutAbilities(this.getAbilities()));
|
||||
@@ -822,12 +1071,31 @@
|
||||
@@ -822,12 +1072,31 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@ -503,9 +504,9 @@
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, BlockPosition exitPosition, TeleportCause cause, int searchRadius, int creationRadius) {
|
||||
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Position exitPosition, TeleportCause cause, int searchRadius, int creationRadius) {
|
||||
+ Location enter = this.getBukkitEntity().getLocation();
|
||||
+ Location exit = new Location(exitWorldServer.getWorld(), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ(), getYRot(), getXRot());
|
||||
+ Location exit = new Location(exitWorldServer.getWorld(), exitPosition.x(), exitPosition.y(), exitPosition.z(), getYRot(), getXRot());
|
||||
+ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, searchRadius, true, creationRadius);
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null) {
|
||||
@ -518,7 +519,7 @@
|
||||
private void createEndPlatform(WorldServer worldserver, BlockPosition blockposition) {
|
||||
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable();
|
||||
|
||||
@@ -844,17 +1112,17 @@
|
||||
@@ -844,17 +1113,17 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -541,7 +542,7 @@
|
||||
}
|
||||
|
||||
return optional1;
|
||||
@@ -864,13 +1132,21 @@
|
||||
@@ -864,13 +1133,21 @@
|
||||
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
|
||||
ResourceKey<World> resourcekey = worldserver.dimension();
|
||||
ResourceKey<World> resourcekey1 = this.level.dimension();
|
||||
@ -566,7 +567,7 @@
|
||||
this.enteredNetherPosition = null;
|
||||
}
|
||||
|
||||
@@ -887,12 +1163,10 @@
|
||||
@@ -887,12 +1164,10 @@
|
||||
this.containerMenu.broadcastChanges();
|
||||
}
|
||||
|
||||
@ -582,7 +583,7 @@
|
||||
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE);
|
||||
} else if (!this.bedInRange(blockposition, enumdirection)) {
|
||||
return Either.left(EntityHuman.EnumBedResult.TOO_FAR_AWAY);
|
||||
@@ -916,7 +1190,36 @@
|
||||
@@ -916,7 +1191,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -620,7 +621,7 @@
|
||||
this.awardStat(StatisticList.SLEEP_IN_BED);
|
||||
CriterionTriggers.SLEPT_IN_BED.trigger(this);
|
||||
});
|
||||
@@ -929,9 +1232,8 @@
|
||||
@@ -929,9 +1233,8 @@
|
||||
return either;
|
||||
}
|
||||
}
|
||||
@ -631,7 +632,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -958,6 +1260,24 @@
|
||||
@@ -958,6 +1261,24 @@
|
||||
|
||||
@Override
|
||||
public void stopSleepInBed(boolean flag, boolean flag1) {
|
||||
@ -656,7 +657,7 @@
|
||||
if (this.isSleeping()) {
|
||||
this.getLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2));
|
||||
}
|
||||
@@ -1039,8 +1359,9 @@
|
||||
@@ -1039,8 +1360,9 @@
|
||||
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos()));
|
||||
}
|
||||
|
||||
@ -667,7 +668,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1048,13 +1369,35 @@
|
||||
@@ -1048,13 +1370,35 @@
|
||||
if (itileinventory == null) {
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@ -703,7 +704,7 @@
|
||||
if (container == null) {
|
||||
if (this.isSpectator()) {
|
||||
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
|
||||
@@ -1062,9 +1405,11 @@
|
||||
@@ -1062,9 +1406,11 @@
|
||||
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@ -717,7 +718,7 @@
|
||||
return OptionalInt.of(this.containerCounter);
|
||||
}
|
||||
}
|
||||
@@ -1077,13 +1422,24 @@
|
||||
@@ -1077,13 +1423,24 @@
|
||||
|
||||
@Override
|
||||
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
|
||||
@ -744,7 +745,7 @@
|
||||
this.initMenu(this.containerMenu);
|
||||
}
|
||||
|
||||
@@ -1106,6 +1462,7 @@
|
||||
@@ -1106,6 +1463,7 @@
|
||||
|
||||
@Override
|
||||
public void closeContainer() {
|
||||
@ -752,7 +753,7 @@
|
||||
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
|
||||
this.doCloseContainer();
|
||||
}
|
||||
@@ -1135,7 +1492,7 @@
|
||||
@@ -1135,7 +1493,7 @@
|
||||
@Override
|
||||
public void awardStat(Statistic<?> statistic, int i) {
|
||||
this.stats.increment(this, statistic, i);
|
||||
@ -761,7 +762,7 @@
|
||||
scoreboardscore.add(i);
|
||||
});
|
||||
}
|
||||
@@ -1143,7 +1500,7 @@
|
||||
@@ -1143,7 +1501,7 @@
|
||||
@Override
|
||||
public void resetStat(Statistic<?> statistic) {
|
||||
this.stats.setValue(this, statistic, 0);
|
||||
@ -770,7 +771,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1159,7 +1516,7 @@
|
||||
@@ -1159,7 +1517,7 @@
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
MinecraftKey minecraftkey = aminecraftkey1[j];
|
||||
@ -779,7 +780,7 @@
|
||||
|
||||
Objects.requireNonNull(list);
|
||||
optional.ifPresent(list::add);
|
||||
@@ -1194,6 +1551,7 @@
|
||||
@@ -1194,6 +1552,7 @@
|
||||
|
||||
public void resetSentInfo() {
|
||||
this.lastSentHealth = -1.0E8F;
|
||||
@ -787,7 +788,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1249,7 +1607,7 @@
|
||||
@@ -1249,7 +1608,7 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@ -796,7 +797,7 @@
|
||||
this.seenCredits = entityplayer.seenCredits;
|
||||
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
|
||||
this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft());
|
||||
@@ -1397,7 +1755,20 @@
|
||||
@@ -1397,7 +1756,20 @@
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -817,7 +818,7 @@
|
||||
this.chatVisibility = packetplayinsettings.chatVisibility();
|
||||
this.canChatColor = packetplayinsettings.chatColors();
|
||||
this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled();
|
||||
@@ -1472,7 +1843,7 @@
|
||||
@@ -1472,7 +1844,7 @@
|
||||
this.camera = (Entity) (entity == null ? this : entity);
|
||||
if (entity1 != this.camera) {
|
||||
this.connection.send(new PacketPlayOutCamera(this.camera));
|
||||
@ -826,7 +827,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1501,7 +1872,7 @@
|
||||
@@ -1501,7 +1873,7 @@
|
||||
|
||||
@Nullable
|
||||
public IChatBaseComponent getTabListDisplayName() {
|
||||
@ -835,7 +836,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1522,9 +1893,16 @@
|
||||
@@ -1522,9 +1894,16 @@
|
||||
return this.advancements;
|
||||
}
|
||||
|
||||
@ -852,7 +853,7 @@
|
||||
if (worldserver == this.level) {
|
||||
this.connection.teleport(d0, d1, d2, f, f1);
|
||||
} else {
|
||||
@@ -1544,6 +1922,9 @@
|
||||
@@ -1544,6 +1923,9 @@
|
||||
this.server.getPlayerList().sendLevelInfo(this, worldserver);
|
||||
this.server.getPlayerList().sendAllPlayerInfo(this);
|
||||
}
|
||||
@ -862,7 +863,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -1713,4 +2094,146 @@
|
||||
@@ -1713,4 +2095,146 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -710,7 +710,7 @@
|
||||
double d0 = DimensionManager.getTeleportationScale(this.level.dimensionType(), worldserver.dimensionType());
|
||||
BlockPosition blockposition = worldborder.clampToBounds(this.getX() * d0, this.getY(), this.getZ() * d0);
|
||||
+ // CraftBukkit start
|
||||
+ CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16);
|
||||
+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Position(blockposition.getX(), blockposition.getY(), blockposition.getZ()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16);
|
||||
+ if (event == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
@ -740,7 +740,7 @@
|
||||
blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos());
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition1.offset(0.5D, 0, 0.5D), PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0);
|
||||
+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Position(blockposition1.getX() + 0.5D, blockposition1.getY(), blockposition1.getZ() + 0.5D), PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0);
|
||||
+ if (event == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
@ -758,10 +758,10 @@
|
||||
- protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder) {
|
||||
- return worldserver.getPortalForcer().findPortalAround(blockposition, flag, worldborder);
|
||||
+ // CraftBukkit start
|
||||
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, BlockPosition exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
|
||||
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Position exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
|
||||
+ org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
|
||||
+ Location enter = bukkitEntity.getLocation();
|
||||
+ Location exit = new Location(exitWorldServer.getWorld(), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ());
|
||||
+ Location exit = new Location(exitWorldServer.getWorld(), exitPosition.x(), exitPosition.y(), exitPosition.z());
|
||||
+
|
||||
+ EntityPortalEvent event = new EntityPortalEvent(bukkitEntity, enter, exit, searchRadius);
|
||||
+ event.getEntity().getServer().getPluginManager().callEvent(event);
|
||||
|
Loading…
Reference in New Issue
Block a user