From ca25aa1859fc7392fe85fc8bb8dd03787650fb8c Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 25 Apr 2024 22:34:46 +0200 Subject: [PATCH] More more compile fixes --- .../Ability-to-apply-mending-to-XP-API.patch | 2 +- ...ternate-Current-redstone-implementation.patch | 2 +- ...ional-open-container-api-to-HumanEntity.patch | 13 +++++++++++++ patches/server/Adventure.patch | 6 +++--- .../Allow-Saving-of-Oversized-Chunks.patch | 2 +- .../Allow-delegation-to-vanilla-chunk-gen.patch | 16 +++++++++------- ...calculate-regionfile-header-if-it-is-co.patch | 4 ++-- patches/server/Deprecate-ItemStack-setType.patch | 9 +++++++-- .../Fix-missing-map-initialize-event-call.patch | 14 +++++++------- .../Improve-performance-of-mass-crafts.patch | 2 +- patches/server/Player.setPlayerProfile-API.patch | 2 +- patches/server/Properly-resend-entities.patch | 2 +- 12 files changed, 47 insertions(+), 27 deletions(-) diff --git a/patches/server/Ability-to-apply-mending-to-XP-API.patch b/patches/server/Ability-to-apply-mending-to-XP-API.patch index 37a9248a1a..1bdf2cf4d5 100644 --- a/patches/server/Ability-to-apply-mending-to-XP-API.patch +++ b/patches/server/Ability-to-apply-mending-to-XP-API.patch @@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final var stackEntry = net.minecraft.world.item.enchantment.EnchantmentHelper + .getRandomItemWith(net.minecraft.world.item.enchantment.Enchantments.MENDING, handle); + final net.minecraft.world.item.ItemStack itemstack = stackEntry != null ? stackEntry.getValue() : net.minecraft.world.item.ItemStack.EMPTY; -+ if (!itemstack.isEmpty() && itemstack.getItem().canBeDepleted()) { ++ if (!itemstack.isEmpty() && itemstack.getItem().components().has(net.minecraft.core.component.DataComponents.MAX_STACK_SIZE)) { + net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityType.EXPERIENCE_ORB.create(handle.level()); + orb.value = amount; + orb.spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.CUSTOM; diff --git a/patches/server/Add-Alternate-Current-redstone-implementation.patch b/patches/server/Add-Alternate-Current-redstone-implementation.patch index b6468d2fd0..40d6619a4f 100644 --- a/patches/server/Add-Alternate-Current-redstone-implementation.patch +++ b/patches/server/Add-Alternate-Current-redstone-implementation.patch @@ -1869,7 +1869,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // positions of the network to a set and filter out block updates to wires in + // the network that way. + if (!state.isAir() && !state.is(Blocks.REDSTONE_WIRE)) { -+ state.neighborChanged(level, pos, neighborBlock, neighborPos, false); ++ state.handleNeighborChanged(level, pos, neighborBlock, neighborPos, false); + } + } + diff --git a/patches/server/Add-additional-open-container-api-to-HumanEntity.patch b/patches/server/Add-additional-open-container-api-to-HumanEntity.patch index 62834e679a..00f9871b6a 100644 --- a/patches/server/Add-additional-open-container-api-to-HumanEntity.patch +++ b/patches/server/Add-additional-open-container-api-to-HumanEntity.patch @@ -4,6 +4,19 @@ Date: Wed, 26 Aug 2020 02:12:31 -0400 Subject: [PATCH] Add additional open container api to HumanEntity +diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java ++++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +@@ -0,0 +0,0 @@ public abstract class BlockBehaviour implements FeatureElement { + } + + @Nullable +- protected MenuProvider getMenuProvider(BlockState state, Level world, BlockPos pos) { ++ public MenuProvider getMenuProvider(BlockState state, Level world, BlockPos pos) { // Paper - public + return null; + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index f16b5910c8..f7adefefca 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -3084,7 +3084,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 boolean flag1 = false; boolean flag2; -+ Packet disguised = sender != null && unsignedFunction == null ? new net.minecraft.network.protocol.game.ClientboundDisguisedChatPacket(outgoingchatmessage.content(), params.toNetwork(sender.level().registryAccess())) : null; // Paper - don't send player chat packets from vanished players ++ Packet disguised = sender != null && unsignedFunction == null ? new net.minecraft.network.protocol.game.ClientboundDisguisedChatPacket(outgoingchatmessage.content(), params) : null; // Paper - don't send player chat packets from vanished players for (Iterator iterator = this.players.iterator(); iterator.hasNext(); flag1 |= flag2 && message.isFullyFiltered()) { ServerPlayer entityplayer1 = (ServerPlayer) iterator.next(); @@ -3094,7 +3094,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - don't send player chat packets from vanished players + if (sender != null && !entityplayer1.getBukkitEntity().canSee(sender.getBukkitEntity())) { + entityplayer1.connection.send(unsignedFunction != null -+ ? new net.minecraft.network.protocol.game.ClientboundDisguisedChatPacket(unsignedFunction.apply(entityplayer1.getBukkitEntity()), params.toNetwork(sender.level().registryAccess())) ++ ? new net.minecraft.network.protocol.game.ClientboundDisguisedChatPacket(unsignedFunction.apply(entityplayer1.getBukkitEntity()), params) + : disguised); + continue; + } @@ -4287,7 +4287,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final Component prompt = io.papermc.paper.adventure.PaperAdventure.asVanilla(request.prompt()); + for (final java.util.Iterator iter = request.packs().iterator(); iter.hasNext();) { + final net.kyori.adventure.resource.ResourcePackInfo pack = iter.next(); -+ packs.add(new ClientboundResourcePackPushPacket(pack.id(), pack.uri().toASCIIString(), pack.hash(), request.required(), iter.hasNext() ? null : prompt)); ++ packs.add(new ClientboundResourcePackPushPacket(pack.id(), pack.uri().toASCIIString(), pack.hash(), request.required(), iter.hasNext() ? Optional.empty() : Optional.of(prompt))); + if (request.callback() != net.kyori.adventure.resource.ResourcePackCallback.noOp()) { + this.getHandle().connection.packCallbacks.put(pack.id(), request.callback()); // just override if there is a previously existing callback + } diff --git a/patches/server/Allow-Saving-of-Oversized-Chunks.patch b/patches/server/Allow-Saving-of-Oversized-Chunks.patch index b402a50327..830aba46e9 100644 --- a/patches/server/Allow-Saving-of-Oversized-Chunks.patch +++ b/patches/server/Allow-Saving-of-Oversized-Chunks.patch @@ -187,7 +187,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + if (regionfile.isOversized(pos.x, pos.z)) { -+ printOversizedLog("Loading Oversized Chunk!", regionfile.regionFile, pos.x, pos.z); ++ printOversizedLog("Loading Oversized Chunk!", regionfile.getPath(), pos.x, pos.z); + return readOversizedChunk(regionfile, pos); + } + // Paper end diff --git a/patches/server/Allow-delegation-to-vanilla-chunk-gen.patch b/patches/server/Allow-delegation-to-vanilla-chunk-gen.patch index c08bbc8b85..feb0179d28 100644 --- a/patches/server/Allow-delegation-to-vanilla-chunk-gen.patch +++ b/patches/server/Allow-delegation-to-vanilla-chunk-gen.patch @@ -69,18 +69,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + chunkStatus.generate( ++ new net.minecraft.world.level.chunk.status.WorldGenContext( ++ serverLevel, ++ chunkGenerator, ++ serverLevel.getStructureManager(), ++ serverLevel.chunkSource.getLightEngine() ++ ), + mailbox::tell, -+ serverLevel, -+ chunkGenerator, -+ serverLevel.getStructureManager(), -+ serverLevel.chunkSource.getLightEngine(), + chunk -> { + throw new UnsupportedOperationException("Not creating full chunks here"); + }, + chunks -+ ).thenAccept(either -> { -+ if (chunkStatus == net.minecraft.world.level.chunk.status.ChunkStatus.NOISE) { -+ either.left().ifPresent(chunk -> net.minecraft.world.level.levelgen.Heightmap.primeHeightmaps(chunk, net.minecraft.world.level.chunk.status.ChunkStatus.POST_FEATURES)); ++ ).thenAccept(chunk -> { ++ if (chunk != null && chunkStatus == net.minecraft.world.level.chunk.status.ChunkStatus.NOISE) { ++ net.minecraft.world.level.levelgen.Heightmap.primeHeightmaps(chunk, net.minecraft.world.level.chunk.status.ChunkStatus.POST_FEATURES); + } + }).join(); + } diff --git a/patches/server/Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/patches/server/Attempt-to-recalculate-regionfile-header-if-it-is-co.patch index bb40aeb52b..992be687a6 100644 --- a/patches/server/Attempt-to-recalculate-regionfile-header-if-it-is-co.patch +++ b/patches/server/Attempt-to-recalculate-regionfile-header-if-it-is-co.patch @@ -749,12 +749,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (this.isChunkData) { + ChunkPos chunkPos = ChunkSerializer.getChunkCoordinate(nbttagcompound); + if (!chunkPos.equals(pos)) { -+ net.minecraft.server.MinecraftServer.LOGGER.error("Attempting to read chunk data at " + pos + " but got chunk data for " + chunkPos + " instead! Attempting regionfile recalculation for regionfile " + regionfile.regionFile.toAbsolutePath()); ++ net.minecraft.server.MinecraftServer.LOGGER.error("Attempting to read chunk data at " + pos + " but got chunk data for " + chunkPos + " instead! Attempting regionfile recalculation for regionfile " + regionfile.getPath().toAbsolutePath()); + if (regionfile.recalculateHeader()) { + regionfile.fileLock.lock(); // otherwise we will unlock twice and only lock once. + return this.read(pos, regionfile); + } -+ net.minecraft.server.MinecraftServer.LOGGER.error("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.regionFile.toAbsolutePath()); ++ net.minecraft.server.MinecraftServer.LOGGER.error("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.getPath().toAbsolutePath()); + return null; + } + } diff --git a/patches/server/Deprecate-ItemStack-setType.patch b/patches/server/Deprecate-ItemStack-setType.patch index e8508e20d3..dbd40c91e9 100644 --- a/patches/server/Deprecate-ItemStack-setType.patch +++ b/patches/server/Deprecate-ItemStack-setType.patch @@ -15,12 +15,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - with type + @Override + public ItemStack withType(final Material type) { -+ if (type == Material.AIR) return CraftItemStack.asCraftMirror(null); ++ if (type == Material.AIR) { ++ return CraftItemStack.asCraftMirror(null); ++ } + + final net.minecraft.world.item.ItemStack copy = new net.minecraft.world.item.ItemStack( + CraftItemType.bukkitToMinecraft(type), this.getAmount() + ); -+ if (this.handle != null && this.handle.getTag() != null) copy.setTag(this.handle.getTag().copy()); ++ ++ if (this.handle != null) { ++ copy.applyComponents(this.handle.getComponents()); ++ } + + final CraftItemStack mirrored = CraftItemStack.asCraftMirror(copy); + mirrored.setItemMeta(mirrored.getItemMeta()); diff --git a/patches/server/Fix-missing-map-initialize-event-call.patch b/patches/server/Fix-missing-map-initialize-event-call.patch index 76b21fc798..a5686584c0 100644 --- a/patches/server/Fix-missing-map-initialize-event-call.patch +++ b/patches/server/Fix-missing-map-initialize-event-call.patch @@ -21,14 +21,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Call missing map initialize event and set id + final DimensionDataStorage storage = this.getServer().overworld().getDataStorage(); + -+ final net.minecraft.world.level.saveddata.SavedData existing = storage.cache.get(id); -+ if (existing == null && !storage.cache.containsKey(id)) { ++ final net.minecraft.world.level.saveddata.SavedData existing = storage.cache.get(id.key()); ++ if (existing == null && !storage.cache.containsKey(id.key())) { + final MapItemSavedData worldmap = (MapItemSavedData) this.getServer().overworld().getDataStorage().get(MapItemSavedData.factory(), id.key()); -+ storage.cache.put(id, map); -+ if (map != null) { -+ map.id = id; -+ new MapInitializeEvent(map.mapView).callEvent(); -+ return map; ++ storage.cache.put(id.key(), worldmap); ++ if (worldmap != null) { ++ worldmap.id = id; ++ new MapInitializeEvent(worldmap.mapView).callEvent(); ++ return worldmap; + } + } else if (existing instanceof MapItemSavedData mapItemSavedData) { + mapItemSavedData.id = id; diff --git a/patches/server/Improve-performance-of-mass-crafts.patch b/patches/server/Improve-performance-of-mass-crafts.patch index 33c96569bf..c6c34dcf3f 100644 --- a/patches/server/Improve-performance-of-mass-crafts.patch +++ b/patches/server/Improve-performance-of-mass-crafts.patch @@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return this.getRemainingItemsFor(type, inventory, world, null); + } + public > NonNullList getRemainingItemsFor(RecipeType type, C inventory, Level world, @Nullable ResourceLocation firstToCheck) { -+ Optional> optional = firstToCheck == null ? this.getRecipeFor(type, inventory, world) : this.getRecipeFor(type, inventory, world, firstToCheck).map(Pair::getSecond); ++ Optional> optional = firstToCheck == null ? this.getRecipeFor(type, inventory, world) : this.getRecipeFor(type, inventory, world, firstToCheck); + // Paper end - Perf: Improve mass crafting if (optional.isPresent()) { diff --git a/patches/server/Player.setPlayerProfile-API.patch b/patches/server/Player.setPlayerProfile-API.patch index 9c2f282668..b67ee7dbd9 100644 --- a/patches/server/Player.setPlayerProfile-API.patch +++ b/patches/server/Player.setPlayerProfile-API.patch @@ -212,7 +212,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Resend their XP and effects because the respawn packet resets it + connection.send(new net.minecraft.network.protocol.game.ClientboundSetExperiencePacket(handle.experienceProgress, handle.totalExperience, handle.experienceLevel)); + for (net.minecraft.world.effect.MobEffectInstance mobEffect : handle.getActiveEffects()) { -+ connection.send(new net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket(handle.getId(), mobEffect)); ++ connection.send(new net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket(handle.getId(), mobEffect, false)); + } + } + // Paper end diff --git a/patches/server/Properly-resend-entities.patch b/patches/server/Properly-resend-entities.patch index 6b39c35396..a95a6fc04f 100644 --- a/patches/server/Properly-resend-entities.patch +++ b/patches/server/Properly-resend-entities.patch @@ -206,7 +206,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - entityTracker.broadcast(this.getHandle().getAddEntityPacket()); + // Paper start, resend possibly desynced entity instead of add entity packet + for (ServerPlayerConnection playerConnection : entityTracker.seenBy) { -+ this.getHandle().getEntityData().resendPossiblyDesyncedEntityData(playerConnection.getPlayer()); ++ this.getHandle().resendPossiblyDesyncedEntityData(playerConnection.getPlayer()); + } + // Paper end }