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 5fbd32333f..609bdfd7d5 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,6 +293,34 @@ +@@ -258,7 +293,35 @@ private final CommandSource commandSource; private int containerCounter; public boolean wonGame; @@ -125,7 +125,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; @@ -146,9 +146,10 @@ + public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent + public @Nullable String clientBrandName = null; // Paper - Brand support + public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event - ++ public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) { super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); + this.chatVisibility = ChatVisiblity.FULL; @@ -266,7 +329,7 @@ this.canChatColor = true; this.lastActionTime = Util.getMillis(); @@ -158,7 +159,22 @@ this.lastSectionPos = SectionPos.of(0, 0, 0); this.chunkTrackingView = ChunkTrackingView.EMPTY; this.respawnDimension = Level.OVERWORLD; -@@ -316,6 +379,25 @@ +@@ -285,7 +348,14 @@ + + } + ++ // Paper start - Sync offhand slot in menus + @Override ++ public void sendOffHandSlotChange() { ++ ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(ServerPlayer.this.inventoryMenu.containerId, ServerPlayer.this.inventoryMenu.incrementStateId(), net.minecraft.world.inventory.InventoryMenu.SHIELD_SLOT, ServerPlayer.this.inventoryMenu.getSlot(net.minecraft.world.inventory.InventoryMenu.SHIELD_SLOT).getItem().copy())); ++ } ++ // Paper end - Sync offhand slot in menus ++ ++ @Override + public void sendSlotChange(AbstractContainerMenu handler, int slot, ItemStack stack) { + ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(handler.containerId, handler.incrementStateId(), slot, stack)); + } +@@ -316,6 +386,25 @@ } } @@ -184,7 +200,7 @@ @Override public void dataChanged(AbstractContainerMenu handler, int property, int value) {} -@@ -340,6 +422,13 @@ +@@ -340,6 +429,13 @@ public void sendSystemMessage(Component message) { ServerPlayer.this.sendSystemMessage(message); } @@ -198,7 +214,7 @@ }; this.textFilter = server.createTextFilterForPlayer(this); this.gameMode = server.createGameModeForPlayer(this); -@@ -349,17 +438,71 @@ +@@ -349,17 +445,71 @@ this.server = server; this.stats = server.getPlayerList().getPlayerStats(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this); @@ -273,7 +289,7 @@ int i = Math.max(0, this.server.getSpawnRadius(world)); int j = Mth.floor(world.getWorldBorder().getDistanceToBorder((double) basePos.getX(), (double) basePos.getZ())); -@@ -395,14 +538,20 @@ +@@ -395,14 +545,20 @@ Objects.requireNonNull(basePos); crashreportsystemdetails.setDetail("Origin", basePos::toString); @@ -296,7 +312,7 @@ }); throw new ReportedException(crashreport); } -@@ -440,7 +589,7 @@ +@@ -440,7 +596,7 @@ dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(NbtOps.INSTANCE, nbt.get("warden_spawn_tracker"))); logger = ServerPlayer.LOGGER; Objects.requireNonNull(logger); @@ -305,7 +321,7 @@ this.wardenSpawnTracker = wardenspawntracker; }); } -@@ -457,17 +606,26 @@ +@@ -457,17 +613,26 @@ return this.server.getRecipeManager().byKey(resourcekey).isPresent(); }); } @@ -333,7 +349,7 @@ Logger logger1 = ServerPlayer.LOGGER; Objects.requireNonNull(logger1); -@@ -482,7 +640,7 @@ +@@ -482,7 +647,7 @@ dataresult = BlockPos.CODEC.parse(NbtOps.INSTANCE, nbtbase); logger = ServerPlayer.LOGGER; Objects.requireNonNull(logger); @@ -342,7 +358,7 @@ this.raidOmenPosition = blockposition; }); } -@@ -492,7 +650,7 @@ +@@ -492,7 +657,7 @@ @Override public void addAdditionalSaveData(CompoundTag nbt) { super.addAdditionalSaveData(nbt); @@ -351,7 +367,7 @@ Logger logger = ServerPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -526,6 +684,7 @@ +@@ -526,6 +691,7 @@ nbt.put("SpawnDimension", nbtbase); }); } @@ -359,7 +375,7 @@ nbt.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall); if (this.raidOmenPosition != null) { -@@ -544,7 +703,20 @@ +@@ -544,7 +710,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -381,7 +397,7 @@ CompoundTag nbttagcompound1 = new CompoundTag(); CompoundTag nbttagcompound2 = new CompoundTag(); -@@ -564,7 +736,7 @@ +@@ -564,7 +743,7 @@ ServerLevel worldserver = (ServerLevel) world; CompoundTag nbttagcompound = ((CompoundTag) nbt.get()).getCompound("RootVehicle"); Entity entity = EntityType.loadEntityRecursive(nbttagcompound.getCompound("Entity"), worldserver, EntitySpawnReason.LOAD, (entity1) -> { @@ -390,7 +406,7 @@ }); if (entity == null) { -@@ -598,12 +770,12 @@ +@@ -598,12 +777,12 @@ if (!this.isPassenger()) { ServerPlayer.LOGGER.warn("Couldn't reattach entity to player"); @@ -405,7 +421,7 @@ } } } -@@ -625,7 +797,7 @@ +@@ -625,7 +804,7 @@ CompoundTag nbttagcompound1 = new CompoundTag(); entityenderpearl.save(nbttagcompound1); @@ -414,7 +430,7 @@ Logger logger = ServerPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -651,7 +823,7 @@ +@@ -651,7 +830,7 @@ nbttaglist.forEach((nbtbase1) -> { if (nbtbase1 instanceof CompoundTag nbttagcompound) { if (nbttagcompound.contains("ender_pearl_dimension")) { @@ -423,10 +439,12 @@ Logger logger = ServerPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -686,6 +858,29 @@ - - } +@@ -684,7 +863,30 @@ + } + } ++ } ++ + // CraftBukkit start - World fallback code, either respawn location or global spawn + public void spawnIn(Level world) { + this.setLevel(world); @@ -447,13 +465,12 @@ + this.setPosRaw(position.x(), position.y(), position.z()); // Paper - don't register to chunks yet + } + this.gameMode.setLevel((ServerLevel) world); -+ } + } + // CraftBukkit end -+ + public void setExperiencePoints(int points) { float f = (float) this.getXpNeededForNextLevel(); - float f1 = (f - 1.0F) / f; -@@ -744,6 +939,11 @@ +@@ -744,6 +946,11 @@ @Override public void tick() { @@ -465,7 +482,7 @@ this.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -751,9 +951,13 @@ +@@ -751,9 +958,13 @@ --this.invulnerableTime; } @@ -482,7 +499,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -807,7 +1011,7 @@ +@@ -807,7 +1018,7 @@ public void doTick() { try { @@ -491,7 +508,7 @@ super.tick(); } -@@ -820,7 +1024,7 @@ +@@ -820,7 +1031,7 @@ } if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -500,7 +517,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -851,6 +1055,12 @@ +@@ -851,6 +1062,12 @@ this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float) this.lastRecordedExperience)); } @@ -513,15 +530,17 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float) this.lastRecordedLevel)); -@@ -865,6 +1075,20 @@ - CriteriaTriggers.LOCATION.trigger(this); - } +@@ -863,8 +1080,22 @@ + if (this.tickCount % 20 == 0) { + CriteriaTriggers.LOCATION.trigger(this); ++ } ++ + // CraftBukkit start - initialize oldLevel, fire PlayerLevelChangeEvent, and tick client-sided world border + if (this.oldLevel == -1) { + this.oldLevel = this.experienceLevel; -+ } -+ + } + + if (this.oldLevel != this.experienceLevel) { + CraftEventFactory.callPlayerLevelChangeEvent(this.getBukkitEntity(), this.oldLevel, this.experienceLevel); + this.oldLevel = this.experienceLevel; @@ -534,7 +553,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Player being ticked"); -@@ -893,7 +1117,7 @@ +@@ -893,7 +1124,7 @@ if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (this.tickCount % 20 == 0) { if (this.getHealth() < this.getMaxHealth()) { @@ -543,7 +562,7 @@ } float f = this.foodData.getSaturationLevel(); -@@ -946,19 +1170,105 @@ +@@ -946,19 +1177,105 @@ } private void updateScoreForCriteria(ObjectiveCriteria criterion, int score) { @@ -653,7 +672,7 @@ this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> { boolean flag1 = true; String s = ichatbasecomponent.getString(256); -@@ -988,12 +1298,23 @@ +@@ -988,12 +1305,23 @@ if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { this.tellNeutralMobsThatIDied(); } @@ -681,7 +700,7 @@ LivingEntity entityliving = this.getKillCredit(); if (entityliving != null) { -@@ -1028,10 +1349,12 @@ +@@ -1028,10 +1356,12 @@ public void awardKillScore(Entity entityKilled, DamageSource damageSource) { if (entityKilled != this) { super.awardKillScore(entityKilled, damageSource); @@ -697,7 +716,7 @@ } else { this.awardStat(Stats.MOB_KILLS); } -@@ -1049,7 +1372,8 @@ +@@ -1049,7 +1379,8 @@ int i = scoreboardteam.getColor().getId(); if (i >= 0 && i < criterions.length) { @@ -707,7 +726,7 @@ } } -@@ -1062,8 +1386,8 @@ +@@ -1062,8 +1393,8 @@ } else { Entity entity = source.getEntity(); @@ -718,7 +737,7 @@ if (!this.canHarmPlayer(entityhuman)) { return false; -@@ -1074,8 +1398,8 @@ +@@ -1074,8 +1405,8 @@ AbstractArrow entityarrow = (AbstractArrow) entity; Entity entity1 = entityarrow.getOwner(); @@ -729,7 +748,7 @@ if (!this.canHarmPlayer(entityhuman1)) { return false; -@@ -1083,38 +1407,84 @@ +@@ -1083,38 +1414,84 @@ } } @@ -822,7 +841,7 @@ } public static Optional findRespawnAndUseSpawnBlock(ServerLevel world, BlockPos pos, float spawnAngle, boolean spawnForced, boolean alive) { -@@ -1129,11 +1499,11 @@ +@@ -1129,11 +1506,11 @@ } return optional.map((vec3d) -> { @@ -836,7 +855,7 @@ }); } else if (!spawnForced) { return Optional.empty(); -@@ -1142,7 +1512,7 @@ +@@ -1142,7 +1519,7 @@ BlockState iblockdata1 = world.getBlockState(pos.above()); boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1); @@ -845,7 +864,7 @@ } } -@@ -1160,6 +1530,7 @@ +@@ -1160,6 +1537,7 @@ @Nullable @Override public ServerPlayer teleport(TeleportTransition teleportTarget) { @@ -853,7 +872,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1169,39 +1540,78 @@ +@@ -1169,39 +1547,78 @@ ServerLevel worldserver = teleportTarget.newLevel(); ServerLevel worldserver1 = this.serverLevel(); @@ -940,7 +959,7 @@ this.connection.resetPosition(); worldserver.addDuringTeleport(this); gameprofilerfiller.pop(); -@@ -1215,10 +1625,33 @@ +@@ -1215,12 +1632,35 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -956,25 +975,27 @@ + // Paper end - Reset shield blocking on dimension change return this; } -+ } -+ } -+ + } + } + + // CraftBukkit start -+ @Override + @Override + public CraftPortalEvent callPortalEvent(Entity entity, Location exit, TeleportCause cause, int searchRadius, int creationRadius) { + Location enter = this.getBukkitEntity().getLocation(); + 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) { + return null; - } ++ } + return new CraftPortalEvent(event); - } ++ } + // CraftBukkit end - - @Override ++ ++ @Override public void forceSetRotation(float yaw, float pitch) { -@@ -1228,13 +1661,27 @@ + this.connection.send(new ClientboundPlayerRotationPacket(yaw, pitch)); + } +@@ -1228,13 +1668,27 @@ public void triggerDimensionChangeTriggers(ServerLevel origin) { ResourceKey resourcekey = origin.dimension(); ResourceKey resourcekey1 = this.level().dimension(); @@ -1005,7 +1026,7 @@ this.enteredNetherPosition = null; } -@@ -1251,36 +1698,63 @@ +@@ -1251,36 +1705,63 @@ this.containerMenu.broadcastChanges(); } @@ -1084,7 +1105,7 @@ this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1293,9 +1767,8 @@ +@@ -1293,9 +1774,8 @@ return either; } } @@ -1095,7 +1116,7 @@ } @Override -@@ -1322,13 +1795,31 @@ +@@ -1322,13 +1802,31 @@ @Override public void stopSleepInBed(boolean skipSleepTimer, boolean updateSleepingPlayers) { @@ -1128,7 +1149,7 @@ } } -@@ -1341,7 +1832,7 @@ +@@ -1341,7 +1839,7 @@ @Override public boolean isInvulnerableTo(ServerLevel world, DamageSource source) { @@ -1137,7 +1158,7 @@ } @Override -@@ -1387,8 +1878,9 @@ +@@ -1387,8 +1885,9 @@ this.connection.send(new ClientboundOpenSignEditorPacket(sign.getBlockPos(), front)); } @@ -1148,7 +1169,7 @@ } @Override -@@ -1396,13 +1888,35 @@ +@@ -1396,13 +1895,35 @@ if (factory == null) { return OptionalInt.empty(); } else { @@ -1184,7 +1205,7 @@ if (container == null) { if (this.isSpectator()) { this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); -@@ -1410,9 +1924,11 @@ +@@ -1410,9 +1931,11 @@ return OptionalInt.empty(); } else { @@ -1198,7 +1219,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1425,15 +1941,26 @@ +@@ -1425,15 +1948,26 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -1228,7 +1249,7 @@ this.initMenu(this.containerMenu); } -@@ -1456,9 +1983,28 @@ +@@ -1456,9 +1990,28 @@ @Override public void closeContainer() { @@ -1257,7 +1278,7 @@ @Override public void doCloseContainer() { -@@ -1485,19 +2031,19 @@ +@@ -1485,19 +2038,19 @@ i = Math.round((float) Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) * 100.0F); if (i > 0) { this.awardStat(Stats.SWIM_ONE_CM, i); @@ -1280,7 +1301,7 @@ } } else if (this.onClimbable()) { if (deltaY > 0.0D) { -@@ -1508,13 +2054,13 @@ +@@ -1508,13 +2061,13 @@ if (i > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, i); @@ -1297,7 +1318,7 @@ } } } else if (this.isFallFlying()) { -@@ -1557,7 +2103,7 @@ +@@ -1557,7 +2110,7 @@ @Override public void awardStat(Stat stat, int amount) { this.stats.increment(this, stat, amount); @@ -1306,7 +1327,7 @@ scoreaccess.add(amount); }); } -@@ -1565,7 +2111,7 @@ +@@ -1565,7 +2118,7 @@ @Override public void resetStat(Stat stat) { this.stats.setValue(this, stat, 0); @@ -1315,7 +1336,7 @@ } @Override -@@ -1597,9 +2143,9 @@ +@@ -1597,9 +2150,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1327,7 +1348,7 @@ } } -@@ -1613,6 +2159,13 @@ +@@ -1613,6 +2166,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1341,7 +1362,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1625,6 +2178,7 @@ +@@ -1625,6 +2185,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1349,7 +1370,7 @@ } @Override -@@ -1661,7 +2215,7 @@ +@@ -1661,7 +2222,7 @@ this.onUpdateAbilities(); if (alive) { this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); @@ -1358,7 +1379,7 @@ this.setHealth(oldPlayer.getHealth()); this.foodData = oldPlayer.foodData; Iterator iterator = oldPlayer.getActiveEffects().iterator(); -@@ -1669,7 +2223,7 @@ +@@ -1669,7 +2230,7 @@ while (iterator.hasNext()) { MobEffectInstance mobeffect = (MobEffectInstance) iterator.next(); @@ -1367,7 +1388,7 @@ } this.getInventory().replaceWith(oldPlayer.getInventory()); -@@ -1680,7 +2234,7 @@ +@@ -1680,7 +2241,7 @@ this.portalProcess = oldPlayer.portalProcess; } else { this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); @@ -1376,7 +1397,7 @@ if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || oldPlayer.isSpectator()) { this.getInventory().replaceWith(oldPlayer.getInventory()); this.experienceLevel = oldPlayer.experienceLevel; -@@ -1696,7 +2250,7 @@ +@@ -1696,7 +2257,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1385,7 +1406,7 @@ this.seenCredits = oldPlayer.seenCredits; this.enteredNetherPosition = oldPlayer.enteredNetherPosition; this.chunkTrackingView = oldPlayer.chunkTrackingView; -@@ -1752,19 +2306,19 @@ +@@ -1752,19 +2313,19 @@ } @Override @@ -1409,7 +1430,7 @@ } return flag1; -@@ -1799,10 +2353,18 @@ +@@ -1799,10 +2360,18 @@ } public boolean setGameMode(GameType gameMode) { @@ -1430,7 +1451,7 @@ } else { this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) gameMode.getId())); if (gameMode == GameType.SPECTATOR) { -@@ -1818,7 +2380,7 @@ +@@ -1818,7 +2387,7 @@ this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1439,7 +1460,7 @@ } } -@@ -1861,8 +2423,13 @@ +@@ -1861,8 +2430,13 @@ } public void sendChatMessage(OutgoingChatMessage message, boolean filterMaskEnabled, ChatType.Bound params) { @@ -1454,7 +1475,7 @@ } } -@@ -1878,7 +2445,36 @@ +@@ -1878,7 +2452,36 @@ } public void updateOptions(ClientInformation clientOptions) { @@ -1491,7 +1512,7 @@ this.requestedViewDistance = clientOptions.viewDistance(); this.chatVisibility = clientOptions.chatVisibility(); this.canChatColor = clientOptions.chatColors(); -@@ -1957,12 +2553,27 @@ +@@ -1957,12 +2560,27 @@ this.camera = (Entity) (entity == null ? this : entity); if (entity1 != this.camera) { @@ -1520,7 +1541,7 @@ } if (entity != null) { -@@ -1999,11 +2610,11 @@ +@@ -1999,11 +2617,11 @@ @Nullable public Component getTabListDisplayName() { @@ -1534,7 +1555,7 @@ } @Override -@@ -2045,12 +2656,44 @@ +@@ -2045,12 +2663,44 @@ this.setRespawnPosition(player.getRespawnDimension(), player.getRespawnPosition(), player.getRespawnAngle(), player.isRespawnForced(), false); } @@ -1581,7 +1602,7 @@ } this.respawnPosition = pos; -@@ -2064,6 +2707,7 @@ +@@ -2064,6 +2714,7 @@ this.respawnForced = false; } @@ -1589,7 +1610,7 @@ } public SectionPos getLastSectionPos() { -@@ -2088,18 +2732,44 @@ +@@ -2088,18 +2739,44 @@ } @Override @@ -1638,7 +1659,7 @@ } this.awardStat(Stats.DROP); -@@ -2115,6 +2785,11 @@ +@@ -2115,6 +2792,11 @@ return null; } else { double d0 = this.getEyeY() - 0.30000001192092896D; @@ -1650,7 +1671,7 @@ ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), d0, this.getZ(), stack); entityitem.setPickUpDelay(40); -@@ -2166,6 +2841,16 @@ +@@ -2166,6 +2848,16 @@ } public void loadGameTypes(@Nullable CompoundTag nbt) { @@ -1667,7 +1688,7 @@ this.gameMode.setGameModeForPlayer(this.calculateGameModeForNewPlayer(ServerPlayer.readPlayerMode(nbt, "playerGameType")), ServerPlayer.readPlayerMode(nbt, "previousPlayerGameType")); } -@@ -2275,9 +2960,15 @@ +@@ -2275,9 +2967,15 @@ @Override public void stopRiding() { @@ -1684,7 +1705,7 @@ if (entity instanceof LivingEntity entityliving) { Iterator iterator = entityliving.getActiveEffects().iterator(); -@@ -2375,10 +3066,12 @@ +@@ -2375,10 +3073,12 @@ return TicketType.ENDER_PEARL.timeout(); } @@ -1700,7 +1721,7 @@ } private static float calculateLookAtYaw(Vec3 respawnPos, BlockPos currentPos) { -@@ -2387,4 +3080,147 @@ +@@ -2387,4 +3087,147 @@ return (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); } } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index 8a1feeb6bf..7b3d185a8f 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -61,7 +61,12 @@ protected AbstractContainerMenu(@Nullable MenuType type, int syncId) { this.carried = ItemStack.EMPTY; -@@ -192,6 +232,15 @@ +@@ -188,10 +228,20 @@ + + if (this.synchronizer != null) { + this.synchronizer.sendInitialData(this, this.remoteSlots, this.remoteCarried, this.remoteDataSlots.toIntArray()); ++ this.synchronizer.sendOffHandSlotChange(); // Paper - Sync offhand slot in menus; update player's offhand since the offhand slot is not added to the slots for menus but can be changed by swapping from a menu slot + } } @@ -77,7 +82,7 @@ public void removeSlotListener(ContainerListener listener) { this.containerListeners.remove(listener); } -@@ -281,7 +330,7 @@ +@@ -281,7 +331,7 @@ while (iterator.hasNext()) { ContainerListener icrafting = (ContainerListener) iterator.next(); @@ -86,7 +91,7 @@ } } -@@ -417,7 +466,7 @@ +@@ -417,7 +467,7 @@ } } else if (this.quickcraftStatus == 2) { if (!this.quickcraftSlots.isEmpty()) { @@ -95,7 +100,7 @@ k = ((Slot) this.quickcraftSlots.iterator().next()).index; this.resetQuickCraft(); this.doClick(k, this.quickcraftType, ClickType.PICKUP, player); -@@ -433,6 +482,7 @@ +@@ -433,6 +483,7 @@ l = this.getCarried().getCount(); Iterator iterator = this.quickcraftSlots.iterator(); @@ -103,7 +108,7 @@ while (iterator.hasNext()) { Slot slot1 = (Slot) iterator.next(); ItemStack itemstack2 = this.getCarried(); -@@ -443,12 +493,48 @@ +@@ -443,12 +494,48 @@ int l1 = Math.min(AbstractContainerMenu.getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemstack1) + j1, k1); l -= l1 - j1; @@ -155,7 +160,7 @@ } this.resetQuickCraft(); -@@ -466,8 +552,11 @@ +@@ -466,8 +553,11 @@ if (slotIndex == -999) { if (!this.getCarried().isEmpty()) { if (clickaction == ClickAction.PRIMARY) { @@ -168,7 +173,7 @@ } else { player.drop(this.getCarried().split(1), true); } -@@ -530,6 +619,15 @@ +@@ -530,6 +620,15 @@ } slot.setChanged(); @@ -184,7 +189,7 @@ } } else { int j2; -@@ -662,8 +760,9 @@ +@@ -662,8 +761,9 @@ ItemStack itemstack = this.getCarried(); if (!itemstack.isEmpty()) { @@ -195,7 +200,7 @@ } } -@@ -893,6 +992,11 @@ +@@ -893,6 +993,11 @@ } public ItemStack getCarried() { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ContainerSynchronizer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ContainerSynchronizer.java.patch new file mode 100644 index 0000000000..a76ea56e99 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ContainerSynchronizer.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/inventory/ContainerSynchronizer.java ++++ b/net/minecraft/world/inventory/ContainerSynchronizer.java +@@ -6,6 +6,7 @@ + public interface ContainerSynchronizer { + void sendInitialData(AbstractContainerMenu handler, NonNullList stacks, ItemStack cursorStack, int[] properties); + ++ default void sendOffHandSlotChange() {} // Paper - Sync offhand slot in menus + void sendSlotChange(AbstractContainerMenu handler, int slot, ItemStack stack); + + void sendCarriedChange(AbstractContainerMenu handler, ItemStack stack);