Skip to content

Commit

Permalink
All patches done
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Dec 14, 2024
1 parent ed40c14 commit 0736390
Show file tree
Hide file tree
Showing 57 changed files with 613 additions and 746 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ From: HaHaWTH <[email protected]>
Date: Fri, 14 Jun 2024 17:34:17 -0400
Subject: [PATCH] Fix-MC-183518

Removed since Leaf 1.21.3, Mojang fixed in 1.21.2 24w33a

Related MC issue: https://bugs.mojang.com/browse/MC-183518

diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
Expand Down
24 changes: 8 additions & 16 deletions patches/server/0035-Leaves-Replay-Mod-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ index 414e30430eb7bcb935ef2cc038fcb7c27747bdd4..4129d894d6604f3b2495a35ad2d026c4
@Override
diff --git a/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java b/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java
new file mode 100644
index 0000000000000000000000000000000000000000..1dfbda8b2439e3f21fea953292aa0e3e853b22e0
index 0000000000000000000000000000000000000000..5bd34353b6ea86cd15ff48b8d6570167f35d75f0
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java
@@ -0,0 +1,38 @@
Expand Down Expand Up @@ -518,10 +518,9 @@ index 0000000000000000000000000000000000000000..1dfbda8b2439e3f21fea953292aa0e3e
+ return 0;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/leavesmc/leaves/entity/CraftPhotographer.java b/src/main/java/org/leavesmc/leaves/entity/CraftPhotographer.java
new file mode 100644
index 0000000000000000000000000000000000000000..23c2f699f3ae12d1a36efc7860e869facea9c175
index 0000000000000000000000000000000000000000..fed2005cb711d0d15d5c87e5f0f7939c7a6a8ffa
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/entity/CraftPhotographer.java
@@ -0,0 +1,73 @@
Expand Down Expand Up @@ -598,7 +597,6 @@ index 0000000000000000000000000000000000000000..23c2f699f3ae12d1a36efc7860e869fa
+ return "CraftPhotographer{" + "name=" + getName() + '}';
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/leavesmc/leaves/entity/CraftPhotographerManager.java b/src/main/java/org/leavesmc/leaves/entity/CraftPhotographerManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..e87d1e72902207dbcea67e8300c7375aa9161269
Expand Down Expand Up @@ -689,7 +687,7 @@ index 0000000000000000000000000000000000000000..e87d1e72902207dbcea67e8300c7375a
+}
diff --git a/src/main/java/org/leavesmc/leaves/replay/DigestOutputStream.java b/src/main/java/org/leavesmc/leaves/replay/DigestOutputStream.java
new file mode 100644
index 0000000000000000000000000000000000000000..ffb753377aea3a2c9fd653da8245d5e733fee0cf
index 0000000000000000000000000000000000000000..e67ff063b7f50b4bfdaaaeb88f225eb768d89623
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/replay/DigestOutputStream.java
@@ -0,0 +1,46 @@
Expand Down Expand Up @@ -739,10 +737,9 @@ index 0000000000000000000000000000000000000000..ffb753377aea3a2c9fd653da8245d5e7
+ out.write(b, off, len);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/leavesmc/leaves/replay/RecordMetaData.java b/src/main/java/org/leavesmc/leaves/replay/RecordMetaData.java
new file mode 100644
index 0000000000000000000000000000000000000000..f6b9d5d47dd957d30f725c2daad596226e21af32
index 0000000000000000000000000000000000000000..5a3ea3e1e8df362262e1beaac167d667bd10adfa
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/replay/RecordMetaData.java
@@ -0,0 +1,23 @@
Expand All @@ -769,7 +766,6 @@ index 0000000000000000000000000000000000000000..f6b9d5d47dd957d30f725c2daad59622
+
+ public Set<UUID> players = new HashSet<>();
+}
\ No newline at end of file
diff --git a/src/main/java/org/leavesmc/leaves/replay/Recorder.java b/src/main/java/org/leavesmc/leaves/replay/Recorder.java
new file mode 100644
index 0000000000000000000000000000000000000000..d1fb2f08f2d357c6551de7832eb3cf6980d44fb5
Expand Down Expand Up @@ -1063,7 +1059,7 @@ index 0000000000000000000000000000000000000000..d1fb2f08f2d357c6551de7832eb3cf69
+}
diff --git a/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java b/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java
new file mode 100644
index 0000000000000000000000000000000000000000..7183f7fc3eb4fc12aa90b94661b652f476de396b
index 0000000000000000000000000000000000000000..e1c32a60fa60054b351b0f4267d2e3e20c129e9b
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java
@@ -0,0 +1,57 @@
Expand Down Expand Up @@ -1124,7 +1120,6 @@ index 0000000000000000000000000000000000000000..7183f7fc3eb4fc12aa90b94661b652f4
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/leavesmc/leaves/replay/ReplayFile.java b/src/main/java/org/leavesmc/leaves/replay/ReplayFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..c6bb5431c3fe14935b0f0a871308830e476271d8
Expand Down Expand Up @@ -1331,7 +1326,7 @@ index 0000000000000000000000000000000000000000..c6bb5431c3fe14935b0f0a871308830e
+}
diff --git a/src/main/java/org/leavesmc/leaves/replay/ReplayMarker.java b/src/main/java/org/leavesmc/leaves/replay/ReplayMarker.java
new file mode 100644
index 0000000000000000000000000000000000000000..219b9ea88f8cebaf8aab73b123d3efd586cc3147
index 0000000000000000000000000000000000000000..1568f6928d5d4f38ca1919c6de6ec9bb9deb20b2
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/replay/ReplayMarker.java
@@ -0,0 +1,43 @@
Expand Down Expand Up @@ -1378,7 +1373,6 @@ index 0000000000000000000000000000000000000000..219b9ea88f8cebaf8aab73b123d3efd5
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/leavesmc/leaves/replay/ServerPhotographer.java b/src/main/java/org/leavesmc/leaves/replay/ServerPhotographer.java
new file mode 100644
index 0000000000000000000000000000000000000000..d8f8f071c67cd0e29411d3f0f3b5e931abe86f65
Expand Down Expand Up @@ -1609,7 +1603,7 @@ index 0000000000000000000000000000000000000000..d8f8f071c67cd0e29411d3f0f3b5e931
+}
diff --git a/src/main/java/org/leavesmc/leaves/replay/ServerPhotographerGameMode.java b/src/main/java/org/leavesmc/leaves/replay/ServerPhotographerGameMode.java
new file mode 100644
index 0000000000000000000000000000000000000000..41adf5787bdab11806c76fd379275403c00466a9
index 0000000000000000000000000000000000000000..c612215b0f1e8c3fae641e7a23c7cf7d165eca87
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/replay/ServerPhotographerGameMode.java
@@ -0,0 +1,35 @@
Expand Down Expand Up @@ -1648,10 +1642,9 @@ index 0000000000000000000000000000000000000000..41adf5787bdab11806c76fd379275403
+ public void tick() {
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/leavesmc/leaves/util/UUIDSerializer.java b/src/main/java/org/leavesmc/leaves/util/UUIDSerializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..93f72a99595a0b1f182f3950de36f1282a171e84
index 0000000000000000000000000000000000000000..b0834f4b569b3e28ec7e026b3ff4236219498011
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/util/UUIDSerializer.java
@@ -0,0 +1,17 @@
Expand All @@ -1672,4 +1665,3 @@ index 0000000000000000000000000000000000000000..93f72a99595a0b1f182f3950de36f128
+ return new JsonPrimitive(src.toString());
+ }
+}
\ No newline at end of file
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,10 @@ Replace `thenApply` with `thenCompose`. Once one task is completed then the next
to prevent blocking threads while waiting to complete all tasks. But may cause the sequence of future compose disorder.

diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
index 1360aa8202542d3d0f32247f1123575fc2c38ff1..b177428857e17a0fb9df0031d60e3027d5b996a1 100644
index 1360aa8202542d3d0f32247f1123575fc2c38ff1..8701e64aa7287093f8cac3921e0189f94c62cae9 100644
--- a/src/main/java/net/minecraft/Util.java
+++ b/src/main/java/net/minecraft/Util.java
@@ -40,6 +40,7 @@ import java.time.Duration;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.Iterator;
@@ -586,17 +587,44 @@ public class Util {
@@ -586,17 +586,44 @@ public class Util {
return enumMap;
}

Expand Down Expand Up @@ -48,7 +40,7 @@ index 1360aa8202542d3d0f32247f1123575fc2c38ff1..b177428857e17a0fb9df0031d60e3027
+ private static <V> CompletableFuture<List<V>> sequenceFaster(List<? extends CompletableFuture<V>> futures, CompletableFuture<Void> completableFuture) {
+ return completableFuture.thenCompose(void_ ->
+ CompletableFuture.supplyAsync(() -> {
+ List<V> list = new ArrayList<>();
+ List<V> list = new java.util.ArrayList<>();
+
+ for (CompletableFuture<V> future : futures) {
+ list.add(future.join());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,28 +86,28 @@ index 796322fc35da0b47654e60388ec93cae7b999766..84d95b8e718609d06f5a259f22599494

public Vec3 getPositionBase() {
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
index bd5e034ce58ebe53d2121209d76ae60134ce72fe..739e178b4544964d24e242b088393093348cc15f 100644
index bd5e034ce58ebe53d2121209d76ae60134ce72fe..063a58e7413092918a66dd57a6178f02c78f165a 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
@@ -434,6 +434,16 @@ public class ItemFrame extends HangingEntity {
}
this.setItem(ItemStack.fromBukkitCopy(event.getItemStack()));
// Paper end - Add PlayerItemFrameChangeEvent
+ // Paper start - add decoration and mark everything dirty for other players who are already tracking this frame
+ final ItemStack item = this.getItem();
+ if (item.is(Items.FILLED_MAP)) {
+ final MapItemSavedData data = MapItem.getSavedData(item, this.level());
+ if (data != null) {
+ data.addFrameDecoration(this);
+ data.markAllDirty();
+ }
+ }
+ // Paper end
this.gameEvent(GameEvent.BLOCK_CHANGE, player);
itemstack.consume(1, player);
return InteractionResult.SUCCESS;
@@ -175,6 +175,16 @@ public class ItemFrame extends HangingEntity {
this.setItem(ItemStack.fromBukkitCopy(event.getItemStack()), false);
}
// Paper end - Add PlayerItemFrameChangeEvent
+ // Paper start - add decoration and mark everything dirty for other players who are already tracking this frame
+ final ItemStack item = this.getItem();
+ if (item.is(Items.FILLED_MAP)) {
+ final MapItemSavedData data = MapItem.getSavedData(item, this.level());
+ if (data != null) {
+ data.addFrameDecoration(this);
+ data.markAllDirty();
+ }
+ }
+ // Paper end
this.dropItem(world, source.getEntity(), false);
this.gameEvent(GameEvent.BLOCK_CHANGE, source.getEntity());
this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F);
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
index aabc0b5a3e50aad8c4f902fa41e6bed319599ff3..18ba99619fa5acc5b7148c2e8a4e9b086c6a072c 100644
index aabc0b5a3e50aad8c4f902fa41e6bed319599ff3..8c26a86d4a79b64da790bf6fda1f76a11bc26569 100644
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
@@ -81,6 +81,16 @@ public class MapItemSavedData extends SavedData {
Expand Down Expand Up @@ -140,7 +140,7 @@ index aabc0b5a3e50aad8c4f902fa41e6bed319599ff3..18ba99619fa5acc5b7148c2e8a4e9b08
}

this.setDecorationsDirty();
+ if (type.value().showOnItemFrame() || (mapicon1 != null && mapicon.type().value().showOnItemFrame())) this.dirtyFrameDecorations = true; // Paper
+ if (mapicon.renderOnFrame()) this.dirtyFrameDecorations = true; // Paper
}

}
Expand All @@ -165,32 +165,28 @@ index aabc0b5a3e50aad8c4f902fa41e6bed319599ff3..18ba99619fa5acc5b7148c2e8a4e9b08
Iterator iterator = this.carriedBy.iterator();

while (iterator.hasNext()) {
@@ -561,7 +586,11 @@ public class MapItemSavedData extends SavedData {
public void removedFromFrame(BlockPos pos, int id) {
@@ -562,6 +587,7 @@ public class MapItemSavedData extends SavedData {
this.removeDecoration(MapItemSavedData.getFrameKey(id));
this.frameMarkers.remove(MapFrame.frameId(pos));
+<<<<<<< HEAD
this.setDirty();
+=======
+ this.dirtyFrameDecorations = true; // Paper
+>>>>>>> PaperPR: Rewrite framed map tracker ticking
}

public boolean updateColor(int x, int z, byte color) {
@@ -623,6 +652,93 @@ public class MapItemSavedData extends SavedData {
@@ -623,6 +649,93 @@ public class MapItemSavedData extends SavedData {
return "frame-" + id;
}

+ // Paper start
+ public final @Nullable Packet<?> framedUpdatePacket(MapId mapid, @Nullable Player player) {
+ return createUpdatePacket(mapid, player, false);
+ public final @Nullable Packet<?> framedUpdatePacket(MapId id, @Nullable Player player) {
+ return createUpdatePacket(id, player, false);
+ }
+
+ public final @Nullable Packet<?> fullUpdatePacket(MapId mapid, @Nullable Player player) {
+ return createUpdatePacket(mapid, player, true);
+ public final @Nullable Packet<?> fullUpdatePacket(MapId id, @Nullable Player player) {
+ return createUpdatePacket(id, player, true);
+ }
+
+ public final @Nullable Packet<?> createUpdatePacket(MapId mapid, @Nullable Player player, boolean full) {
+ public final @Nullable Packet<?> createUpdatePacket(MapId id, @Nullable Player player, boolean full) {
+ if (!dirtyColorData && !dirtyFrameDecorations && (player == null || server.getCurrentTick() % 5 != 0) && !full) // Periodically send update packets if a renderer is added
+ return null;
+
Expand Down Expand Up @@ -225,7 +221,7 @@ index aabc0b5a3e50aad8c4f902fa41e6bed319599ff3..18ba99619fa5acc5b7148c2e8a4e9b08
+
+ for (final org.bukkit.map.MapCursor cursor : render.cursors) {
+ if (cursor.isVisible()) {
+ decorations.add(new MapDecoration(CraftMapCursor.CraftType.bukkitToMinecraftHolder(cursor.getType()), cursor.getX(), cursor.getY(), cursor.getDirection(), CraftChatMessage.fromStringOrOptional(cursor.getCaption()))); // Paper - Adventure
+ decorations.add(new MapDecoration(CraftMapCursor.CraftType.bukkitToMinecraftHolder(cursor.getType()), cursor.getX(), cursor.getY(), cursor.getDirection(), Optional.ofNullable(PaperAdventure.asVanilla(cursor.caption())))); // Paper - Adventure
+ }
+ }
+ }
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0068-Faster-Random-Generator.patch
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ index 252aef3ffe0fecd47ebea1ed7df48e14fa873eb9..5b4599927effca11293b367c5bac4541
RandomSource fork();

diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 3665fa73fb0bd788335a8bbbdaa8f5aba0b45d8b..e7423f95187098ab99e05e16f6b76549a0b0a1b9 100644
index 3665fa73fb0bd788335a8bbbdaa8f5aba0b45d8b..4543116afc9a86961377b9e2d20868c9e73c698d 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -184,7 +184,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}

// Paper start - Share random for entities to make them more random
- public static RandomSource SHARED_RANDOM = new RandomRandomSource();
+ public static RandomSource SHARED_RANDOM = org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? org.dreeam.leaf.util.math.random.FasterRandomSource.SHARED_INSTANCE : new RandomRandomSource.RandomRandomSource(); // Leaf - Faster random generator
+ public static RandomSource SHARED_RANDOM = org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? org.dreeam.leaf.util.math.random.FasterRandomSource.SHARED_INSTANCE : new RandomRandomSource(); // Leaf - Faster random generator
// Paper start - replace random
private static final class RandomRandomSource extends ca.spottedleaf.moonrise.common.util.ThreadUnsafeRandom {
public RandomRandomSource() {
Expand Down
8 changes: 4 additions & 4 deletions patches/server/0090-Reduce-worldgen-allocations.patch
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ index 38428ba2c522108f4f9f7986bc3535d1232ac1f8..02f143b41350660486de79e240259245
return blockState;
}
diff --git a/src/main/java/net/minecraft/world/level/levelgen/material/MaterialRuleList.java b/src/main/java/net/minecraft/world/level/levelgen/material/MaterialRuleList.java
index 0e6dfe2635ea5f5e410049b05f94f5083b2f18a4..e19086b3a65d992cf6687222557a34a896e84385 100644
index 0e6dfe2635ea5f5e410049b05f94f5083b2f18a4..75a378bea8fdb03b6864fad49bc38fee83523bd9 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/material/MaterialRuleList.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/material/MaterialRuleList.java
@@ -9,13 +9,16 @@ public record MaterialRuleList(NoiseChunk.BlockStateFiller[] materialRuleList) i
Expand All @@ -81,10 +81,10 @@ index 0e6dfe2635ea5f5e410049b05f94f5083b2f18a4..e19086b3a65d992cf6687222557a34a8
- }
+ // Leaf start - Avoid iterator allocation
+ BlockState blockState = null;
+ int s = this.materialRuleList.size();
+ int length = this.materialRuleList.length;
+
+ for (int i = 0; blockState == null && i < s; i++) {
+ NoiseChunk.BlockStateFiller blockStateFiller = this.materialRuleList.get(i);
+ for (int i = 0; blockState == null && i < length; i++) {
+ NoiseChunk.BlockStateFiller blockStateFiller = this.materialRuleList[i];
+ blockState = blockStateFiller.calculate(pos);
}

Expand Down
Loading

0 comments on commit 0736390

Please sign in to comment.