diff --git a/patches/api/Add-new-overload-to-PersistentDataContainer-has.patch b/patches/api/Add-new-overload-to-PersistentDataContainer-has.patch deleted file mode 100644 index 12f2296985..0000000000 --- a/patches/api/Add-new-overload-to-PersistentDataContainer-has.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: u9g -Date: Mon, 3 Jan 2022 23:27:21 -0500 -Subject: [PATCH] Add new overload to PersistentDataContainer#has - -Adds the new overload: PersistentDataContainer#has(NamespacedKey key) - -diff --git a/src/main/java/org/bukkit/persistence/PersistentDataContainer.java b/src/main/java/org/bukkit/persistence/PersistentDataContainer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/persistence/PersistentDataContainer.java -+++ b/src/main/java/org/bukkit/persistence/PersistentDataContainer.java -@@ -0,0 +0,0 @@ public interface PersistentDataContainer { - */ - @NotNull - PersistentDataAdapterContext getAdapterContext(); -+ -+ // Paper start -+ /** -+ * Returns if the persistent metadata provider has metadata registered -+ * matching the provided key. -+ * -+ * @param key the key for which existence should be checked. -+ * -+ * @return whether the key exists -+ * -+ * @throws NullPointerException if the key to look up is null -+ */ -+ boolean has(@NotNull NamespacedKey key); -+ // Paper end - } diff --git a/patches/api/Added-byte-array-serialization-deserialization-for-P.patch b/patches/api/Added-byte-array-serialization-deserialization-for-P.patch index e0c2af1974..648329c15b 100644 --- a/patches/api/Added-byte-array-serialization-deserialization-for-P.patch +++ b/patches/api/Added-byte-array-serialization-deserialization-for-P.patch @@ -10,10 +10,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/persistence/PersistentDataContainer.java +++ b/src/main/java/org/bukkit/persistence/PersistentDataContainer.java @@ -0,0 +0,0 @@ public interface PersistentDataContainer { - * @throws NullPointerException if the key to look up is null */ - boolean has(@NotNull NamespacedKey key); + @NotNull + PersistentDataAdapterContext getAdapterContext(); + ++ // Paper start - byte array serialization + /** + * Serialize this {@link PersistentDataContainer} instance to a + * byte array. @@ -43,8 +44,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param bytes the byte array to read from + * @throws java.io.IOException if the byte array has an invalid format + */ -+ default void readFromBytes(byte @NotNull [] bytes) throws java.io.IOException { ++ default void readFromBytes(final byte @NotNull [] bytes) throws java.io.IOException { + this.readFromBytes(bytes, true); + } - // Paper end ++ // Paper end - byte array serialization } diff --git a/patches/api/Keyed-Cat-Type.patch b/patches/api/Keyed-Cat-Type.patch deleted file mode 100644 index 205af26ad7..0000000000 --- a/patches/api/Keyed-Cat-Type.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> -Date: Wed, 8 Jun 2022 18:23:17 -0400 -Subject: [PATCH] Keyed Cat Type - - -diff --git a/src/main/java/org/bukkit/entity/Cat.java b/src/main/java/org/bukkit/entity/Cat.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/entity/Cat.java -+++ b/src/main/java/org/bukkit/entity/Cat.java -@@ -0,0 +0,0 @@ public interface Cat extends Tameable, Sittable, io.papermc.paper.entity.CollarC - /** - * Represents the various different cat types there are. - */ -- public enum Type { -+ public enum Type implements org.bukkit.Keyed { // Paper - TABBY, - BLACK, - RED, -@@ -0,0 +0,0 @@ public interface Cat extends Tameable, Sittable, io.papermc.paper.entity.CollarC - WHITE, - JELLIE, - ALL_BLACK; -+ -+ // Paper start -+ private final org.bukkit.NamespacedKey key; -+ -+ Type() { -+ this.key = org.bukkit.NamespacedKey.minecraft(name().toLowerCase(java.util.Locale.ROOT)); -+ } -+ -+ @NotNull -+ @Override -+ public org.bukkit.NamespacedKey getKey() { -+ return key; -+ } -+ // Paper end - } - - // Paper Start - More cat api diff --git a/patches/api/Missing-Entity-API.patch b/patches/api/Missing-Entity-API.patch index 6765204415..a117cee3bd 100644 --- a/patches/api/Missing-Entity-API.patch +++ b/patches/api/Missing-Entity-API.patch @@ -327,8 +327,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/entity/Cat.java +++ b/src/main/java/org/bukkit/entity/Cat.java @@ -0,0 +0,0 @@ public interface Cat extends Tameable, Sittable { - JELLIE, - ALL_BLACK; + return key; + } } + + // Paper Start - More cat api diff --git a/patches/server/Add-new-overload-to-PersistentDataContainer-has.patch b/patches/server/Add-missing-IAE-check-for-PersistentDataContainer-ha.patch similarity index 66% rename from patches/server/Add-new-overload-to-PersistentDataContainer-has.patch rename to patches/server/Add-missing-IAE-check-for-PersistentDataContainer-ha.patch index 7721b27e0e..2debdb5166 100644 --- a/patches/server/Add-new-overload-to-PersistentDataContainer-has.patch +++ b/patches/server/Add-missing-IAE-check-for-PersistentDataContainer-ha.patch @@ -1,24 +1,18 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: u9g Date: Mon, 3 Jan 2022 23:32:42 -0500 -Subject: [PATCH] Add new overload to PersistentDataContainer#has +Subject: [PATCH] Add missing IAE check for PersistentDataContainer#has -Adds the new overload: PersistentDataContainer#has(NamespacedKey key) diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java @@ -0,0 +0,0 @@ public class CraftPersistentDataContainer implements PersistentDataContainer { - public void clear() { - this.customDataTags.clear(); + + @Override + public boolean has(NamespacedKey key) { ++ Preconditions.checkArgument(key != null, "The provided key for the custom value was null"); // Paper + return this.customDataTags.get(key.toString()) != null; } -+ -+ @Override -+ public boolean has(NamespacedKey key) { -+ Preconditions.checkArgument(key != null, "The provided key for the custom value was null"); -+ -+ return this.customDataTags.containsKey(key.toString()); -+ } - // Paper end - } + diff --git a/patches/server/Added-byte-array-serialization-deserialization-for-P.patch b/patches/server/Added-byte-array-serialization-deserialization-for-P.patch index 7629d24ac6..00f6596ea9 100644 --- a/patches/server/Added-byte-array-serialization-deserialization-for-P.patch +++ b/patches/server/Added-byte-array-serialization-deserialization-for-P.patch @@ -10,29 +10,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java @@ -0,0 +0,0 @@ public class CraftPersistentDataContainer implements PersistentDataContainer { - - return this.customDataTags.containsKey(key.toString()); + this.customDataTags.clear(); } + // Paper end + ++ // Paper start - byte array serialization + @Override + public byte[] serializeToBytes() throws java.io.IOException { -+ net.minecraft.nbt.CompoundTag root = this.toTagCompound(); -+ java.io.ByteArrayOutputStream byteArrayOutput = new java.io.ByteArrayOutputStream(); -+ try (java.io.DataOutputStream dataOutput = new java.io.DataOutputStream(byteArrayOutput)) { ++ final net.minecraft.nbt.CompoundTag root = this.toTagCompound(); ++ final java.io.ByteArrayOutputStream byteArrayOutput = new java.io.ByteArrayOutputStream(); ++ try (final java.io.DataOutputStream dataOutput = new java.io.DataOutputStream(byteArrayOutput)) { + net.minecraft.nbt.NbtIo.write(root, dataOutput); + return byteArrayOutput.toByteArray(); + } + } + + @Override -+ public void readFromBytes(byte[] bytes, boolean clear) throws java.io.IOException { ++ public void readFromBytes(final byte[] bytes, final boolean clear) throws java.io.IOException { + if (clear) { + this.clear(); + } -+ try (java.io.DataInputStream dataInput = new java.io.DataInputStream(new java.io.ByteArrayInputStream(bytes))) { -+ net.minecraft.nbt.CompoundTag compound = net.minecraft.nbt.NbtIo.read(dataInput); ++ try (final java.io.DataInputStream dataInput = new java.io.DataInputStream(new java.io.ByteArrayInputStream(bytes))) { ++ final net.minecraft.nbt.CompoundTag compound = net.minecraft.nbt.NbtIo.read(dataInput); + this.putAll(compound); + } + } - // Paper end ++ // Paper end - byte array serialization } diff --git a/patches/server/Deep-clone-unhandled-nbt-tags.patch b/patches/server/Deep-clone-unhandled-nbt-tags.patch index eb0169ed6f..cfe289872f 100644 --- a/patches/server/Deep-clone-unhandled-nbt-tags.patch +++ b/patches/server/Deep-clone-unhandled-nbt-tags.patch @@ -48,14 +48,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java @@ -0,0 +0,0 @@ public class CraftPersistentDataContainer implements PersistentDataContainer { - this.putAll(compound); } } + // Paper end - byte array serialization + ++ // Paper start - deep clone tags + public Map getTagsCloned() { + final Map tags = new HashMap<>(); + this.customDataTags.forEach((key, tag) -> tags.put(key, tag.copy())); + return tags; + } - // Paper end ++ // Paper end - deep clone tags } diff --git a/patches/server/Fix-missing-map-initialize-event-call.patch b/patches/server/Fix-missing-map-initialize-event-call.patch index df6edad405..d7b54db21d 100644 --- a/patches/server/Fix-missing-map-initialize-event-call.patch +++ b/patches/server/Fix-missing-map-initialize-event-call.patch @@ -3,6 +3,8 @@ From: Warrior <50800980+Warriorrrr@users.noreply.github.com> Date: Sun, 24 Sep 2023 18:35:28 +0200 Subject: [PATCH] Fix missing map initialize event call +== AT == +public net.minecraft.world.level.storage.DimensionDataStorage readSavedData(Ljava/util/function/Function;Lnet/minecraft/util/datafix/DataFixTypes;Ljava/lang/String;)Lnet/minecraft/world/level/saveddata/SavedData; 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 @@ -12,7 +14,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Nullable @Override public MapItemSavedData getMapData(String id) { -- return (MapItemSavedData) this.getServer().overworld().getDataStorage().get(MapItemSavedData.factory(), id); +- // CraftBukkit start +- MapItemSavedData worldmap = (MapItemSavedData) this.getServer().overworld().getDataStorage().get(MapItemSavedData.factory(), id); +- if (worldmap != null) { +- worldmap.id = id; + // Paper start - Call missing map initialize event & set id + final DimensionDataStorage storage = this.getServer().overworld().getDataStorage(); + @@ -26,23 +31,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + new MapInitializeEvent(map.mapView).callEvent(); + return map; + } -+ } ++ } else if (existing instanceof MapItemSavedData mapItemSavedData) { ++ mapItemSavedData.id = id; + } +- return worldmap; +- // CraftBukkit end + + return existing instanceof MapItemSavedData data ? data : null; + // Paper end } @Override -diff --git a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java -+++ b/src/main/java/net/minecraft/world/level/storage/DimensionDataStorage.java -@@ -0,0 +0,0 @@ public class DimensionDataStorage { - } - - @Nullable -- private T readSavedData(Function readFunction, DataFixTypes dataFixTypes, String id) { -+ public T readSavedData(Function readFunction, DataFixTypes dataFixTypes, String id) { // Paper - try { - File file = this.getDataFile(id); - if (file.exists()) { diff --git a/patches/server/Implement-EntityTeleportEndGatewayEvent.patch b/patches/server/Implement-EntityTeleportEndGatewayEvent.patch index dca2d5e9cb..4e2cd3b6b6 100644 --- a/patches/server/Implement-EntityTeleportEndGatewayEvent.patch +++ b/patches/server/Implement-EntityTeleportEndGatewayEvent.patch @@ -11,22 +11,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { } - // CraftBukkit end + +- org.bukkit.event.entity.EntityTeleportEvent teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(entity1, blockposition1.getX() + 0.5, blockposition1.getY() + 0.5, blockposition1.getZ() + 0.5); // Paper - diff on change +- if (teleEvent.isCancelled()) { + // Paper start - EntityTeleportEndGatewayEvent + org.bukkit.Location location = new org.bukkit.Location(world.getWorld(), blockposition1.getX() + 0.5D, blockposition1.getY(), blockposition1.getZ() + 0.5D); + location.setPitch(entity1.getXRot()); + location.setYaw(entity1.getBukkitYaw()); -+ + org.bukkit.entity.Entity bukkitEntity = entity1.getBukkitEntity(); -+ com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent event = new com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent(bukkitEntity, bukkitEntity.getLocation(), location, new org.bukkit.craftbukkit.block.CraftEndGateway(world.getWorld(), blockEntity)); -+ if (!event.callEvent()) { -+ return; -+ } -+ // Paper end ++ org.bukkit.event.entity.EntityTeleportEvent teleEvent = new com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent(bukkitEntity, bukkitEntity.getLocation(), location, new org.bukkit.craftbukkit.block.CraftEndGateway(world.getWorld(), blockEntity)); ++ if (!teleEvent.callEvent()) { ++ // Paper end - EntityTeleportEndGatewayEvent + return; + } - entity1.setPortalCooldown(); -- entity1.teleportToWithTicket((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D); // Paper - diff on change -+ entity1.teleportToWithTicket(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); // Paper - } - - TheEndGatewayBlockEntity.triggerCooldown(world, pos, state, blockEntity); diff --git a/patches/server/Missing-Entity-API.patch b/patches/server/Missing-Entity-API.patch index a8af25c679..82d5daa3ab 100644 --- a/patches/server/Missing-Entity-API.patch +++ b/patches/server/Missing-Entity-API.patch @@ -545,7 +545,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -0,0 +0,0 @@ public class CraftCat extends CraftTameableAnimal implements Cat { - .byId(bukkit.ordinal()); + return registry.get(CraftNamespacedKey.toMinecraft(bukkit.getKey())); } } + diff --git a/patches/server/PlayerTeleportEndGatewayEvent.patch b/patches/server/PlayerTeleportEndGatewayEvent.patch index 944faab9ee..f418a5b171 100644 --- a/patches/server/PlayerTeleportEndGatewayEvent.patch +++ b/patches/server/PlayerTeleportEndGatewayEvent.patch @@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java @@ -0,0 +0,0 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { - // CraftBukkit start - Fire PlayerTeleportEvent + // CraftBukkit start - Fire PlayerTeleportEvent/EntityTeleportEvent if (entity1 instanceof ServerPlayer) { org.bukkit.craftbukkit.entity.CraftPlayer player = (CraftPlayer) entity1.getBukkitEntity(); - org.bukkit.Location location = CraftLocation.toBukkit(blockposition1, world.getWorld()).add(0.5D, 0.5D, 0.5D); @@ -25,11 +25,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (teleEvent.isCancelled()) { return; @@ -0,0 +0,0 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { - // CraftBukkit end - entity1.setPortalCooldown(); -- entity1.teleportToWithTicket((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D); -+ entity1.teleportToWithTicket((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D); // Paper - diff on change - } + } - TheEndGatewayBlockEntity.triggerCooldown(world, pos, state, blockEntity); +- org.bukkit.event.entity.EntityTeleportEvent teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(entity1, blockposition1.getX() + 0.5, blockposition1.getY() + 0.5, blockposition1.getZ() + 0.5); ++ org.bukkit.event.entity.EntityTeleportEvent teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(entity1, blockposition1.getX() + 0.5, blockposition1.getY() + 0.5, blockposition1.getZ() + 0.5); // Paper - diff on change + if (teleEvent.isCancelled()) { + return; + } diff --git a/work/Bukkit b/work/Bukkit index cdfe62e472..01bb6ba7d0 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit cdfe62e472085016a8225f356eec9efede9d8b5a +Subproject commit 01bb6ba7d0add97af46db9ae8c2c991912033aa7 diff --git a/work/CraftBukkit b/work/CraftBukkit index 51eea725f7..cb2ea54def 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 51eea725f7b2b683ce04c7d2aeb76705086d78e6 +Subproject commit cb2ea54def89e749d9d1f6a4a7ea029110f03a43