From 2c43d196e46ba7de52e51c9d60851d3fb429a7aa Mon Sep 17 00:00:00 2001 From: connorhartley Date: Mon, 7 Jan 2019 14:43:48 -0600 Subject: [PATCH] Workaround for vehicle tracking issue on disconnect --- .../server/level/ServerPlayer.java.patch | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index a1b868e603..e21e083614 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -114,7 +114,7 @@ @Nullable private Vec3 startingToFallPosition; @Nullable -@@ -258,7 +293,32 @@ +@@ -258,6 +293,31 @@ private final CommandSource commandSource; private int containerCounter; public boolean wonGame; @@ -124,7 +124,7 @@ + public boolean queueHealthUpdatePacket; + public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; + // Paper end - cancellable death event - ++ + // CraftBukkit start + public CraftPlayer.TransferCookieConnection transferCookieConnection; + public String displayName; @@ -143,10 +143,9 @@ + // CraftBukkit end + public boolean isRealPlayer; // Paper + public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent -+ + public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) { super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); - this.chatVisibility = ChatVisiblity.FULL; @@ -266,7 +326,7 @@ this.canChatColor = true; this.lastActionTime = Util.getMillis(); @@ -1190,7 +1189,21 @@ } } -@@ -1625,6 +2073,7 @@ +@@ -1613,6 +2061,13 @@ + public void disconnect() { + this.disconnected = true; + this.ejectPassengers(); ++ ++ // Paper start - Workaround vehicle not tracking the passenger disconnection dismount ++ if (this.isPassenger() && this.getVehicle() instanceof ServerPlayer) { ++ this.stopRiding(); ++ } ++ // Paper end - Workaround vehicle not tracking the passenger disconnection dismount ++ + if (this.isSleeping()) { + this.stopSleepInBed(true, false); + } +@@ -1625,6 +2080,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1198,7 +1211,7 @@ } @Override -@@ -1661,7 +2110,7 @@ +@@ -1661,7 +2117,7 @@ this.onUpdateAbilities(); if (alive) { this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); @@ -1207,7 +1220,7 @@ this.setHealth(oldPlayer.getHealth()); this.foodData = oldPlayer.foodData; Iterator iterator = oldPlayer.getActiveEffects().iterator(); -@@ -1669,7 +2118,7 @@ +@@ -1669,7 +2125,7 @@ while (iterator.hasNext()) { MobEffectInstance mobeffect = (MobEffectInstance) iterator.next(); @@ -1216,7 +1229,7 @@ } this.getInventory().replaceWith(oldPlayer.getInventory()); -@@ -1680,7 +2129,7 @@ +@@ -1680,7 +2136,7 @@ this.portalProcess = oldPlayer.portalProcess; } else { this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); @@ -1225,7 +1238,7 @@ if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || oldPlayer.isSpectator()) { this.getInventory().replaceWith(oldPlayer.getInventory()); this.experienceLevel = oldPlayer.experienceLevel; -@@ -1696,7 +2145,7 @@ +@@ -1696,7 +2152,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1234,7 +1247,7 @@ this.seenCredits = oldPlayer.seenCredits; this.enteredNetherPosition = oldPlayer.enteredNetherPosition; this.chunkTrackingView = oldPlayer.chunkTrackingView; -@@ -1752,19 +2201,19 @@ +@@ -1752,19 +2208,19 @@ } @Override @@ -1258,7 +1271,7 @@ } return flag1; -@@ -1861,8 +2310,13 @@ +@@ -1861,8 +2317,13 @@ } public void sendChatMessage(OutgoingChatMessage message, boolean filterMaskEnabled, ChatType.Bound params) { @@ -1273,7 +1286,7 @@ } } -@@ -1878,7 +2332,18 @@ +@@ -1878,7 +2339,18 @@ } public void updateOptions(ClientInformation clientOptions) { @@ -1292,7 +1305,7 @@ this.requestedViewDistance = clientOptions.viewDistance(); this.chatVisibility = clientOptions.chatVisibility(); this.canChatColor = clientOptions.chatColors(); -@@ -1957,12 +2422,27 @@ +@@ -1957,12 +2429,27 @@ this.camera = (Entity) (entity == null ? this : entity); if (entity1 != this.camera) { @@ -1321,7 +1334,7 @@ } if (entity != null) { -@@ -1999,11 +2479,11 @@ +@@ -1999,11 +2486,11 @@ @Nullable public Component getTabListDisplayName() { @@ -1335,7 +1348,7 @@ } @Override -@@ -2046,17 +2526,43 @@ +@@ -2046,17 +2533,43 @@ } public void setRespawnPosition(ResourceKey dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage) { @@ -1386,7 +1399,7 @@ } else { this.respawnPosition = null; this.respawnDimension = Level.OVERWORLD; -@@ -2088,18 +2594,44 @@ +@@ -2088,18 +2601,44 @@ } @Override @@ -1435,7 +1448,7 @@ } this.awardStat(Stats.DROP); -@@ -2275,9 +2807,15 @@ +@@ -2275,9 +2814,15 @@ @Override public void stopRiding() { @@ -1452,7 +1465,7 @@ if (entity instanceof LivingEntity entityliving) { Iterator iterator = entityliving.getActiveEffects().iterator(); -@@ -2375,16 +2913,161 @@ +@@ -2375,16 +2920,161 @@ return TicketType.ENDER_PEARL.timeout(); } @@ -1485,8 +1498,8 @@ + } else { + // Adds timeOffset to the beginning of this day. + return this.level().getDayTime() - (this.level().getDayTime() % 24000) + this.timeOffset; - } - } ++ } ++ } + + public WeatherType weather = null; + @@ -1501,14 +1514,14 @@ + + if (plugin) { + this.weather = type; -+ } + } + + if (type == WeatherType.DOWNFALL) { + this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.STOP_RAINING, 0)); + } else { + this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0)); + } -+ } + } + + private float pluginRainPosition; + private float pluginRainPositionPrevious;