diff --git a/patches/unapplied/api/Add-BellRevealRaiderEvent.patch b/patches/api/Add-BellRevealRaiderEvent.patch similarity index 100% rename from patches/unapplied/api/Add-BellRevealRaiderEvent.patch rename to patches/api/Add-BellRevealRaiderEvent.patch diff --git a/patches/unapplied/api/Add-PufferFishStateChangeEvent.patch b/patches/api/Add-PufferFishStateChangeEvent.patch similarity index 100% rename from patches/unapplied/api/Add-PufferFishStateChangeEvent.patch rename to patches/api/Add-PufferFishStateChangeEvent.patch diff --git a/patches/unapplied/server/Add-BellRevealRaiderEvent.patch b/patches/server/Add-BellRevealRaiderEvent.patch similarity index 89% rename from patches/unapplied/server/Add-BellRevealRaiderEvent.patch rename to patches/server/Add-BellRevealRaiderEvent.patch index d811b71a8e..27911b4ffd 100644 --- a/patches/unapplied/server/Add-BellRevealRaiderEvent.patch +++ b/patches/server/Add-BellRevealRaiderEvent.patch @@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java @@ -0,0 +0,0 @@ public class BellBlockEntity extends BlockEntity { private static void makeRaidersGlow(Level world, BlockPos pos, List hearingEntities) { - hearingEntities.stream().filter((livingEntity) -> { - return isRaiderWithinRange(pos, livingEntity); + hearingEntities.stream().filter((entity) -> { + return isRaiderWithinRange(pos, entity); - }).forEach(BellBlockEntity::glow); + }).forEach(entity -> glow(entity, pos)); // Paper - pass BlockPos } @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - private static void glow(LivingEntity entity) { + // Paper start + private static void glow(LivingEntity entity) { glow(entity, null); } -+ private static void glow(LivingEntity entity, BlockPos pos) { ++ private static void glow(LivingEntity entity, @javax.annotation.Nullable BlockPos pos) { + if (pos != null && !new io.papermc.paper.event.block.BellRevealRaiderEvent(entity.level.getWorld().getBlockAt(net.minecraft.server.MCUtil.toLocation(entity.level, pos)), entity.getBukkitEntity()).callEvent()) return; + // Paper end entity.addEffect(new MobEffectInstance(MobEffects.GLOWING, 60)); diff --git a/patches/unapplied/server/Add-PufferFishStateChangeEvent.patch b/patches/server/Add-PufferFishStateChangeEvent.patch similarity index 100% rename from patches/unapplied/server/Add-PufferFishStateChangeEvent.patch rename to patches/server/Add-PufferFishStateChangeEvent.patch diff --git a/patches/unapplied/server/Add-option-to-fix-items-merging-through-walls.patch b/patches/server/Add-option-to-fix-items-merging-through-walls.patch similarity index 99% rename from patches/unapplied/server/Add-option-to-fix-items-merging-through-walls.patch rename to patches/server/Add-option-to-fix-items-merging-through-walls.patch index 4d659ec01e..ea5ba11e7a 100644 --- a/patches/unapplied/server/Add-option-to-fix-items-merging-through-walls.patch +++ b/patches/server/Add-option-to-fix-items-merging-through-walls.patch @@ -18,7 +18,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + fixItemsMergingThroughWalls = getBoolean("fix-items-merging-through-walls", fixItemsMergingThroughWalls); + } } - diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java diff --git a/patches/unapplied/server/Fix-PlayerBucketEmptyEvent-result-itemstack.patch b/patches/server/Fix-PlayerBucketEmptyEvent-result-itemstack.patch similarity index 100% rename from patches/unapplied/server/Fix-PlayerBucketEmptyEvent-result-itemstack.patch rename to patches/server/Fix-PlayerBucketEmptyEvent-result-itemstack.patch diff --git a/patches/server/MC-Dev-fixes.patch b/patches/server/MC-Dev-fixes.patch index 37c212c36f..19bbcdde2b 100644 --- a/patches/server/MC-Dev-fixes.patch +++ b/patches/server/MC-Dev-fixes.patch @@ -305,3 +305,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static class BiomeBuilder { @Nullable private Biome.Precipitation precipitation; +diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java ++++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { + } + + static record Configuration(Palette.Factory factory, int bits) { +- Configuration(Palette.Factory factory, int i) { +- this.factory = factory; +- this.bits = i; +- } + + public PalettedContainer.Data createData(IdMap idList, PaletteResize listener, int size) { + BitStorage bitStorage = (BitStorage)(this.bits == 0 ? new ZeroBitStorage(size) : new SimpleBitStorage(this.bits, size)); +@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { + } + + static record Data(PalettedContainer.Configuration configuration, BitStorage storage, Palette palette) { +- final BitStorage storage; +- final Palette palette; +- + public void copyFrom(Palette palette, BitStorage storage) { + for(int i = 0; i < storage.getSize(); ++i) { + T object = palette.valueFor(storage.get(i)); +@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { + } + + static record DiscData(List paletteEntries, Optional storage) { +- DiscData(List list, Optional optional) { +- this.paletteEntries = list; +- this.storage = optional; +- } + } + + public abstract static class Strategy { diff --git a/patches/server/Synchronize-PalettedContainer-instead-of-ReentrantLo.patch b/patches/server/Synchronize-PalettedContainer-instead-of-ReentrantLo.patch new file mode 100644 index 0000000000..1f6db3988b --- /dev/null +++ b/patches/server/Synchronize-PalettedContainer-instead-of-ReentrantLo.patch @@ -0,0 +1,91 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Fri, 29 May 2020 20:29:02 -0400 +Subject: [PATCH] Synchronize PalettedContainer instead of ReentrantLock + +Mojang has flaws in their logic about chunks being concurrently +wrote to. So we constantly see crashes around multiple threads writing. + +Additionally, java has optimized synchronization so well that its +in many times faster than trying to manage read wrote locks for low +contention situations. + +And this is extremely a low contention situation. + +diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java ++++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { + private final ThreadingDetector threadingDetector = new ThreadingDetector("PalettedContainer"); + + public void acquire() { +- this.threadingDetector.checkAndLock(); ++ // this.threadingDetector.checkAndLock(); // Paper - disable this - use proper synchronization + } + + public void release() { +- this.threadingDetector.checkAndUnlock(); ++ // this.threadingDetector.checkAndUnlock(); // Paper - disable this + } + + public static Codec> codec(IdMap idList, Codec entryCodec, PalettedContainer.Strategy provider, T object) { +- return RecordCodecBuilder.create((instance) -> { ++ return RecordCodecBuilder.>create((instance) -> { // Paper - decompile fixes + return instance.group(entryCodec.mapResult(ExtraCodecs.orElsePartial(object)).listOf().fieldOf("palette").forGetter(PalettedContainer.DiscData::paletteEntries), Codec.LONG_STREAM.optionalFieldOf("data").forGetter(PalettedContainer.DiscData::storage)).apply(instance, PalettedContainer.DiscData::new); + }).comapFlatMap((serialized) -> { + return read(idList, provider, serialized); +@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { + return data2.palette.idFor(object); + } + +- public T getAndSet(int x, int y, int z, T value) { ++ public synchronized T getAndSet(int x, int y, int z, T value) { // Paper - synchronize + this.acquire(); + + Object var5; +@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { + return this.data.palette.valueFor(j); + } + +- public void set(int x, int y, int z, T value) { ++ public synchronized void set(int x, int y, int z, T value) { // Paper - synchronize + this.acquire(); + + try { +@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { + }); + } + +- public void read(FriendlyByteBuf buf) { ++ public synchronized void read(FriendlyByteBuf buf) { // Paper - synchronize + this.acquire(); + + try { +@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { + + } + +- public void write(FriendlyByteBuf buf) { ++ public synchronized void write(FriendlyByteBuf buf) { // Paper - synchronize + this.acquire(); + + try { +@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { + + } + +- private static DataResult> read(IdMap idList, PalettedContainer.Strategy provider, PalettedContainer.DiscData serialized) { ++ private static synchronized DataResult> read(IdMap idList, PalettedContainer.Strategy provider, PalettedContainer.DiscData serialized) { // Paper - synchronize + List list = serialized.paletteEntries(); + int i = provider.size(); + int j = provider.calculateBitsForSerialization(idList, list.size()); +@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { + return DataResult.success(new PalettedContainer<>(idList, provider, configuration, bitStorage, list)); + } + +- private PalettedContainer.DiscData write(IdMap idList, PalettedContainer.Strategy provider) { ++ private synchronized PalettedContainer.DiscData write(IdMap idList, PalettedContainer.Strategy provider) { // Paper - synchronize + this.acquire(); + + PalettedContainer.DiscData var12; diff --git a/patches/unapplied/server/Synchronize-PalettedContainer-instead-of-ReentrantLo.patch b/patches/unapplied/server/Synchronize-PalettedContainer-instead-of-ReentrantLo.patch deleted file mode 100644 index 0741d92a5d..0000000000 --- a/patches/unapplied/server/Synchronize-PalettedContainer-instead-of-ReentrantLo.patch +++ /dev/null @@ -1,92 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Fri, 29 May 2020 20:29:02 -0400 -Subject: [PATCH] Synchronize PalettedContainer instead of ReentrantLock - -Mojang has flaws in their logic about chunks being concurrently -wrote to. So we constantly see crashes around multiple threads writing. - -Additionally, java has optimized synchronization so well that its -in many times faster than trying to manage read wrote locks for low -contention situations. - -And this is extremely a low contention situation. - -diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { - private final DebugBuffer> traces = null; - - public void acquire() { -+ /* // Paper start - disable this - use proper synchronization - if (this.traces != null) { - Thread thread = Thread.currentThread(); - this.traces.push(Pair.of(thread, thread.getStackTrace())); - } - - ThreadingDetector.checkAndLock(this.lock, this.traces, "PalettedContainer"); -+ */ // Paper end - } - - public void release() { -- this.lock.release(); -+ //this.lock.release(); // Paper - disable this - } - - // Paper start - Anti-Xray - Add preset values -@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { - return this.palette.idFor(objectAdded); - } - -- public T getAndSet(int x, int y, int z, T value) { -+ public synchronized T getAndSet(int x, int y, int z, T value) { // Paper - synchronize - Object var6; - try { - this.acquire(); -@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { - return (T)(object == null ? this.defaultValue : object); - } - -- public void set(int i, int j, int k, T object) { -+ public synchronized void set(int i, int j, int k, T object) { // Paper - synchronize - try { - this.acquire(); - this.set(getIndex(i, j, k), object); -@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { - return (T)(object == null ? this.defaultValue : object); - } - -- public void read(FriendlyByteBuf buf) { -+ public synchronized void read(FriendlyByteBuf buf) { // Paper - synchronize - try { - this.acquire(); - int i = buf.readByte(); -@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { - - // Paper start - Anti-Xray - Add chunk packet info - @Deprecated public void write(FriendlyByteBuf buf) { write(buf, null, 0); } // Notice for updates: Please make sure this method isn't used anywhere -- public void write(FriendlyByteBuf buf, com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo, int bottomBlockY) { -+ public synchronized void write(FriendlyByteBuf buf, com.destroystokyo.paper.antixray.ChunkPacketInfo chunkPacketInfo, int bottomBlockY) { // Paper - synchronize - // Paper end - try { - this.acquire(); -@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { - - } - -- public void read(ListTag paletteNbt, long[] data) { -+ public synchronized void read(ListTag paletteNbt, long[] data) { // Paper - synchronize - try { - this.acquire(); - // Paper - Anti-Xray - TODO: Should this.presetValues.length just be added here (faster) or should the contents be compared to calculate the size (less RAM)? -@@ -0,0 +0,0 @@ public class PalettedContainer implements PaletteResize { - - } - -- public void write(CompoundTag nbt, String paletteKey, String dataKey) { -+ public synchronized void write(CompoundTag nbt, String paletteKey, String dataKey) { // Paper - synchronize - try { - this.acquire(); - HashMapPalette hashMapPalette = new HashMapPalette<>(this.registry, this.bits, this.dummyPaletteResize, this.reader, this.writer);