From b6be217e0396e31095f8ced99d161b29c2740dd4 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 24 Nov 2021 16:07:19 +0100 Subject: [PATCH] More more more more more more more more more more more more more work --- build-data/dev-imports.txt | 1 + ...reResultEvent-PrepareGrindstoneEvent.patch | 0 .../api/Add-entity-liquid-API.patch | 0 .../api/Support-components-in-ItemMeta.patch | 0 ...-TargetReasons-for-1.16-mob-behavior.patch | 0 ...-Plugin-Tickets-to-API-Chunk-Methods.patch | 0 .../server/Add-PrepareResultEvent.patch | 0 .../server/Add-entity-liquid-API.patch | 2 +- ...up-duplicated-GameProfile-Properties.patch | 0 ...nvert-legacy-attributes-in-Item-Meta.patch | 0 ...k-for-portal-on-world-gen-entity-add.patch | 0 ...argetLivingEntityEvent-for-1.16-mobs.patch | 2 +- .../Optimize-Bit-Operations-by-inlining.patch | 8 +- ...ze-NibbleArray-to-use-pooled-buffers.patch | 161 ++++++++++++------ .../Remove-some-streams-from-structures.patch | 37 ++++ ...from-classes-related-villager-gossip.patch | 0 ...awn-player-in-correct-world-on-login.patch | 0 ...te-operations-for-updating-light-dat.patch | 16 +- .../Support-components-in-ItemMeta.patch | 0 .../Support-old-UUID-format-for-NBT.patch | 41 ++--- ...pdate-itemstack-legacy-name-and-lore.patch | 2 +- ...llow-delegation-to-vanilla-chunk-gen.patch | 85 --------- ...llow-delegation-to-vanilla-chunk-gen.patch | 67 -------- .../Remove-some-streams-from-structures.patch | 106 ------------ 24 files changed, 177 insertions(+), 351 deletions(-) rename patches/{unapplied => }/api/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch (100%) rename patches/{unapplied => }/api/Add-entity-liquid-API.patch (100%) rename patches/{unapplied => }/api/Support-components-in-ItemMeta.patch (100%) rename patches/{unapplied => }/api/added-2-new-TargetReasons-for-1.16-mob-behavior.patch (100%) rename patches/{unapplied => }/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch (100%) rename patches/{unapplied => }/server/Add-PrepareResultEvent.patch (100%) rename patches/{unapplied => }/server/Add-entity-liquid-API.patch (98%) rename patches/{unapplied => }/server/Clean-up-duplicated-GameProfile-Properties.patch (100%) rename patches/{unapplied => }/server/Convert-legacy-attributes-in-Item-Meta.patch (100%) rename patches/{unapplied => }/server/Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch (100%) rename patches/{unapplied => }/server/Improve-EntityTargetLivingEntityEvent-for-1.16-mobs.patch (98%) rename patches/{unapplied => }/server/Optimize-Bit-Operations-by-inlining.patch (98%) rename patches/{unapplied => }/server/Optimize-NibbleArray-to-use-pooled-buffers.patch (71%) create mode 100644 patches/server/Remove-some-streams-from-structures.patch rename patches/{unapplied => }/server/Remove-streams-from-classes-related-villager-gossip.patch (100%) rename patches/{unapplied => }/server/Spawn-player-in-correct-world-on-login.patch (100%) rename patches/{unapplied => }/server/Stop-copy-on-write-operations-for-updating-light-dat.patch (97%) rename patches/{unapplied => }/server/Support-components-in-ItemMeta.patch (100%) rename patches/{unapplied => }/server/Support-old-UUID-format-for-NBT.patch (70%) rename patches/{unapplied => }/server/Update-itemstack-legacy-name-and-lore.patch (97%) delete mode 100644 patches/unapplied/api/Allow-delegation-to-vanilla-chunk-gen.patch delete mode 100644 patches/unapplied/server/Allow-delegation-to-vanilla-chunk-gen.patch delete mode 100644 patches/unapplied/server/Remove-some-streams-from-structures.patch diff --git a/build-data/dev-imports.txt b/build-data/dev-imports.txt index b818b96e27..286aeeaaa9 100644 --- a/build-data/dev-imports.txt +++ b/build-data/dev-imports.txt @@ -8,3 +8,4 @@ # To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId: # minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter # minecraft net/minecraft/world/level/entity/LevelEntityGetter.java + diff --git a/patches/unapplied/api/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch b/patches/api/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch similarity index 100% rename from patches/unapplied/api/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch rename to patches/api/Add-PrepareResultEvent-PrepareGrindstoneEvent.patch diff --git a/patches/unapplied/api/Add-entity-liquid-API.patch b/patches/api/Add-entity-liquid-API.patch similarity index 100% rename from patches/unapplied/api/Add-entity-liquid-API.patch rename to patches/api/Add-entity-liquid-API.patch diff --git a/patches/unapplied/api/Support-components-in-ItemMeta.patch b/patches/api/Support-components-in-ItemMeta.patch similarity index 100% rename from patches/unapplied/api/Support-components-in-ItemMeta.patch rename to patches/api/Support-components-in-ItemMeta.patch diff --git a/patches/unapplied/api/added-2-new-TargetReasons-for-1.16-mob-behavior.patch b/patches/api/added-2-new-TargetReasons-for-1.16-mob-behavior.patch similarity index 100% rename from patches/unapplied/api/added-2-new-TargetReasons-for-1.16-mob-behavior.patch rename to patches/api/added-2-new-TargetReasons-for-1.16-mob-behavior.patch diff --git a/patches/unapplied/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch b/patches/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch similarity index 100% rename from patches/unapplied/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch rename to patches/server/Add-Plugin-Tickets-to-API-Chunk-Methods.patch diff --git a/patches/unapplied/server/Add-PrepareResultEvent.patch b/patches/server/Add-PrepareResultEvent.patch similarity index 100% rename from patches/unapplied/server/Add-PrepareResultEvent.patch rename to patches/server/Add-PrepareResultEvent.patch diff --git a/patches/unapplied/server/Add-entity-liquid-API.patch b/patches/server/Add-entity-liquid-API.patch similarity index 98% rename from patches/unapplied/server/Add-entity-liquid-API.patch rename to patches/server/Add-entity-liquid-API.patch index a8c4164158..b716f8b207 100644 --- a/patches/unapplied/server/Add-entity-liquid-API.patch +++ b/patches/server/Add-entity-liquid-API.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n +@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i return this.isInWater() || this.isInRain(); } diff --git a/patches/unapplied/server/Clean-up-duplicated-GameProfile-Properties.patch b/patches/server/Clean-up-duplicated-GameProfile-Properties.patch similarity index 100% rename from patches/unapplied/server/Clean-up-duplicated-GameProfile-Properties.patch rename to patches/server/Clean-up-duplicated-GameProfile-Properties.patch diff --git a/patches/unapplied/server/Convert-legacy-attributes-in-Item-Meta.patch b/patches/server/Convert-legacy-attributes-in-Item-Meta.patch similarity index 100% rename from patches/unapplied/server/Convert-legacy-attributes-in-Item-Meta.patch rename to patches/server/Convert-legacy-attributes-in-Item-Meta.patch diff --git a/patches/unapplied/server/Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch b/patches/server/Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch similarity index 100% rename from patches/unapplied/server/Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch rename to patches/server/Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch diff --git a/patches/unapplied/server/Improve-EntityTargetLivingEntityEvent-for-1.16-mobs.patch b/patches/server/Improve-EntityTargetLivingEntityEvent-for-1.16-mobs.patch similarity index 98% rename from patches/unapplied/server/Improve-EntityTargetLivingEntityEvent-for-1.16-mobs.patch rename to patches/server/Improve-EntityTargetLivingEntityEvent-for-1.16-mobs.patch index 88d87428c2..88bbdff0c8 100644 --- a/patches/unapplied/server/Improve-EntityTargetLivingEntityEvent-for-1.16-mobs.patch +++ b/patches/server/Improve-EntityTargetLivingEntityEvent-for-1.16-mobs.patch @@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!entity.canAttack(entityliving)) { - this.clearAttackTarget(entity); + this.clearAttackTarget(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_INVALID); // Paper - } else if (StopAttackingIfTargetInvalid.isTiredOfTryingToReachTarget((LivingEntity) entity)) { + } else if (StopAttackingIfTargetInvalid.isTiredOfTryingToReachTarget(entity)) { - this.clearAttackTarget(entity); + this.clearAttackTarget(entity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); // Paper } else if (this.isCurrentTargetDeadOrRemoved(entity)) { diff --git a/patches/unapplied/server/Optimize-Bit-Operations-by-inlining.patch b/patches/server/Optimize-Bit-Operations-by-inlining.patch similarity index 98% rename from patches/unapplied/server/Optimize-Bit-Operations-by-inlining.patch rename to patches/server/Optimize-Bit-Operations-by-inlining.patch index 1e6da24bb7..95c664cc4c 100644 --- a/patches/unapplied/server/Optimize-Bit-Operations-by-inlining.patch +++ b/patches/server/Optimize-Bit-Operations-by-inlining.patch @@ -76,8 +76,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static long asLong(int x, int y, int z) { - long l = 0L; -- l = l | ((long)x & PACKED_X_MASK) << X_OFFSET; -- l = l | ((long)y & PACKED_Y_MASK) << 0; +- l |= ((long)x & PACKED_X_MASK) << X_OFFSET; +- l |= ((long)y & PACKED_Y_MASK) << 0; - return l | ((long)z & PACKED_Z_MASK) << Z_OFFSET; + return (((long) x & (long) 67108863) << 38) | (((long) y & (long) 4095)) | (((long) z & (long) 67108863) << 12); // Paper - inline constants and simplify } @@ -180,8 +180,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public static long asLong(int x, int y, int z) { - long l = 0L; -- l = l | ((long)x & 4194303L) << 42; -- l = l | ((long)y & 1048575L) << 0; +- l |= ((long)x & 4194303L) << 42; +- l |= ((long)y & 1048575L) << 0; - return l | ((long)z & 4194303L) << 20; + return (((long) x & 4194303L) << 42) | (((long) y & 1048575L)) | (((long) z & 4194303L) << 20); // Paper - Simplify to reduce instruction count } diff --git a/patches/unapplied/server/Optimize-NibbleArray-to-use-pooled-buffers.patch b/patches/server/Optimize-NibbleArray-to-use-pooled-buffers.patch similarity index 71% rename from patches/unapplied/server/Optimize-NibbleArray-to-use-pooled-buffers.patch rename to patches/server/Optimize-NibbleArray-to-use-pooled-buffers.patch index 50ce4646ce..55bfd61ae8 100644 --- a/patches/unapplied/server/Optimize-NibbleArray-to-use-pooled-buffers.patch +++ b/patches/server/Optimize-NibbleArray-to-use-pooled-buffers.patch @@ -8,26 +8,91 @@ an object pool for these. Uses lots of advanced new capabilities of the Paper codebase :) +diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java ++++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java +@@ -0,0 +0,0 @@ package net.minecraft.network.protocol.game; + + import java.util.BitSet; + import javax.annotation.Nullable; ++ ++import io.netty.channel.ChannelFuture; + import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.network.protocol.Packet; ++import net.minecraft.server.level.ServerPlayer; + import net.minecraft.world.level.ChunkPos; + import net.minecraft.world.level.chunk.LevelChunk; + import net.minecraft.world.level.lighting.LevelLightEngine; +@@ -0,0 +0,0 @@ public class ClientboundLevelChunkWithLightPacket implements Packet skyUpdates; private final List blockUpdates; private final boolean trustEdges; @@ -36,16 +101,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + java.lang.Runnable cleaner2; + java.util.concurrent.atomic.AtomicInteger remainingSends = new java.util.concurrent.atomic.AtomicInteger(0); + -+ @Override -+ public void onPacketDispatch(ServerPlayer player) { ++ public void onPacketDispatch(net.minecraft.server.level.ServerPlayer player) { + remainingSends.incrementAndGet(); + } + -+ @Override -+ public void onPacketDispatchFinish(ServerPlayer player, ChannelFuture future) { ++ public void onPacketDispatchFinish(net.minecraft.server.level.ServerPlayer player, io.netty.channel.ChannelFuture future) { + if (remainingSends.decrementAndGet() <= 0) { + // incase of any race conditions, schedule this delayed -+ MCUtil.scheduleTask(5, () -> { ++ net.minecraft.server.MCUtil.scheduleTask(5, () -> { + if (remainingSends.get() == 0) { + cleaner1.run(); + cleaner2.run(); @@ -53,33 +116,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + }, "Light Packet Release"); + } + } -+ -+ @Override -+ public boolean hasFinishListener() { -+ return true; -+ } -+ + // Paper end - public ClientboundLightUpdatePacket(ChunkPos chunkPos, LevelLightEngine lightProvider, @Nullable BitSet bitSet, @Nullable BitSet bitSet2, boolean nonEdge) { - this.x = chunkPos.x; -@@ -0,0 +0,0 @@ public class ClientboundLightUpdatePacket implements Packet storage, long sectionPos) { @@ -0,0 +0,0 @@ public abstract class LayerLightSectionStorage> - protected void queueSectionData(long sectionPos, @Nullable DataLayer array, boolean bl) { + protected void queueSectionData(long sectionPos, @Nullable DataLayer array, boolean nonEdge) { if (array != null) { - this.queuedSections.put(sectionPos, array); + DataLayer remove = this.queuedSections.put(sectionPos, array); if (remove != null && remove.cleaner != null) remove.cleaner.run(); // Paper - clean up when removed - if (!bl) { + if (!nonEdge) { this.untrustedSections.add(sectionPos); } } else { @@ -303,19 +360,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -0,0 +0,0 @@ public class CraftChunk implements Chunk { - sectionSkyLights[i] = CraftChunk.emptyLight; - } else { - sectionSkyLights[i] = new byte[2048]; -- System.arraycopy(skyLightArray.getData(), 0, sectionSkyLights[i], 0, 2048); -+ System.arraycopy(skyLightArray.getIfSet(), 0, sectionSkyLights[i], 0, 2048); // Paper - } - DataLayer emitLightArray = lightengine.getLayerListener(LightLayer.BLOCK).getDataLayerData(SectionPos.of(x, i, z)); - if (emitLightArray == null) { - sectionEmitLights[i] = CraftChunk.emptyLight; - } else { - sectionEmitLights[i] = new byte[2048]; -- System.arraycopy(emitLightArray.getData(), 0, sectionEmitLights[i], 0, 2048); -+ System.arraycopy(emitLightArray.getIfSet(), 0, sectionEmitLights[i], 0, 2048); // Paper - } + sectionSkyLights[i] = CraftChunk.emptyLight; + } else { + sectionSkyLights[i] = new byte[2048]; +- System.arraycopy(skyLightArray.getData(), 0, sectionSkyLights[i], 0, 2048); ++ System.arraycopy(skyLightArray.getIfSet(), 0, sectionSkyLights[i], 0, 2048); // Paper } - } + DataLayer emitLightArray = lightengine.getLayerListener(LightLayer.BLOCK).getDataLayerData(SectionPos.of(x, i, z)); + if (emitLightArray == null) { + sectionEmitLights[i] = CraftChunk.emptyLight; + } else { + sectionEmitLights[i] = new byte[2048]; +- System.arraycopy(emitLightArray.getData(), 0, sectionEmitLights[i], 0, 2048); ++ System.arraycopy(emitLightArray.getIfSet(), 0, sectionEmitLights[i], 0, 2048); // Paper + } + + if (biome != null) { diff --git a/patches/server/Remove-some-streams-from-structures.patch b/patches/server/Remove-some-streams-from-structures.patch new file mode 100644 index 0000000000..7ec0c8d1cf --- /dev/null +++ b/patches/server/Remove-some-streams-from-structures.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Josh Roy <10731363+JRoy@users.noreply.github.com> +Date: Mon, 29 Jun 2020 17:03:06 -0400 +Subject: [PATCH] Remove some streams from structures + +This showed up a lot in the spark profiler, should have a low-medium performance improvement. + +diff --git a/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java b/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java ++++ b/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java +@@ -0,0 +0,0 @@ import net.minecraft.world.level.levelgen.feature.structures.StructureTemplatePo + import net.minecraft.world.level.levelgen.structure.BoundingBox; + import net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece; + import net.minecraft.world.level.levelgen.structure.StructurePiece; ++import net.minecraft.world.level.levelgen.structure.StructureStart; + + public class Beardifier implements NoiseChunk.NoiseFiller { + public static final int BEARD_KERNEL_RADIUS = 12; +@@ -0,0 +0,0 @@ public class Beardifier implements NoiseChunk.NoiseFiller { + this.rigids = new ObjectArrayList<>(10); + + for(StructureFeature structureFeature : StructureFeature.NOISE_AFFECTING_FEATURES) { +- structureAccessor.startsForFeature(SectionPos.bottomOf(chunk), structureFeature).forEach((structureStart) -> { ++ for (StructureStart structureStart : structureAccessor.startsForFeature(SectionPos.bottomOf(chunk), structureFeature)) { // Paper - remove streams + for(StructurePiece structurePiece : structureStart.getPieces()) { + if (structurePiece.isCloseToChunk(chunkPos, 12)) { + if (structurePiece instanceof PoolElementStructurePiece) { +@@ -0,0 +0,0 @@ public class Beardifier implements NoiseChunk.NoiseFiller { + } + } + +- }); ++ } // Paper + } + + this.pieceIterator = this.rigids.iterator(); diff --git a/patches/unapplied/server/Remove-streams-from-classes-related-villager-gossip.patch b/patches/server/Remove-streams-from-classes-related-villager-gossip.patch similarity index 100% rename from patches/unapplied/server/Remove-streams-from-classes-related-villager-gossip.patch rename to patches/server/Remove-streams-from-classes-related-villager-gossip.patch diff --git a/patches/unapplied/server/Spawn-player-in-correct-world-on-login.patch b/patches/server/Spawn-player-in-correct-world-on-login.patch similarity index 100% rename from patches/unapplied/server/Spawn-player-in-correct-world-on-login.patch rename to patches/server/Spawn-player-in-correct-world-on-login.patch diff --git a/patches/unapplied/server/Stop-copy-on-write-operations-for-updating-light-dat.patch b/patches/server/Stop-copy-on-write-operations-for-updating-light-dat.patch similarity index 97% rename from patches/unapplied/server/Stop-copy-on-write-operations-for-updating-light-dat.patch rename to patches/server/Stop-copy-on-write-operations-for-updating-light-dat.patch index 605b7d91fd..be3a3be127 100644 --- a/patches/unapplied/server/Stop-copy-on-write-operations-for-updating-light-dat.patch +++ b/patches/server/Stop-copy-on-write-operations-for-updating-light-dat.patch @@ -180,20 +180,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override @@ -0,0 +0,0 @@ public class SkyLightSectionStorage extends LayerLightSectionStorage YXZ_LISTTAG_INT_COMPARATOR = Comparator.comparingInt((listTag) -> { -+ private static final Comparator YXZ_LISTTAG_INT_COMPARATOR = Comparator.comparingInt((listTag) -> { // Paper - decompile fix - return listTag.getInt(1); - }).thenComparingInt((listTag) -> { - return listTag.getInt(0); - }).thenComparingInt((listTag) -> { - return listTag.getInt(2); +- private static final Comparator YXZ_LISTTAG_INT_COMPARATOR = Comparator.comparingInt((nbt) -> { ++ private static final Comparator YXZ_LISTTAG_INT_COMPARATOR = Comparator.comparingInt((nbt) -> { // Paper - decompile fix + return nbt.getInt(1); + }).thenComparingInt((nbt) -> { + return nbt.getInt(0); + }).thenComparingInt((nbt) -> { + return nbt.getInt(2); }); -- private static final Comparator YXZ_LISTTAG_DOUBLE_COMPARATOR = Comparator.comparingDouble((listTag) -> { -+ private static final Comparator YXZ_LISTTAG_DOUBLE_COMPARATOR = Comparator.comparingDouble((listTag) -> { // Paper - decompile fix - return listTag.getDouble(1); - }).thenComparingDouble((listTag) -> { - return listTag.getDouble(0); +- private static final Comparator YXZ_LISTTAG_DOUBLE_COMPARATOR = Comparator.comparingDouble((nbt) -> { ++ private static final Comparator YXZ_LISTTAG_DOUBLE_COMPARATOR = Comparator.comparingDouble((nbt) -> { // Paper - decompile fix + return nbt.getDouble(1); + }).thenComparingDouble((nbt) -> { + return nbt.getDouble(0); @@ -0,0 +0,0 @@ public final class NbtUtils { + if (compound.contains("Name", 8)) { string = compound.getString("Name"); } - + // Paper start - support string UUID's + if (compound.contains("Id", 8)) { + uUID = UUID.fromString(compound.getString("Id")); + } + // Paper end + if (compound.hasUUID("Id")) { uUID = compound.getUUID("Id"); - } @@ -0,0 +0,0 @@ public final class NbtUtils { } public static CompoundTag update(DataFixer fixer, DataFixTypes fixTypes, CompoundTag compound, int oldVersion, int targetVersion) { - return fixer.update(fixTypes.getType(), new Dynamic<>(NbtOps.INSTANCE, compound), oldVersion, targetVersion).getValue(); -+ return (CompoundTag) fixer.update(fixTypes.getType(), new com.mojang.serialization.Dynamic<>(NbtOps.INSTANCE, compound), oldVersion, targetVersion).getValue(); // Paper - decompile fix ++ return (CompoundTag) fixer.update(fixTypes.getType(), new Dynamic<>(NbtOps.INSTANCE, compound), oldVersion, targetVersion).getValue(); // Paper - decompile fix } public static Component toPrettyComponent(Tag element) { -@@ -0,0 +0,0 @@ public final class NbtUtils { - CompoundTag compoundTag2 = new CompoundTag(); - if (i + 2 <= string.length()) { - String string3 = string.substring(i + 1, string.indexOf(125, i)); -- COMMA_SPLITTER.split(string3).forEach((string2) -> { -- List list = COLON_SPLITTER.splitToList(string2); -+ COMMA_SPLITTER.split(string3).forEach(it -> { // Paper - decompile fix -+ List list = COLON_SPLITTER.splitToList(it); // Paper - decompile fix - if (list.size() == 2) { - compoundTag2.putString(list.get(0), list.get(1)); - } else { diff --git a/patches/unapplied/server/Update-itemstack-legacy-name-and-lore.patch b/patches/server/Update-itemstack-legacy-name-and-lore.patch similarity index 97% rename from patches/unapplied/server/Update-itemstack-legacy-name-and-lore.patch rename to patches/server/Update-itemstack-legacy-name-and-lore.patch index 53c5ba5f07..1cbc2a57de 100644 --- a/patches/unapplied/server/Update-itemstack-legacy-name-and-lore.patch +++ b/patches/server/Update-itemstack-legacy-name-and-lore.patch @@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public ItemStack(ItemLike item) { @@ -0,0 +0,0 @@ public final class ItemStack { - this.tag = (CompoundTag) nbttagcompound.getCompound("tag").copy(); + this.tag = nbttagcompound.getCompound("tag").copy(); // CraftBukkit end this.processEnchantOrder(this.tag); // Paper + this.processText(); // Paper diff --git a/patches/unapplied/api/Allow-delegation-to-vanilla-chunk-gen.patch b/patches/unapplied/api/Allow-delegation-to-vanilla-chunk-gen.patch deleted file mode 100644 index ee37e4bdd7..0000000000 --- a/patches/unapplied/api/Allow-delegation-to-vanilla-chunk-gen.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MiniDigger | Martin -Date: Wed, 29 Apr 2020 02:09:17 +0200 -Subject: [PATCH] Allow delegation to vanilla chunk gen - - -diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/Bukkit.java -+++ b/src/main/java/org/bukkit/Bukkit.java -@@ -0,0 +0,0 @@ public final class Bukkit { - return server.createChunkData(world); - } - -+ // Paper start -+ /** -+ * Create a ChunkData for use in a generator, that is populated by the vanilla generator for that world -+ * -+ * @param world the world to create the ChunkData for -+ * @param x the x coordinate of the chunk -+ * @param z the z coordinate of the chunk -+ * @return a new ChunkData for the world -+ * -+ */ -+ @NotNull -+ public static ChunkGenerator.ChunkData createVanillaChunkData(@NotNull World world, int x, int z) { -+ return server.createVanillaChunkData(world, x, z); -+ } -+ // Paper stop -+ - /** - * Creates a boss bar instance to display to players. The progress - * defaults to 1.0 -diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/Server.java -+++ b/src/main/java/org/bukkit/Server.java -@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi - @NotNull - public ChunkGenerator.ChunkData createChunkData(@NotNull World world); - -+ // Paper start -+ /** -+ * Create a ChunkData for use in a generator, that is populated by the vanilla generator for that world -+ * -+ * @param world the world to create the ChunkData for -+ * @param x the x coordinate of the chunk -+ * @param z the z coordinate of the chunk -+ * @return a new ChunkData for the world -+ * -+ */ -+ @NotNull -+ ChunkGenerator.ChunkData createVanillaChunkData(@NotNull World world, int x, int z); -+ // Paper end -+ - /** - * Creates a boss bar instance to display to players. The progress - * defaults to 1.0 -diff --git a/src/main/java/org/bukkit/generator/ChunkGenerator.java b/src/main/java/org/bukkit/generator/ChunkGenerator.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/generator/ChunkGenerator.java -+++ b/src/main/java/org/bukkit/generator/ChunkGenerator.java -@@ -0,0 +0,0 @@ public abstract class ChunkGenerator { - return false; - } - -+ // Paper start -+ /** -+ * Create a ChunkData for use in a generator, that is populated by the vanilla generator for that world -+ * -+ * @param world the world to create the ChunkData for -+ * @param x the x coordinate of the chunk -+ * @param z the z coordinate of the chunk -+ * @return a new ChunkData for the world -+ * -+ */ -+ @NotNull -+ public ChunkData createVanillaChunkData(@NotNull World world, int x, int z) { -+ return Bukkit.getServer().createVanillaChunkData(world, x, z); -+ } -+ // Paper end -+ - /** - * Data for a Chunk. - */ diff --git a/patches/unapplied/server/Allow-delegation-to-vanilla-chunk-gen.patch b/patches/unapplied/server/Allow-delegation-to-vanilla-chunk-gen.patch deleted file mode 100644 index ba87373b8e..0000000000 --- a/patches/unapplied/server/Allow-delegation-to-vanilla-chunk-gen.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MiniDigger | Martin -Date: Wed, 29 Apr 2020 02:10:32 +0200 -Subject: [PATCH] Allow delegation to vanilla chunk gen - - -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -0,0 +0,0 @@ public final class CraftServer implements Server { - return new OldCraftChunkData(world); - } - -+ // Paper start -+ @Override -+ public ChunkGenerator.ChunkData createVanillaChunkData(World world, int x, int z) { -+ // get empty object -+ OldCraftChunkData data = (OldCraftChunkData) createChunkData(world); -+ // do bunch of vanilla shit -+ net.minecraft.server.level.ServerLevel nmsWorld = ((CraftWorld) world).getHandle(); -+ net.minecraft.world.level.chunk.ProtoChunk protoChunk = new net.minecraft.world.level.chunk.ProtoChunk(new net.minecraft.world.level.ChunkPos(x, z), null, nmsWorld, nmsWorld); -+ List list = new ArrayList<>(); -+ list.add(protoChunk); -+ net.minecraft.server.level.WorldGenRegion genRegion = new net.minecraft.server.level.WorldGenRegion(nmsWorld, list, net.minecraft.world.level.chunk.ChunkStatus.EMPTY, -1); -+ // call vanilla generator, one feature after another. Order here is important! -+ net.minecraft.world.level.chunk.ChunkGenerator chunkGenerator = nmsWorld.getChunkSource().generator; -+ if (chunkGenerator instanceof org.bukkit.craftbukkit.generator.CustomChunkGenerator) { -+ chunkGenerator = ((org.bukkit.craftbukkit.generator.CustomChunkGenerator) chunkGenerator).delegate; -+ } -+ chunkGenerator.createBiomes(nmsWorld.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), protoChunk); -+ chunkGenerator.fillFromNoise((runnable) -> {}, nmsWorld.structureFeatureManager(), protoChunk); -+ chunkGenerator.buildSurfaceAndBedrock(genRegion, protoChunk); -+ // copy over generated sections -+ data.setRawChunkData(protoChunk.getSections()); -+ // hooray! -+ return data; -+ } -+ // Paper end -+ - @Override - public BossBar createBossBar(String title, BarColor color, BarStyle style, BarFlag... flags) { - return new CraftBossBar(title, color, style, flags); -diff --git a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java -+++ b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java -@@ -0,0 +0,0 @@ import org.bukkit.material.MaterialData; - public final class OldCraftChunkData implements ChunkGenerator.ChunkData { - private final int minHeight; - private final int maxHeight; -- private final LevelChunkSection[] sections; -+ private LevelChunkSection[] sections; - private Set tiles; - private final Set lights = new HashSet<>(); - private World world; // Paper - Anti-Xray - Add parameters -@@ -0,0 +0,0 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData { - Set getLights() { - return this.lights; - } -+ -+ // Paper start -+ public void setRawChunkData(LevelChunkSection[] sections) { -+ this.sections = sections; -+ } -+ // Paper end - } diff --git a/patches/unapplied/server/Remove-some-streams-from-structures.patch b/patches/unapplied/server/Remove-some-streams-from-structures.patch deleted file mode 100644 index d4a2892990..0000000000 --- a/patches/unapplied/server/Remove-some-streams-from-structures.patch +++ /dev/null @@ -1,106 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Josh Roy <10731363+JRoy@users.noreply.github.com> -Date: Mon, 29 Jun 2020 17:03:06 -0400 -Subject: [PATCH] Remove some streams from structures - -This showed up a lot in the spark profiler, should have a low-medium performance improvement. - -diff --git a/src/main/java/net/minecraft/world/level/StructureFeatureManager.java b/src/main/java/net/minecraft/world/level/StructureFeatureManager.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/StructureFeatureManager.java -+++ b/src/main/java/net/minecraft/world/level/StructureFeatureManager.java -@@ -0,0 +0,0 @@ public class StructureFeatureManager { - }); - } - -+ // Paper start - remove structure streams - based on method above -+ public java.util.List> streamlessStartsForFeature(SectionPos sectionPosition, StructureFeature structureGenerator) { -+ java.util.List> list = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(); -+ for (Long curLong : this.level.getChunk(sectionPosition.x(), sectionPosition.z(), ChunkStatus.STRUCTURE_REFERENCES).getReferencesForFeature(structureGenerator)) { -+ SectionPos sectionPosition1 = SectionPos.of(new ChunkPos(curLong), 0); -+ StructureStart structurestart = getStartForFeature(sectionPosition1, structureGenerator, this.level.getChunk(sectionPosition1.x(), sectionPosition1.z(), ChunkStatus.STRUCTURE_STARTS)); -+ if (structurestart != null && structurestart.isValid()) { -+ list.add(structurestart); -+ } -+ } -+ return list; -+ } -+ // Paper end -+ - @Nullable - public StructureStart getStartForFeature(SectionPos pos, StructureFeature feature, FeatureAccess holder) { - return holder.getStartForFeature(feature); -@@ -0,0 +0,0 @@ public class StructureFeatureManager { - } - - public StructureStart getStructureAt(BlockPos pos, boolean matchChildren, StructureFeature feature) { -- return (StructureStart) DataFixUtils.orElse(this.startsForFeature(SectionPos.of(pos), feature).filter((structurestart) -> { -- return matchChildren ? structurestart.getPieces().stream().anyMatch((structurepiece) -> { -- return structurepiece.getBoundingBox().isInside((Vec3i) pos); -- }) : structurestart.getBoundingBox().isInside((Vec3i) pos); -- }).findFirst(), StructureStart.INVALID_START); -+ // Paper start - remove structure streams -+ for (StructureStart structureStart : streamlessStartsForFeature(SectionPos.of(pos), feature)) { -+ if (matchChildren) { -+ for (net.minecraft.world.level.levelgen.structure.StructurePiece piece : structureStart.getPieces()) { -+ if (piece.getBoundingBox().isInside(pos)) { -+ return structureStart; -+ } -+ } -+ } else if (structureStart.getBoundingBox().isInside(pos)) { -+ return structureStart; -+ } -+ } -+ return StructureStart.INVALID_START; -+ // Paper end - } - - // Spigot start -diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/biome/Biome.java -+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java -@@ -0,0 +0,0 @@ import net.minecraft.world.level.levelgen.WorldgenRandom; - import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; - import net.minecraft.world.level.levelgen.feature.StructureFeature; - import net.minecraft.world.level.levelgen.structure.BoundingBox; -+import net.minecraft.world.level.levelgen.structure.StructureStart; - import net.minecraft.world.level.levelgen.surfacebuilders.ConfiguredSurfaceBuilder; - import net.minecraft.world.level.levelgen.synth.PerlinSimplexNoise; - import net.minecraft.world.level.material.FluidState; -@@ -0,0 +0,0 @@ public final class Biome { - int p = region.getMinBuildHeight() + 1; - int q = region.getMaxBuildHeight() - 1; - region.setCurrentlyGenerating(supplier); -- structureAccessor.startsForFeature(SectionPos.of(origin), structureFeature).forEach((structureStart) -> { -+ // Paper start - remove structure streams -+ for (StructureStart structureStart : structureAccessor.streamlessStartsForFeature(SectionPos.of(origin), structureFeature)) { - structureStart.placeInChunk(region, structureAccessor, chunkGenerator, random, new BoundingBox(n, p, o, n + 15, q, o + 15), new ChunkPos(l, m)); -- }); -+ } -+ // Paper end - } catch (Exception var24) { - CrashReport crashReport = CrashReport.forThrowable(var24, "Feature placement"); - crashReport.addCategory("Feature").setDetail("Description", supplier::get); -diff --git a/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java b/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/Beardifier.java -@@ -0,0 +0,0 @@ public class Beardifier { - this.rigids = new ObjectArrayList<>(10); - - for(StructureFeature structureFeature : StructureFeature.NOISE_AFFECTING_FEATURES) { -- accessor.startsForFeature(SectionPos.bottomOf(chunk), structureFeature).forEach((start) -> { -+ for (net.minecraft.world.level.levelgen.structure.StructureStart start : accessor.streamlessStartsForFeature(SectionPos.of(chunkPos, 0), structureFeature)) { // Paper - remove structure streams - for(StructurePiece structurePiece : start.getPieces()) { - if (structurePiece.isCloseToChunk(chunkPos, 12)) { - if (structurePiece instanceof PoolElementStructurePiece) { -@@ -0,0 +0,0 @@ public class Beardifier { - } - } - -- }); -+ } // Paper - remove structure streams - } - - this.pieceIterator = this.rigids.iterator();