From 4f1619700a472b36ff5895922c3e0573b28a3279 Mon Sep 17 00:00:00 2001 From: Jakub Zacek <dawon@dawon.eu> Date: Sun, 24 Apr 2022 22:56:59 +0200 Subject: [PATCH] Add PlayerInventorySlotChangeEvent --- .../server/level/ServerPlayer.java.patch | 200 ++++++++++-------- .../AbstractContainerMenu.java.patch | 17 +- .../inventory/ContainerListener.java.patch | 14 ++ 3 files changed, 139 insertions(+), 92 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/world/inventory/ContainerListener.java.patch 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 44c03dc91a..5fbd32333f 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 @@ -158,7 +158,33 @@ this.lastSectionPos = SectionPos.of(0, 0, 0); this.chunkTrackingView = ChunkTrackingView.EMPTY; this.respawnDimension = Level.OVERWORLD; -@@ -340,6 +403,13 @@ +@@ -316,6 +379,25 @@ + + } + } ++ // Paper start - Add PlayerInventorySlotChangeEvent ++ @Override ++ public void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack oldStack, ItemStack stack) { ++ Slot slot = handler.getSlot(slotId); ++ if (!(slot instanceof ResultSlot)) { ++ if (slot.container == ServerPlayer.this.getInventory()) { ++ if (io.papermc.paper.event.player.PlayerInventorySlotChangeEvent.getHandlerList().getRegisteredListeners().length == 0) { ++ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack); ++ return; ++ } ++ io.papermc.paper.event.player.PlayerInventorySlotChangeEvent event = new io.papermc.paper.event.player.PlayerInventorySlotChangeEvent(ServerPlayer.this.getBukkitEntity(), slotId, CraftItemStack.asBukkitCopy(oldStack), CraftItemStack.asBukkitCopy(stack)); ++ event.callEvent(); ++ if (event.shouldTriggerAdvancements()) { ++ CriteriaTriggers.INVENTORY_CHANGED.trigger(ServerPlayer.this, ServerPlayer.this.getInventory(), stack); ++ } ++ } ++ } ++ } ++ // Paper end - Add PlayerInventorySlotChangeEvent + + @Override + public void dataChanged(AbstractContainerMenu handler, int property, int value) {} +@@ -340,6 +422,13 @@ public void sendSystemMessage(Component message) { ServerPlayer.this.sendSystemMessage(message); } @@ -172,7 +198,7 @@ }; this.textFilter = server.createTextFilterForPlayer(this); this.gameMode = server.createGameModeForPlayer(this); -@@ -349,17 +419,71 @@ +@@ -349,17 +438,71 @@ this.server = server; this.stats = server.getPlayerList().getPlayerStats(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this); @@ -187,8 +213,8 @@ + this.adventure$displayName = net.kyori.adventure.text.Component.text(this.getScoreboardName()); // Paper + this.bukkitPickUpLoot = true; + this.maxHealthCache = this.getMaxHealth(); -+ } -+ + } + + // Use method to resend items in hands in case of client desync, because the item use got cancelled. + // For example, when cancelling the leash event + public void resendItemInHands() { @@ -234,9 +260,9 @@ + } + + return blockposition; - } ++ } + // CraftBukkit end - ++ @Override public BlockPos adjustSpawnLocation(ServerLevel world, BlockPos basePos) { AABB axisalignedbb = this.getDimensions(Pose.STANDING).makeBoundingBox(Vec3.ZERO); @@ -247,7 +273,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 +519,20 @@ +@@ -395,14 +538,20 @@ Objects.requireNonNull(basePos); crashreportsystemdetails.setDetail("Origin", basePos::toString); @@ -270,7 +296,7 @@ }); throw new ReportedException(crashreport); } -@@ -440,7 +570,7 @@ +@@ -440,7 +589,7 @@ dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(NbtOps.INSTANCE, nbt.get("warden_spawn_tracker"))); logger = ServerPlayer.LOGGER; Objects.requireNonNull(logger); @@ -279,7 +305,7 @@ this.wardenSpawnTracker = wardenspawntracker; }); } -@@ -457,17 +587,26 @@ +@@ -457,17 +606,26 @@ return this.server.getRecipeManager().byKey(resourcekey).isPresent(); }); } @@ -288,7 +314,7 @@ if (this.isSleeping()) { this.stopSleeping(); } -+ + + // CraftBukkit start + String spawnWorld = nbt.getString("SpawnWorld"); + CraftWorld oldWorld = (CraftWorld) Bukkit.getWorld(spawnWorld); @@ -296,7 +322,7 @@ + this.respawnDimension = oldWorld.getHandle().dimension(); + } + // CraftBukkit end - ++ if (nbt.contains("SpawnX", 99) && nbt.contains("SpawnY", 99) && nbt.contains("SpawnZ", 99)) { this.respawnPosition = new BlockPos(nbt.getInt("SpawnX"), nbt.getInt("SpawnY"), nbt.getInt("SpawnZ")); this.respawnForced = nbt.getBoolean("SpawnForced"); @@ -307,7 +333,7 @@ Logger logger1 = ServerPlayer.LOGGER; Objects.requireNonNull(logger1); -@@ -482,7 +621,7 @@ +@@ -482,7 +640,7 @@ dataresult = BlockPos.CODEC.parse(NbtOps.INSTANCE, nbtbase); logger = ServerPlayer.LOGGER; Objects.requireNonNull(logger); @@ -316,7 +342,7 @@ this.raidOmenPosition = blockposition; }); } -@@ -492,7 +631,7 @@ +@@ -492,7 +650,7 @@ @Override public void addAdditionalSaveData(CompoundTag nbt) { super.addAdditionalSaveData(nbt); @@ -325,7 +351,7 @@ Logger logger = ServerPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -526,6 +665,7 @@ +@@ -526,6 +684,7 @@ nbt.put("SpawnDimension", nbtbase); }); } @@ -333,7 +359,7 @@ nbt.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall); if (this.raidOmenPosition != null) { -@@ -544,7 +684,20 @@ +@@ -544,7 +703,20 @@ Entity entity = this.getRootVehicle(); Entity entity1 = this.getVehicle(); @@ -355,7 +381,7 @@ CompoundTag nbttagcompound1 = new CompoundTag(); CompoundTag nbttagcompound2 = new CompoundTag(); -@@ -564,7 +717,7 @@ +@@ -564,7 +736,7 @@ ServerLevel worldserver = (ServerLevel) world; CompoundTag nbttagcompound = ((CompoundTag) nbt.get()).getCompound("RootVehicle"); Entity entity = EntityType.loadEntityRecursive(nbttagcompound.getCompound("Entity"), worldserver, EntitySpawnReason.LOAD, (entity1) -> { @@ -364,7 +390,7 @@ }); if (entity == null) { -@@ -598,12 +751,12 @@ +@@ -598,12 +770,12 @@ if (!this.isPassenger()) { ServerPlayer.LOGGER.warn("Couldn't reattach entity to player"); @@ -379,7 +405,7 @@ } } } -@@ -625,7 +778,7 @@ +@@ -625,7 +797,7 @@ CompoundTag nbttagcompound1 = new CompoundTag(); entityenderpearl.save(nbttagcompound1); @@ -388,7 +414,7 @@ Logger logger = ServerPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -651,7 +804,7 @@ +@@ -651,7 +823,7 @@ nbttaglist.forEach((nbtbase1) -> { if (nbtbase1 instanceof CompoundTag nbttagcompound) { if (nbttagcompound.contains("ender_pearl_dimension")) { @@ -397,7 +423,7 @@ Logger logger = ServerPlayer.LOGGER; Objects.requireNonNull(logger); -@@ -686,6 +839,29 @@ +@@ -686,6 +858,29 @@ } @@ -427,7 +453,7 @@ public void setExperiencePoints(int points) { float f = (float) this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -744,6 +920,11 @@ +@@ -744,6 +939,11 @@ @Override public void tick() { @@ -439,7 +465,7 @@ this.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -751,9 +932,13 @@ +@@ -751,9 +951,13 @@ --this.invulnerableTime; } @@ -456,7 +482,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -807,7 +992,7 @@ +@@ -807,7 +1011,7 @@ public void doTick() { try { @@ -465,7 +491,7 @@ super.tick(); } -@@ -820,7 +1005,7 @@ +@@ -820,7 +1024,7 @@ } if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -474,7 +500,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -851,6 +1036,12 @@ +@@ -851,6 +1055,12 @@ this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float) this.lastRecordedExperience)); } @@ -487,7 +513,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float) this.lastRecordedLevel)); -@@ -865,6 +1056,20 @@ +@@ -865,6 +1075,20 @@ CriteriaTriggers.LOCATION.trigger(this); } @@ -508,7 +534,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Player being ticked"); -@@ -893,7 +1098,7 @@ +@@ -893,7 +1117,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()) { @@ -517,7 +543,7 @@ } float f = this.foodData.getSaturationLevel(); -@@ -946,19 +1151,105 @@ +@@ -946,19 +1170,105 @@ } private void updateScoreForCriteria(ObjectiveCriteria criterion, int score) { @@ -627,7 +653,7 @@ this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> { boolean flag1 = true; String s = ichatbasecomponent.getString(256); -@@ -988,12 +1279,23 @@ +@@ -988,12 +1298,23 @@ if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { this.tellNeutralMobsThatIDied(); } @@ -655,7 +681,7 @@ LivingEntity entityliving = this.getKillCredit(); if (entityliving != null) { -@@ -1028,10 +1330,12 @@ +@@ -1028,10 +1349,12 @@ public void awardKillScore(Entity entityKilled, DamageSource damageSource) { if (entityKilled != this) { super.awardKillScore(entityKilled, damageSource); @@ -671,7 +697,7 @@ } else { this.awardStat(Stats.MOB_KILLS); } -@@ -1049,7 +1353,8 @@ +@@ -1049,7 +1372,8 @@ int i = scoreboardteam.getColor().getId(); if (i >= 0 && i < criterions.length) { @@ -681,7 +707,7 @@ } } -@@ -1062,8 +1367,8 @@ +@@ -1062,8 +1386,8 @@ } else { Entity entity = source.getEntity(); @@ -692,7 +718,7 @@ if (!this.canHarmPlayer(entityhuman)) { return false; -@@ -1074,8 +1379,8 @@ +@@ -1074,8 +1398,8 @@ AbstractArrow entityarrow = (AbstractArrow) entity; Entity entity1 = entityarrow.getOwner(); @@ -703,7 +729,7 @@ if (!this.canHarmPlayer(entityhuman1)) { return false; -@@ -1083,38 +1388,84 @@ +@@ -1083,38 +1407,84 @@ } } @@ -796,7 +822,7 @@ } public static Optional<ServerPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(ServerLevel world, BlockPos pos, float spawnAngle, boolean spawnForced, boolean alive) { -@@ -1129,11 +1480,11 @@ +@@ -1129,11 +1499,11 @@ } return optional.map((vec3d) -> { @@ -810,7 +836,7 @@ }); } else if (!spawnForced) { return Optional.empty(); -@@ -1142,7 +1493,7 @@ +@@ -1142,7 +1512,7 @@ BlockState iblockdata1 = world.getBlockState(pos.above()); boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1); @@ -819,7 +845,7 @@ } } -@@ -1160,6 +1511,7 @@ +@@ -1160,6 +1530,7 @@ @Nullable @Override public ServerPlayer teleport(TeleportTransition teleportTarget) { @@ -827,7 +853,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1169,39 +1521,78 @@ +@@ -1169,39 +1540,78 @@ ServerLevel worldserver = teleportTarget.newLevel(); ServerLevel worldserver1 = this.serverLevel(); @@ -914,7 +940,7 @@ this.connection.resetPosition(); worldserver.addDuringTeleport(this); gameprofilerfiller.pop(); -@@ -1215,12 +1606,35 @@ +@@ -1215,10 +1625,33 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -930,27 +956,25 @@ + // 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 - public void forceSetRotation(float yaw, float pitch) { - this.connection.send(new ClientboundPlayerRotationPacket(yaw, pitch)); } -@@ -1228,13 +1642,27 @@ ++ // CraftBukkit end + + @Override + public void forceSetRotation(float yaw, float pitch) { +@@ -1228,13 +1661,27 @@ public void triggerDimensionChangeTriggers(ServerLevel origin) { ResourceKey<Level> resourcekey = origin.dimension(); ResourceKey<Level> resourcekey1 = this.level().dimension(); @@ -981,7 +1005,7 @@ this.enteredNetherPosition = null; } -@@ -1251,36 +1679,63 @@ +@@ -1251,36 +1698,63 @@ this.containerMenu.broadcastChanges(); } @@ -1060,7 +1084,7 @@ this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1293,9 +1748,8 @@ +@@ -1293,9 +1767,8 @@ return either; } } @@ -1071,7 +1095,7 @@ } @Override -@@ -1322,13 +1776,31 @@ +@@ -1322,13 +1795,31 @@ @Override public void stopSleepInBed(boolean skipSleepTimer, boolean updateSleepingPlayers) { @@ -1104,7 +1128,7 @@ } } -@@ -1341,7 +1813,7 @@ +@@ -1341,7 +1832,7 @@ @Override public boolean isInvulnerableTo(ServerLevel world, DamageSource source) { @@ -1113,7 +1137,7 @@ } @Override -@@ -1387,8 +1859,9 @@ +@@ -1387,8 +1878,9 @@ this.connection.send(new ClientboundOpenSignEditorPacket(sign.getBlockPos(), front)); } @@ -1124,7 +1148,7 @@ } @Override -@@ -1396,13 +1869,35 @@ +@@ -1396,13 +1888,35 @@ if (factory == null) { return OptionalInt.empty(); } else { @@ -1160,7 +1184,7 @@ if (container == null) { if (this.isSpectator()) { this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); -@@ -1410,9 +1905,11 @@ +@@ -1410,9 +1924,11 @@ return OptionalInt.empty(); } else { @@ -1174,7 +1198,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1425,15 +1922,26 @@ +@@ -1425,15 +1941,26 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -1204,7 +1228,7 @@ this.initMenu(this.containerMenu); } -@@ -1456,9 +1964,28 @@ +@@ -1456,9 +1983,28 @@ @Override public void closeContainer() { @@ -1217,7 +1241,7 @@ + // Paper end - Inventory close reason this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId)); this.doCloseContainer(); -+ } + } + // Paper start - special close for unloaded inventory + @Override + public void closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { @@ -1228,12 +1252,12 @@ + this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId)); + this.containerMenu = this.inventoryMenu; + // do not run close logic - } ++ } + // Paper end - special close for unloaded inventory @Override public void doCloseContainer() { -@@ -1485,19 +2012,19 @@ +@@ -1485,19 +2031,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); @@ -1256,7 +1280,7 @@ } } else if (this.onClimbable()) { if (deltaY > 0.0D) { -@@ -1508,13 +2035,13 @@ +@@ -1508,13 +2054,13 @@ if (i > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, i); @@ -1273,7 +1297,7 @@ } } } else if (this.isFallFlying()) { -@@ -1557,7 +2084,7 @@ +@@ -1557,7 +2103,7 @@ @Override public void awardStat(Stat<?> stat, int amount) { this.stats.increment(this, stat, amount); @@ -1282,7 +1306,7 @@ scoreaccess.add(amount); }); } -@@ -1565,7 +2092,7 @@ +@@ -1565,7 +2111,7 @@ @Override public void resetStat(Stat<?> stat) { this.stats.setValue(this, stat, 0); @@ -1291,7 +1315,7 @@ } @Override -@@ -1597,9 +2124,9 @@ +@@ -1597,9 +2143,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1303,7 +1327,7 @@ } } -@@ -1613,6 +2140,13 @@ +@@ -1613,6 +2159,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1317,7 +1341,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1625,6 +2159,7 @@ +@@ -1625,6 +2178,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1325,7 +1349,7 @@ } @Override -@@ -1661,7 +2196,7 @@ +@@ -1661,7 +2215,7 @@ this.onUpdateAbilities(); if (alive) { this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); @@ -1334,7 +1358,7 @@ this.setHealth(oldPlayer.getHealth()); this.foodData = oldPlayer.foodData; Iterator iterator = oldPlayer.getActiveEffects().iterator(); -@@ -1669,7 +2204,7 @@ +@@ -1669,7 +2223,7 @@ while (iterator.hasNext()) { MobEffectInstance mobeffect = (MobEffectInstance) iterator.next(); @@ -1343,7 +1367,7 @@ } this.getInventory().replaceWith(oldPlayer.getInventory()); -@@ -1680,7 +2215,7 @@ +@@ -1680,7 +2234,7 @@ this.portalProcess = oldPlayer.portalProcess; } else { this.getAttributes().assignBaseValues(oldPlayer.getAttributes()); @@ -1352,7 +1376,7 @@ if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || oldPlayer.isSpectator()) { this.getInventory().replaceWith(oldPlayer.getInventory()); this.experienceLevel = oldPlayer.experienceLevel; -@@ -1696,7 +2231,7 @@ +@@ -1696,7 +2250,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1361,7 +1385,7 @@ this.seenCredits = oldPlayer.seenCredits; this.enteredNetherPosition = oldPlayer.enteredNetherPosition; this.chunkTrackingView = oldPlayer.chunkTrackingView; -@@ -1752,19 +2287,19 @@ +@@ -1752,19 +2306,19 @@ } @Override @@ -1385,7 +1409,7 @@ } return flag1; -@@ -1799,10 +2334,18 @@ +@@ -1799,10 +2353,18 @@ } public boolean setGameMode(GameType gameMode) { @@ -1406,7 +1430,7 @@ } else { this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, (float) gameMode.getId())); if (gameMode == GameType.SPECTATOR) { -@@ -1818,7 +2361,7 @@ +@@ -1818,7 +2380,7 @@ this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1415,7 +1439,7 @@ } } -@@ -1861,8 +2404,13 @@ +@@ -1861,8 +2423,13 @@ } public void sendChatMessage(OutgoingChatMessage message, boolean filterMaskEnabled, ChatType.Bound params) { @@ -1430,7 +1454,7 @@ } } -@@ -1878,7 +2426,36 @@ +@@ -1878,7 +2445,36 @@ } public void updateOptions(ClientInformation clientOptions) { @@ -1467,7 +1491,7 @@ this.requestedViewDistance = clientOptions.viewDistance(); this.chatVisibility = clientOptions.chatVisibility(); this.canChatColor = clientOptions.chatColors(); -@@ -1957,12 +2534,27 @@ +@@ -1957,12 +2553,27 @@ this.camera = (Entity) (entity == null ? this : entity); if (entity1 != this.camera) { @@ -1496,7 +1520,7 @@ } if (entity != null) { -@@ -1999,11 +2591,11 @@ +@@ -1999,11 +2610,11 @@ @Nullable public Component getTabListDisplayName() { @@ -1510,7 +1534,7 @@ } @Override -@@ -2045,12 +2637,44 @@ +@@ -2045,12 +2656,44 @@ this.setRespawnPosition(player.getRespawnDimension(), player.getRespawnPosition(), player.getRespawnAngle(), player.isRespawnForced(), false); } @@ -1557,7 +1581,7 @@ } this.respawnPosition = pos; -@@ -2064,6 +2688,7 @@ +@@ -2064,6 +2707,7 @@ this.respawnForced = false; } @@ -1565,7 +1589,7 @@ } public SectionPos getLastSectionPos() { -@@ -2088,18 +2713,44 @@ +@@ -2088,18 +2732,44 @@ } @Override @@ -1614,7 +1638,7 @@ } this.awardStat(Stats.DROP); -@@ -2115,6 +2766,11 @@ +@@ -2115,6 +2785,11 @@ return null; } else { double d0 = this.getEyeY() - 0.30000001192092896D; @@ -1626,7 +1650,7 @@ ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), d0, this.getZ(), stack); entityitem.setPickUpDelay(40); -@@ -2166,6 +2822,16 @@ +@@ -2166,6 +2841,16 @@ } public void loadGameTypes(@Nullable CompoundTag nbt) { @@ -1643,7 +1667,7 @@ this.gameMode.setGameModeForPlayer(this.calculateGameModeForNewPlayer(ServerPlayer.readPlayerMode(nbt, "playerGameType")), ServerPlayer.readPlayerMode(nbt, "previousPlayerGameType")); } -@@ -2275,9 +2941,15 @@ +@@ -2275,9 +2960,15 @@ @Override public void stopRiding() { @@ -1660,7 +1684,7 @@ if (entity instanceof LivingEntity entityliving) { Iterator iterator = entityliving.getActiveEffects().iterator(); -@@ -2375,10 +3047,12 @@ +@@ -2375,10 +3066,12 @@ return TicketType.ENDER_PEARL.timeout(); } @@ -1676,7 +1700,7 @@ } private static float calculateLookAtYaw(Vec3 respawnPos, BlockPos currentPos) { -@@ -2387,4 +3061,147 @@ +@@ -2387,4 +3080,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 0f0fc2ffd3..8a1feeb6bf 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 @@ -28,10 +28,11 @@ public abstract class AbstractContainerMenu { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -67,6 +81,32 @@ +@@ -66,6 +80,32 @@ + @Nullable private ContainerSynchronizer synchronizer; private boolean suppressRemoteUpdates; - ++ + // CraftBukkit start + public boolean checkReachable = true; + public abstract InventoryView getBukkitView(); @@ -57,10 +58,9 @@ + this.title = title; + } + // CraftBukkit end -+ + protected AbstractContainerMenu(@Nullable MenuType<?> type, int syncId) { this.carried = ItemStack.EMPTY; - this.remoteSlots = NonNullList.create(); @@ -192,6 +232,15 @@ } @@ -77,6 +77,15 @@ public void removeSlotListener(ContainerListener listener) { this.containerListeners.remove(listener); } +@@ -281,7 +330,7 @@ + while (iterator.hasNext()) { + ContainerListener icrafting = (ContainerListener) iterator.next(); + +- icrafting.slotChanged(this, slot, itemstack2); ++ icrafting.slotChanged(this, slot, itemstack1, itemstack2); // Paper - Add PlayerInventorySlotChangeEvent + } + } + @@ -417,7 +466,7 @@ } } else if (this.quickcraftStatus == 2) { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ContainerListener.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ContainerListener.java.patch new file mode 100644 index 0000000000..7d9e714dfe --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ContainerListener.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/inventory/ContainerListener.java ++++ b/net/minecraft/world/inventory/ContainerListener.java +@@ -5,5 +5,11 @@ + public interface ContainerListener { + void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack stack); + ++ // Paper start - Add PlayerInventorySlotChangeEvent ++ default void slotChanged(AbstractContainerMenu handler, int slotId, ItemStack oldStack, ItemStack stack) { ++ slotChanged(handler, slotId, stack); ++ } ++ // Paper end - Add PlayerInventorySlotChangeEvent ++ + void dataChanged(AbstractContainerMenu handler, int property, int value); + }