mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 01bb6ba7 PR-936: Add new PersistentDataContainer methods and clean up docs bc145b90 PR-940: Create registry for banner pattern and cat type CraftBukkit Changes: cb2ea54de SPIGOT-7440, PR-1292: Fire EntityTeleportEvent for end gateways 4fea66e44 PR-1299: Add new PersistentDataContainer methods and clean up docs b483a20db PR-1303: Create registry for banner pattern and cat type 4642dd526 SPIGOT-7535: Fix maps not having an ID and also call MapInitializeEvent in more places
This commit is contained in:
parent
7c36ea0a5c
commit
40d0f2da71
13 changed files with 56 additions and 138 deletions
|
@ -1,30 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: u9g <winworkswow@gmail.com>
|
||||
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
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -1,24 +1,18 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: u9g <winworkswow@gmail.com>
|
||||
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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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<String, Tag> getTagsCloned() {
|
||||
+ final Map<String, Tag> tags = new HashMap<>();
|
||||
+ this.customDataTags.forEach((key, tag) -> tags.put(key, tag.copy()));
|
||||
+ return tags;
|
||||
+ }
|
||||
// Paper end
|
||||
+ // Paper end - deep clone tags
|
||||
}
|
||||
|
|
|
@ -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 extends SavedData> T readSavedData(Function<CompoundTag, T> readFunction, DataFixTypes dataFixTypes, String id) {
|
||||
+ public <T extends SavedData> T readSavedData(Function<CompoundTag, T> readFunction, DataFixTypes dataFixTypes, String id) { // Paper
|
||||
try {
|
||||
File file = this.getDataFile(id);
|
||||
if (file.exists()) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
+
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit cdfe62e472085016a8225f356eec9efede9d8b5a
|
||||
Subproject commit 01bb6ba7d0add97af46db9ae8c2c991912033aa7
|
|
@ -1 +1 @@
|
|||
Subproject commit 51eea725f7b2b683ce04c7d2aeb76705086d78e6
|
||||
Subproject commit cb2ea54def89e749d9d1f6a4a7ea029110f03a43
|
Loading…
Reference in a new issue