Workaround for vehicle tracking issue on disconnect

This commit is contained in:
connorhartley
2019-01-07 14:43:48 -06:00
parent f1f016dd5e
commit 2c43d196e4

View File

@@ -114,7 +114,7 @@
@Nullable @Nullable
private Vec3 startingToFallPosition; private Vec3 startingToFallPosition;
@Nullable @Nullable
@@ -258,7 +293,32 @@ @@ -258,6 +293,31 @@
private final CommandSource commandSource; private final CommandSource commandSource;
private int containerCounter; private int containerCounter;
public boolean wonGame; public boolean wonGame;
@@ -124,7 +124,7 @@
+ public boolean queueHealthUpdatePacket; + public boolean queueHealthUpdatePacket;
+ public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; + public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket;
+ // Paper end - cancellable death event + // Paper end - cancellable death event
+
+ // CraftBukkit start + // CraftBukkit start
+ public CraftPlayer.TransferCookieConnection transferCookieConnection; + public CraftPlayer.TransferCookieConnection transferCookieConnection;
+ public String displayName; + public String displayName;
@@ -143,10 +143,9 @@
+ // CraftBukkit end + // CraftBukkit end
+ public boolean isRealPlayer; // Paper + public boolean isRealPlayer; // Paper
+ public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent + public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
+
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) { public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) {
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
this.chatVisibility = ChatVisiblity.FULL;
@@ -266,7 +326,7 @@ @@ -266,7 +326,7 @@
this.canChatColor = true; this.canChatColor = true;
this.lastActionTime = Util.getMillis(); 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() { public void resetSentInfo() {
this.lastSentHealth = -1.0E8F; this.lastSentHealth = -1.0E8F;
@@ -1198,7 +1211,7 @@
} }
@Override @Override
@@ -1661,7 +2110,7 @@ @@ -1661,7 +2117,7 @@
this.onUpdateAbilities(); this.onUpdateAbilities();
if (alive) { if (alive) {
this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); this.getAttributes().assignBaseValues(oldPlayer.getAttributes());
@@ -1207,7 +1220,7 @@
this.setHealth(oldPlayer.getHealth()); this.setHealth(oldPlayer.getHealth());
this.foodData = oldPlayer.foodData; this.foodData = oldPlayer.foodData;
Iterator iterator = oldPlayer.getActiveEffects().iterator(); Iterator iterator = oldPlayer.getActiveEffects().iterator();
@@ -1669,7 +2118,7 @@ @@ -1669,7 +2125,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
MobEffectInstance mobeffect = (MobEffectInstance) iterator.next(); MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
@@ -1216,7 +1229,7 @@
} }
this.getInventory().replaceWith(oldPlayer.getInventory()); this.getInventory().replaceWith(oldPlayer.getInventory());
@@ -1680,7 +2129,7 @@ @@ -1680,7 +2136,7 @@
this.portalProcess = oldPlayer.portalProcess; this.portalProcess = oldPlayer.portalProcess;
} else { } else {
this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); this.getAttributes().assignBaseValues(oldPlayer.getAttributes());
@@ -1225,7 +1238,7 @@
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || oldPlayer.isSpectator()) { if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || oldPlayer.isSpectator()) {
this.getInventory().replaceWith(oldPlayer.getInventory()); this.getInventory().replaceWith(oldPlayer.getInventory());
this.experienceLevel = oldPlayer.experienceLevel; this.experienceLevel = oldPlayer.experienceLevel;
@@ -1696,7 +2145,7 @@ @@ -1696,7 +2152,7 @@
this.lastSentExp = -1; this.lastSentExp = -1;
this.lastSentHealth = -1.0F; this.lastSentHealth = -1.0F;
this.lastSentFood = -1; this.lastSentFood = -1;
@@ -1234,7 +1247,7 @@
this.seenCredits = oldPlayer.seenCredits; this.seenCredits = oldPlayer.seenCredits;
this.enteredNetherPosition = oldPlayer.enteredNetherPosition; this.enteredNetherPosition = oldPlayer.enteredNetherPosition;
this.chunkTrackingView = oldPlayer.chunkTrackingView; this.chunkTrackingView = oldPlayer.chunkTrackingView;
@@ -1752,19 +2201,19 @@ @@ -1752,19 +2208,19 @@
} }
@Override @Override
@@ -1258,7 +1271,7 @@
} }
return flag1; return flag1;
@@ -1861,8 +2310,13 @@ @@ -1861,8 +2317,13 @@
} }
public void sendChatMessage(OutgoingChatMessage message, boolean filterMaskEnabled, ChatType.Bound params) { 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) { public void updateOptions(ClientInformation clientOptions) {
@@ -1292,7 +1305,7 @@
this.requestedViewDistance = clientOptions.viewDistance(); this.requestedViewDistance = clientOptions.viewDistance();
this.chatVisibility = clientOptions.chatVisibility(); this.chatVisibility = clientOptions.chatVisibility();
this.canChatColor = clientOptions.chatColors(); this.canChatColor = clientOptions.chatColors();
@@ -1957,12 +2422,27 @@ @@ -1957,12 +2429,27 @@
this.camera = (Entity) (entity == null ? this : entity); this.camera = (Entity) (entity == null ? this : entity);
if (entity1 != this.camera) { if (entity1 != this.camera) {
@@ -1321,7 +1334,7 @@
} }
if (entity != null) { if (entity != null) {
@@ -1999,11 +2479,11 @@ @@ -1999,11 +2486,11 @@
@Nullable @Nullable
public Component getTabListDisplayName() { public Component getTabListDisplayName() {
@@ -1335,7 +1348,7 @@
} }
@Override @Override
@@ -2046,17 +2526,43 @@ @@ -2046,17 +2533,43 @@
} }
public void setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage) { public void setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage) {
@@ -1386,7 +1399,7 @@
} else { } else {
this.respawnPosition = null; this.respawnPosition = null;
this.respawnDimension = Level.OVERWORLD; this.respawnDimension = Level.OVERWORLD;
@@ -2088,18 +2594,44 @@ @@ -2088,18 +2601,44 @@
} }
@Override @Override
@@ -1435,7 +1448,7 @@
} }
this.awardStat(Stats.DROP); this.awardStat(Stats.DROP);
@@ -2275,9 +2807,15 @@ @@ -2275,9 +2814,15 @@
@Override @Override
public void stopRiding() { public void stopRiding() {
@@ -1452,7 +1465,7 @@
if (entity instanceof LivingEntity entityliving) { if (entity instanceof LivingEntity entityliving) {
Iterator iterator = entityliving.getActiveEffects().iterator(); Iterator iterator = entityliving.getActiveEffects().iterator();
@@ -2375,16 +2913,161 @@ @@ -2375,16 +2920,161 @@
return TicketType.ENDER_PEARL.timeout(); return TicketType.ENDER_PEARL.timeout();
} }
@@ -1485,8 +1498,8 @@
+ } else { + } else {
+ // Adds timeOffset to the beginning of this day. + // Adds timeOffset to the beginning of this day.
+ return this.level().getDayTime() - (this.level().getDayTime() % 24000) + this.timeOffset; + return this.level().getDayTime() - (this.level().getDayTime() % 24000) + this.timeOffset;
} + }
} + }
+ +
+ public WeatherType weather = null; + public WeatherType weather = null;
+ +
@@ -1501,14 +1514,14 @@
+ +
+ if (plugin) { + if (plugin) {
+ this.weather = type; + this.weather = type;
+ } }
+ +
+ if (type == WeatherType.DOWNFALL) { + if (type == WeatherType.DOWNFALL) {
+ this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.STOP_RAINING, 0)); + this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.STOP_RAINING, 0));
+ } else { + } else {
+ this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0)); + this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0));
+ } + }
+ } }
+ +
+ private float pluginRainPosition; + private float pluginRainPosition;
+ private float pluginRainPositionPrevious; + private float pluginRainPositionPrevious;