From b561fd8b25e7fbb858f8fdbfcb84c71af71a47b7 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 8 Jun 2022 15:59:48 +0200 Subject: [PATCH] Compilation error fixes --- .../0755-Optimise-random-block-ticking.patch | 24 ++++++++++++++++--- ...0845-Replace-ticket-level-propagator.patch | 11 ++++++++- ...dd-missing-block-data-mins-and-maxes.patch | 21 ++++++++++++++++ ...0864-Implement-enchantWithLevels-API.patch | 4 ++-- ...assenger-world-matches-ridden-entity.patch | 4 ++-- ...ard-against-invalid-entity-positions.patch | 4 ++-- ...king-amount-to-PlayerItemDamageEvent.patch | 4 ++-- .../0892-Add-support-for-Proxy-Protocol.patch | 12 ++++++++++ ...entity-loading-causing-async-lookups.patch | 4 ++-- 9 files changed, 74 insertions(+), 14 deletions(-) diff --git a/patches/server/0755-Optimise-random-block-ticking.patch b/patches/server/0755-Optimise-random-block-ticking.patch index 408a9fe08..9da121129 100644 --- a/patches/server/0755-Optimise-random-block-ticking.patch +++ b/patches/server/0755-Optimise-random-block-ticking.patch @@ -20,15 +20,18 @@ remains the same. diff --git a/src/main/java/io/papermc/paper/util/math/ThreadUnsafeRandom.java b/src/main/java/io/papermc/paper/util/math/ThreadUnsafeRandom.java new file mode 100644 -index 0000000000000000000000000000000000000000..e8b4053babe46999980b92643125405064af1c04 +index 0000000000000000000000000000000000000000..35551289c27735e2a77102f31ef8cae843aeb225 --- /dev/null +++ b/src/main/java/io/papermc/paper/util/math/ThreadUnsafeRandom.java -@@ -0,0 +1,46 @@ +@@ -0,0 +1,64 @@ +package io.papermc.paper.util.math; + ++import net.minecraft.util.RandomSource; ++import net.minecraft.world.level.levelgen.PositionalRandomFactory; ++ +import java.util.Random; + -+public final class ThreadUnsafeRandom extends Random { ++public final class ThreadUnsafeRandom extends Random implements RandomSource { + + // See javadoc and internal comments for java.util.Random where these values come from, how they are used, and the author for them. + private static final long multiplier = 0x5DEECE66DL; @@ -42,6 +45,21 @@ index 0000000000000000000000000000000000000000..e8b4053babe46999980b926431254050 + private long seed; + + @Override ++ public RandomSource fork() { ++ return new ThreadUnsafeRandom(); ++ } ++ ++ @Override ++ public PositionalRandomFactory forkPositional() { ++ throw new UnsupportedOperationException(); ++ } ++ ++ @Override ++ public int nextInt(int origin, int bound) { ++ return RandomSource.super.nextInt(origin, bound); ++ } ++ ++ @Override + public void setSeed(long seed) { + // note: called by Random constructor + this.seed = initialScramble(seed); diff --git a/patches/server/0845-Replace-ticket-level-propagator.patch b/patches/server/0845-Replace-ticket-level-propagator.patch index bfab6c8c6..392a3870b 100644 --- a/patches/server/0845-Replace-ticket-level-propagator.patch +++ b/patches/server/0845-Replace-ticket-level-propagator.patch @@ -15,7 +15,7 @@ will be more effective, since more time will be allocated to actually processing chunk tasks vs the ticket level updates. diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java -index b22c771ca35466574d5a73f2da3fc8762cb29487..b243de50a44099f619b2c704e51badb9b22b74b6 100644 +index b22c771ca35466574d5a73f2da3fc8762cb29487..65a76e76cd101298a8cad4d23e0928ef3e08289a 100644 --- a/src/main/java/net/minecraft/server/level/DistanceManager.java +++ b/src/main/java/net/minecraft/server/level/DistanceManager.java @@ -38,6 +38,7 @@ import net.minecraft.world.level.chunk.ChunkStatus; @@ -238,6 +238,15 @@ index b22c771ca35466574d5a73f2da3fc8762cb29487..b243de50a44099f619b2c704e51badb9 } // Paper end return removed; // CraftBukkit +@@ -564,7 +638,7 @@ public abstract class DistanceManager { + } + + if (flag) { +- this.ticketTracker.update(entry.getLongKey(), DistanceManager.getTicketLevelAt((SortedArraySet) entry.getValue()), false); ++ this.updateTicketLevel(entry.getLongKey(), DistanceManager.getTicketLevelAt((SortedArraySet) entry.getValue())); // Paper - replace ticket level propagator + } + + if (((SortedArraySet) entry.getValue()).isEmpty()) { @@ -587,7 +661,7 @@ public abstract class DistanceManager { SortedArraySet> tickets = entry.getValue(); if (tickets.remove(target)) { diff --git a/patches/server/0848-Add-missing-block-data-mins-and-maxes.patch b/patches/server/0848-Add-missing-block-data-mins-and-maxes.patch index 83a0ac25a..83ba5f6bc 100644 --- a/patches/server/0848-Add-missing-block-data-mins-and-maxes.patch +++ b/patches/server/0848-Add-missing-block-data-mins-and-maxes.patch @@ -108,6 +108,27 @@ index de882af105fae1166aced908cfe45b826a07f418..0d430382a05dfc0802a2569816c5ec87 // org.bukkit.craftbukkit.block.data.CraftWaterlogged private static final net.minecraft.world.level.block.state.properties.BooleanProperty WATERLOGGED = getBoolean(net.minecraft.world.level.block.LightBlock.class, "waterlogged"); +diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMangroveLeaves.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMangroveLeaves.java +index f070c35833b33ad2d7cfa629d8702a95e9bc6d04..5a021dc1931d35cbe235ab399aa98f3c7e93ded3 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMangroveLeaves.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMangroveLeaves.java +@@ -51,4 +51,16 @@ public final class CraftMangroveLeaves extends org.bukkit.craftbukkit.block.data + public void setWaterlogged(boolean waterlogged) { + set(CraftMangroveLeaves.WATERLOGGED, waterlogged); + } ++ ++ // Paper start ++ @Override ++ public int getMinimumDistance() { ++ return getMin(CraftMangroveLeaves.DISTANCE); ++ } ++ ++ @Override ++ public int getMaximumDistance() { ++ return getMax(CraftMangroveLeaves.DISTANCE); ++ } ++ // Paper end + } diff --git a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPowderSnowCauldron.java b/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPowderSnowCauldron.java index c6bd91bdf6bf64701ffc69619174cc3b43b72d88..c6289306f0f933b67ff1f6db63ef976df7aa5438 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPowderSnowCauldron.java diff --git a/patches/server/0864-Implement-enchantWithLevels-API.patch b/patches/server/0864-Implement-enchantWithLevels-API.patch index 88a8f8f3e..204d4534f 100644 --- a/patches/server/0864-Implement-enchantWithLevels-API.patch +++ b/patches/server/0864-Implement-enchantWithLevels-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Implement enchantWithLevels API diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -index 4a8ac558d308c4e3bc63cdd8d7071a3f9ff3aa81..4b60a9b78e410695310926e1fd319ce7d9eb5e61 100644 +index 4a8ac558d308c4e3bc63cdd8d7071a3f9ff3aa81..ce64286ac5b836283318ac1ac0bd4afb29db9bb7 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -376,6 +376,21 @@ public final class CraftItemFactory implements ItemFactory { @@ -23,7 +23,7 @@ index 4a8ac558d308c4e3bc63cdd8d7071a3f9ff3aa81..4b60a9b78e410695310926e1fd319ce7 + if (internalStack.tag != null) { + internalStack.tag.remove(net.minecraft.world.item.ItemStack.TAG_ENCH); + } -+ final net.minecraft.world.item.ItemStack enchanted = net.minecraft.world.item.enchantment.EnchantmentHelper.enchantItem(random, internalStack, levels, allowTreasure); ++ final net.minecraft.world.item.ItemStack enchanted = net.minecraft.world.item.enchantment.EnchantmentHelper.enchantItem(new org.bukkit.craftbukkit.util.RandomSourceWrapper(random), internalStack, levels, allowTreasure); + return CraftItemStack.asCraftMirror(enchanted); + } + diff --git a/patches/server/0870-Ensure-entity-passenger-world-matches-ridden-entity.patch b/patches/server/0870-Ensure-entity-passenger-world-matches-ridden-entity.patch index e23970dfb..6a28594cb 100644 --- a/patches/server/0870-Ensure-entity-passenger-world-matches-ridden-entity.patch +++ b/patches/server/0870-Ensure-entity-passenger-world-matches-ridden-entity.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Ensure entity passenger world matches ridden entity Bad plugins doing this would cause some obvious problems... diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index fc03e5ddc126a57d4ca9f158b7d0f67401e1ca4b..7deb28159c822b2a05df228028278776e5bea4d5 100644 +index 0d327667f6cb1ad2adf993b14883b7967049aa02..9d8d4f4aef4f7a055f697761d31df9a285c7a2c7 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2632,6 +2632,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2631,6 +2631,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } protected boolean addPassenger(Entity entity) { // CraftBukkit diff --git a/patches/server/0871-Guard-against-invalid-entity-positions.patch b/patches/server/0871-Guard-against-invalid-entity-positions.patch index abb268d6b..d5da22e10 100644 --- a/patches/server/0871-Guard-against-invalid-entity-positions.patch +++ b/patches/server/0871-Guard-against-invalid-entity-positions.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Guard against invalid entity positions Anything not finite should be blocked and logged diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 7deb28159c822b2a05df228028278776e5bea4d5..f8652e17a1d9779b6ca39aa251b15f49e3b2f6e1 100644 +index 9d8d4f4aef4f7a055f697761d31df9a285c7a2c7..9e5e7fd12468cd409152a2c41ceb811209594a6c 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4136,11 +4136,33 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4135,11 +4135,33 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale); } diff --git a/patches/server/0880-Add-pre-unbreaking-amount-to-PlayerItemDamageEvent.patch b/patches/server/0880-Add-pre-unbreaking-amount-to-PlayerItemDamageEvent.patch index 13fb504e8..02e3a789c 100644 --- a/patches/server/0880-Add-pre-unbreaking-amount-to-PlayerItemDamageEvent.patch +++ b/patches/server/0880-Add-pre-unbreaking-amount-to-PlayerItemDamageEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add pre-unbreaking amount to PlayerItemDamageEvent diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index acd80da6e249f83ccd96c3bd24c3b75d9084fc91..2772eafc6ad0b7376a4d8b3e0342634c3cdb223e 100644 +index 30b307076e61c183acd5a1d900043b09f54734fc..6b3cfc19c4fd1382ddf534265a1114995a4f6b55 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -565,10 +565,11 @@ public final class ItemStack { +@@ -563,10 +563,11 @@ public final class ItemStack { } } diff --git a/patches/server/0892-Add-support-for-Proxy-Protocol.patch b/patches/server/0892-Add-support-for-Proxy-Protocol.patch index c916005e0..220fd0aeb 100644 --- a/patches/server/0892-Add-support-for-Proxy-Protocol.patch +++ b/patches/server/0892-Add-support-for-Proxy-Protocol.patch @@ -4,6 +4,18 @@ Date: Thu, 7 Apr 2022 16:13:39 +0200 Subject: [PATCH] Add support for Proxy Protocol +diff --git a/build.gradle.kts b/build.gradle.kts +index 3ff7814add16834c70494afb76d8a7788545d009..50d35d6e60f398501af447319de9d6ccd4db8b00 100644 +--- a/build.gradle.kts ++++ b/build.gradle.kts +@@ -22,6 +22,7 @@ dependencies { + */ + implementation("org.apache.logging.log4j:log4j-core:2.17.1") // Paper - implementation + annotationProcessor("org.apache.logging.log4j:log4j-core:2.17.1") // Paper - Needed to generate meta for our Log4j plugins ++ implementation("io.netty:netty-codec-haproxy:4.1.76.Final") + // Paper end + implementation("org.apache.logging.log4j:log4j-iostreams:2.17.1") // Paper + implementation("org.apache.logging.log4j:log4j-slf4j18-impl:2.17.1") // Paper diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java index 72e17ac76e5f3ac1283bec2133f76bc197353dd6..d4ff14b9e6028259c27ea9cb2b4be587ebabfb41 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java diff --git a/patches/server/0896-Prevent-entity-loading-causing-async-lookups.patch b/patches/server/0896-Prevent-entity-loading-causing-async-lookups.patch index ef0886bec..6957da726 100644 --- a/patches/server/0896-Prevent-entity-loading-causing-async-lookups.patch +++ b/patches/server/0896-Prevent-entity-loading-causing-async-lookups.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Prevent entity loading causing async lookups diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index f8652e17a1d9779b6ca39aa251b15f49e3b2f6e1..e1b7fc9fb342cc03d3447d3638f9376ef89d5543 100644 +index 9e5e7fd12468cd409152a2c41ceb811209594a6c..87a2228c5c5038153935184f0e4a2f11053b202d 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -747,6 +747,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -746,6 +746,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public void baseTick() { this.level.getProfiler().push("entityBaseTick");