From b43286379357a4f4abb010e42c22dc981dec036b Mon Sep 17 00:00:00 2001 From: Nassim Jahnke <nassim@njahnke.dev> Date: Thu, 25 Apr 2024 21:40:53 +0200 Subject: [PATCH] Fix more compile issues --- .../server/Add-EntityDamageItemEvent.patch | 2 +- patches/server/Adventure.patch | 5 ++-- .../Allow-for-toggling-of-spawn-chunks.patch | 27 +++++++++++-------- patches/server/Anti-Xray.patch | 2 +- ...lementation-for-blockstate-state-loo.patch | 2 +- patches/server/Lag-compensation-ticks.patch | 4 +-- patches/server/More-Projectile-API.patch | 6 +++-- ...-Manager-and-add-advanced-packet-sup.patch | 6 ++--- patches/server/Properly-resend-entities.patch | 2 +- ...on-t-call-getItemMeta-on-hasItemMeta.patch | 0 10 files changed, 31 insertions(+), 25 deletions(-) rename patches/server/Don-t-call-getItemMeta-on-hasItemMeta.patch => removed-patches-1-20-5/0227-Don-t-call-getItemMeta-on-hasItemMeta.patch (100%) diff --git a/patches/server/Add-EntityDamageItemEvent.patch b/patches/server/Add-EntityDamageItemEvent.patch index 2144420bc4..86ffdb0ace 100644 --- a/patches/server/Add-EntityDamageItemEvent.patch +++ b/patches/server/Add-EntityDamageItemEvent.patch @@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } else if (player != null) { + io.papermc.paper.event.entity.EntityDamageItemEvent event = new io.papermc.paper.event.entity.EntityDamageItemEvent(player.getBukkitLivingEntity(), CraftItemStack.asCraftMirror(this), amount); + if (!event.callEvent()) { -+ return false; ++ return; + } + amount = event.getDamage(); + // Paper end - Add EntityDamageItemEvent diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 2df02555f9..f16b5910c8 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -1828,8 +1828,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import org.checkerframework.checker.nullness.qual.Nullable; +import org.checkerframework.framework.qual.DefaultQualifier; + -+import static net.kyori.adventure.nbt.api.BinaryTagHolder.binaryTagHolder; -+import static net.kyori.adventure.text.serializer.gson.GsonDataComponentValue.gsonDatacomponentValue; ++import static net.kyori.adventure.text.serializer.gson.GsonDataComponentValue.gsonDataComponentValue; + +@DefaultQualifier(NonNull.class) +public class DataComponentValueConverterProviderImpl implements DataComponentValueConverterRegistry.Provider { @@ -1848,7 +1847,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + DataComponentValueConverterRegistry.Conversion.convert( + PaperAdventure.DataComponentValueImpl.class, + GsonDataComponentValue.class, -+ (key, dataComponentValue) -> gsonDatacomponentValue((JsonElement) dataComponentValue.codec().encodeStart(JsonOps.INSTANCE, dataComponentValue.value()).getOrThrow()) ++ (key, dataComponentValue) -> gsonDataComponentValue((JsonElement) dataComponentValue.codec().encodeStart(JsonOps.INSTANCE, dataComponentValue.value()).getOrThrow()) + ), + DataComponentValueConverterRegistry.Conversion.convert( + GsonDataComponentValue.class, diff --git a/patches/server/Allow-for-toggling-of-spawn-chunks.patch b/patches/server/Allow-for-toggling-of-spawn-chunks.patch index c9c6177e3a..5080515d18 100644 --- a/patches/server/Allow-for-toggling-of-spawn-chunks.patch +++ b/patches/server/Allow-for-toggling-of-spawn-chunks.patch @@ -4,15 +4,20 @@ Date: Thu, 3 Mar 2016 03:53:43 -0600 Subject: [PATCH] Allow for toggling of spawn chunks -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java +diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - }); - // CraftBukkit end - this.timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings -+ this.keepSpawnInMemory = this.paperConfig().spawn.keepSpawnLoaded; // Paper - Option to keep spawn chunks loaded - this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); - this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); - } +--- a/src/main/java/net/minecraft/server/level/ServerLevel.java ++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { + this.dragonFight = null; + } + ++ // Paper start - keep spawn loaded ++ if (this.paperConfig().spawn.keepSpawnLoaded && this.getGameRules().getInt(GameRules.RULE_SPAWN_CHUNK_RADIUS) == 0) { ++ this.getGameRules().getRule(GameRules.RULE_SPAWN_CHUNK_RADIUS).set(this.paperConfig().spawn.keepSpawnLoadedRange, this); ++ } ++ // Paper end - keep spawn loaded ++ + this.sleepStatus = new SleepStatus(); + this.gameEventDispatcher = new GameEventDispatcher(this); + this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> { diff --git a/patches/server/Anti-Xray.patch b/patches/server/Anti-Xray.patch index ec7db61198..780ff1bdc5 100644 --- a/patches/server/Anti-Xray.patch +++ b/patches/server/Anti-Xray.patch @@ -1189,7 +1189,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config this.generator = gen; @@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - this.keepSpawnInMemory = this.paperConfig().spawn.keepSpawnLoaded; // Paper - Option to keep spawn chunks loaded + this.timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); + this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : com.destroystokyo.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray diff --git a/patches/server/Custom-table-implementation-for-blockstate-state-loo.patch b/patches/server/Custom-table-implementation-for-blockstate-state-loo.patch index cfe59c2249..80c373202c 100644 --- a/patches/server/Custom-table-implementation-for-blockstate-state-loo.patch +++ b/patches/server/Custom-table-implementation-for-blockstate-state-loo.patch @@ -186,7 +186,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.owner = owner; this.values = propertyMap; this.propertiesCodec = codec; -+ this.optimisedTable = new io.papermc.paper.util.table.ZeroCollidingReferenceStateTable(this, entries); // Paper - optimise state lookup ++ this.optimisedTable = new io.papermc.paper.util.table.ZeroCollidingReferenceStateTable(this, propertyMap); // Paper - optimise state lookup } public <T extends Comparable<T>> S cycle(Property<T> property) { diff --git a/patches/server/Lag-compensation-ticks.patch b/patches/server/Lag-compensation-ticks.patch index d0cc606850..2bccc73b39 100644 --- a/patches/server/Lag-compensation-ticks.patch +++ b/patches/server/Lag-compensation-ticks.patch @@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { - this.getEntityData().resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer); + this.resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer); } // Paper end - Properly cancel usable items + // Paper start - lag compensate eating @@ -84,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (--this.useItemRemaining == 0 && !this.level().isClientSide && !stack.useOnRelease()) { + // Paper start - lag compensate eating + // we add 1 to the expected time to avoid lag compensating when we should not -+ boolean shouldLagCompensate = this.useItem.getItem().isEdible() && this.eatStartTime != -1 && (System.nanoTime() - this.eatStartTime) > ((1 + this.totalEatTimeTicks) * 50 * (1000 * 1000)); ++ boolean shouldLagCompensate = this.useItem.getItem().components().has(DataComponents.FOOD) && this.eatStartTime != -1 && (System.nanoTime() - this.eatStartTime) > ((1 + this.totalEatTimeTicks) * 50 * (1000 * 1000)); + if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !this.level().isClientSide && !stack.useOnRelease()) { + this.useItemRemaining = 0; + // Paper end - lag compensate eating diff --git a/patches/server/More-Projectile-API.patch b/patches/server/More-Projectile-API.patch index 4865ef011e..ff6d98918b 100644 --- a/patches/server/More-Projectile-API.patch +++ b/patches/server/More-Projectile-API.patch @@ -580,8 +580,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return CraftItemStack.getItemMeta(this.handle); } + // Paper start -+ public static void applyMetaToItem(net.minecraft.world.item.ItemStack itemStack, ItemMeta meta) { -+ ((org.bukkit.craftbukkit.inventory.CraftMetaItem) meta).applyToItem(itemStack.getOrCreateTag()); ++ public static void applyMetaToItem(net.minecraft.world.item.ItemStack itemStack, ItemMeta itemMeta) { ++ final CraftMetaItem.Applicator tag = new CraftMetaItem.Applicator(); ++ ((CraftMetaItem) itemMeta).applyToItem(tag); ++ itemStack.applyComponents(tag.build()); + } public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item) { diff --git a/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch b/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch index 871d7b9217..2b8683fbba 100644 --- a/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch +++ b/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch @@ -345,14 +345,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * @param player Null if not at PLAY stage yet + */ -+ default void onPacketDispatch(@Nullable net.minecraft.server.level.ServerPlayer player) { ++ default void onPacketDispatch(@org.jetbrains.annotations.Nullable net.minecraft.server.level.ServerPlayer player) { + } + + /** + * @param player Null if not at PLAY stage yet + * @param future Can be null if packet was cancelled + */ -+ default void onPacketDispatchFinish(@Nullable net.minecraft.server.level.ServerPlayer player, @Nullable io.netty.channel.ChannelFuture future) {} ++ default void onPacketDispatchFinish(@org.jetbrains.annotations.Nullable net.minecraft.server.level.ServerPlayer player, @org.jetbrains.annotations.Nullable io.netty.channel.ChannelFuture future) {} + + default boolean hasFinishListener() { + return false; @@ -362,7 +362,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return true; + } + -+ @Nullable ++ @org.jetbrains.annotations.Nullable + default java.util.List<Packet<?>> getExtraPackets() { + return null; + } diff --git a/patches/server/Properly-resend-entities.patch b/patches/server/Properly-resend-entities.patch index 8c9d967c1b..6b39c35396 100644 --- a/patches/server/Properly-resend-entities.patch +++ b/patches/server/Properly-resend-entities.patch @@ -175,7 +175,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Properly cancel usable items + public void resyncUsingItem(ServerPlayer serverPlayer) { -+ this.getEntityData().resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer); ++ this.resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer); + } + // Paper end - Properly cancel usable items private void updatingUsingItem() { diff --git a/patches/server/Don-t-call-getItemMeta-on-hasItemMeta.patch b/removed-patches-1-20-5/0227-Don-t-call-getItemMeta-on-hasItemMeta.patch similarity index 100% rename from patches/server/Don-t-call-getItemMeta-on-hasItemMeta.patch rename to removed-patches-1-20-5/0227-Don-t-call-getItemMeta-on-hasItemMeta.patch