mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-21 10:06:18 +01:00
Item DataComponent API (#10845)
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: Bjarne Koll <git@lynxplay.dev>
This commit is contained in:
parent
6735c60738
commit
de6173b061
4186
patches/api/0495-DataComponent-API.patch
Normal file
4186
patches/api/0495-DataComponent-API.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -4691,16 +4691,21 @@ index 0000000000000000000000000000000000000000..197224e31175252d8438a8df585bbb65
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..422bc104e5bdd4ae786b14d97eb779dc76bfad69
|
||||
index 0000000000000000000000000000000000000000..e85e544506b4c762503a1cb490e6c0f5b1d563f4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
@@ -0,0 +1,190 @@
|
||||
@@ -0,0 +1,220 @@
|
||||
+package io.papermc.paper.util;
|
||||
+
|
||||
+import com.google.common.collect.Collections2;
|
||||
+import com.google.common.collect.Lists;
|
||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import io.papermc.paper.math.BlockPosition;
|
||||
+import io.papermc.paper.math.FinePosition;
|
||||
+import io.papermc.paper.math.Position;
|
||||
+import java.util.Collection;
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+import java.util.concurrent.CompletableFuture;
|
||||
+import java.util.concurrent.ExecutionException;
|
||||
@ -4709,11 +4714,17 @@ index 0000000000000000000000000000000000000000..422bc104e5bdd4ae786b14d97eb779dc
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+import java.util.function.BiConsumer;
|
||||
+import java.util.function.Consumer;
|
||||
+import java.util.function.Function;
|
||||
+import java.util.function.Supplier;
|
||||
+import net.kyori.adventure.key.Key;
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+import net.minecraft.core.Holder;
|
||||
+import net.minecraft.core.Vec3i;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.sounds.SoundEvent;
|
||||
+import net.minecraft.world.level.ChunkPos;
|
||||
+import net.minecraft.world.level.Level;
|
||||
+import net.minecraft.world.phys.Vec3;
|
||||
@ -4884,6 +4895,25 @@ index 0000000000000000000000000000000000000000..422bc104e5bdd4ae786b14d97eb779dc
|
||||
+ public static NamespacedKey fromResourceKey(final ResourceKey<?> key) {
|
||||
+ return CraftNamespacedKey.fromMinecraft(key.location());
|
||||
+ }
|
||||
+
|
||||
+ public static Holder<SoundEvent> keyToSound(Key key) {
|
||||
+ ResourceLocation soundId = PaperAdventure.asVanilla(key);
|
||||
+ return BuiltInRegistries.SOUND_EVENT.wrapAsHolder(BuiltInRegistries.SOUND_EVENT.getOptional(soundId).orElse(SoundEvent.createVariableRangeEvent(soundId)));
|
||||
+ }
|
||||
+
|
||||
+ public static <A, M> List<A> transformUnmodifiable(final List<? extends M> nms, final Function<? super M, ? extends A> converter) {
|
||||
+ return Collections.unmodifiableList(Lists.transform(nms, converter::apply));
|
||||
+ }
|
||||
+
|
||||
+ public static <A, M> Collection<A> transformUnmodifiable(final Collection<? extends M> nms, final Function<? super M, ? extends A> converter) {
|
||||
+ return Collections.unmodifiableCollection(Collections2.transform(nms, converter::apply));
|
||||
+ }
|
||||
+
|
||||
+ public static <A, M, C extends Collection<M>> void addAndConvert(final C target, final Collection<A> toAdd, final Function<? super A, ? extends M> converter) {
|
||||
+ for (final A value : toAdd) {
|
||||
+ target.add(converter.apply(value));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/util/StackWalkerUtil.java b/src/main/java/io/papermc/paper/util/StackWalkerUtil.java
|
||||
new file mode 100644
|
||||
@ -6309,6 +6339,28 @@ index f6e6f0ddef6693c58f28b89cf3df005a8d47e08d..101eea3452c9e387e770b716543c3a4f
|
||||
public static net.minecraft.world.item.ItemStack asNMSCopy(ItemStack original) {
|
||||
if (original instanceof CraftItemStack) {
|
||||
CraftItemStack stack = (CraftItemStack) original;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftLocation.java b/src/main/java/org/bukkit/craftbukkit/util/CraftLocation.java
|
||||
index 097996d3955ab5126b71f7bff1dd2c62becb5ffd..a8b46ea5e4b6260c2728c67e8651b74fe6356605 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftLocation.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftLocation.java
|
||||
@@ -40,6 +40,17 @@ public final class CraftLocation {
|
||||
return new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public static net.minecraft.core.GlobalPos toGlobalPos(Location location) {
|
||||
+ return net.minecraft.core.GlobalPos.of(((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle().dimension(), toBlockPosition(location));
|
||||
+ }
|
||||
+
|
||||
+ public static Location fromGlobalPos(net.minecraft.core.GlobalPos globalPos) {
|
||||
+ BlockPos pos = globalPos.pos();
|
||||
+ return new org.bukkit.Location(net.minecraft.server.MinecraftServer.getServer().getLevel(globalPos.dimension()).getWorld(), pos.getX(), pos.getY(), pos.getZ());
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public static Vec3 toVec3D(Location location) {
|
||||
return new Vec3(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java
|
||||
index b8a865305cc61954aeebff4a7cd1d1973c5f46ab..e444662ee4d9405eeea7caa41b9cd6b36586d840 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java
|
||||
|
@ -1161,10 +1161,10 @@ index 0000000000000000000000000000000000000000..2fd6c3e65354071af71c7d8ebb97b559
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/adventure/PaperAdventure.java b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..161bc8c577643094d824ea96fb6974c76e5e77f0
|
||||
index 0000000000000000000000000000000000000000..610003a668c4a7fe53e3477accc6bafb8479b936
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/adventure/PaperAdventure.java
|
||||
@@ -0,0 +1,479 @@
|
||||
@@ -0,0 +1,483 @@
|
||||
+package io.papermc.paper.adventure;
|
||||
+
|
||||
+import com.mojang.brigadier.StringReader;
|
||||
@ -1314,6 +1314,10 @@ index 0000000000000000000000000000000000000000..161bc8c577643094d824ea96fb6974c7
|
||||
+
|
||||
+ // Key
|
||||
+
|
||||
+ public static Key asAdventure(final ResourceLocation key) {
|
||||
+ return Key.key(key.getNamespace(), key.getPath());
|
||||
+ }
|
||||
+
|
||||
+ public static ResourceLocation asVanilla(final Key key) {
|
||||
+ return ResourceLocation.fromNamespaceAndPath(key.namespace(), key.value());
|
||||
+ }
|
||||
@ -2704,7 +2708,7 @@ index 709330ca9caa82a6de71767b3d5c32f97ea1d68b..daf20aa9a83a2583c0c61a4123cc2e52
|
||||
|
||||
public boolean logIPs() {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 32e7c6e6f09e53fe8b5ade22dad8142cd09e0163..4303bde198050cd037f006234d269af406606eff 100644
|
||||
index 785c7e11f92610be58b624d252d1858658496af7..99607edee9fba8df87f0525bf0eadee865ab38a4 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -190,6 +190,7 @@ import net.minecraft.world.item.trading.MerchantOffers;
|
||||
@ -3639,7 +3643,7 @@ index 8b58884d6cb1088a2fffb36a99bfe4dc568326d1..9a79b948264150d0f7a843a8ddd2ea92
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index 94004204b6cdbbbf35263faae56e3e06cb6b650c..2e33acc428dbfd3e123dfd6ef90bc020b8a08daf 100644
|
||||
index 39126769594a535ebd4bf7052f42e9eda9d3e10a..41ceea1093edbf777f9ebe252114be7f75438420 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -20,6 +20,12 @@ public class Main {
|
||||
@ -5202,7 +5206,7 @@ index c71a4971f127fdfc753306019313ce1a31201120..fd3b12477c30d1eabdbe57ea77902793
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index 5dea83c1a0de4e5123430bf2f902a78969021167..2e524520308dda7ce7df98d91c89a9cfe7542862 100644
|
||||
index 2d68086ef09b5f2d6b3d3e6200e621c23747b25a..f3789ea732b17a311d8203a58a97d11370ec7863 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -1097,6 +1097,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
|
4804
patches/server/1036-DataComponent-API.patch
Normal file
4804
patches/server/1036-DataComponent-API.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@ Subject: [PATCH] API for checking sent chunks
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 73ee1ba0b70859cc9c012ab32ad04e8ae2a73e30..92fb2f976ae1c36b152733c28f223337e7f8632e 100644
|
||||
index 4f1b3b38d1eec331ab67307eb0e9e62621ce3cd5..d0010dfd22463986bf3be9b3ee015ce92735753e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -3498,6 +3498,35 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
@ -5,7 +5,7 @@ Subject: [PATCH] Bundle spark
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 3288d59c9635819aef0bd864c64cb80e339c050f..f5104c3232b4ad1bc486490d17a8877d603c7d8d 100644
|
||||
index 9e6c2a4630ce75e4115f76b5e7a1e0b50e8b3197..ee5f662ed0e84be997807a9faf97191ef4fc0449 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -76,6 +76,10 @@ dependencies {
|
@ -86,7 +86,7 @@ index 7b936a01888d71fe305863054471b6b4a3aa95b8..c09c718c1b1c9f27fdf1e4160b2df688
|
||||
// Paper start - add close param
|
||||
this.save(progressListener, flush, savingDisabled, false);
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 8ceeebb561046933cba0725e15732fa074226884..8c9148426f23cbbdfaf7ae66657d1a620f8bd853 100644
|
||||
index dda53c52fab7c02f39451335fe0bfe36852ac994..167ab6346edb8f29c29a7327f031c0f5df71acf1 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -221,6 +221,7 @@ import org.bukkit.inventory.MainHand;
|
@ -65,7 +65,7 @@ index 504c996220b278c194c93e001a3b326d549868ec..a96f859a5d0c6ec692d4627a69f3c9ee
|
||||
|
||||
if (this.hasDelayedDestroy) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 4836b01323abb125289982ef3ceca09d6a9cfc3b..e86314de8d908a0c3e9f17d3e163c11180cf3f59 100644
|
||||
index 59c992173fda6153c58722caae061b0e6bee86a1..6a3a8f0466998409a01223bc0c16d92b96e50118 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -4051,6 +4051,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@ -60,7 +60,7 @@ index b1ecc218034944533967375d11297705c3fc01a3..aaaadb7be8abf867624a1ca83371595b
|
||||
spawnercreature_d = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, null, true);
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 8cc02ee9b1a710e35eb65a5a095681cc7dc542bb..4e4e5b7e8c387cf13cf5bc5e39d334c3222c9103 100644
|
||||
index f28babf8c778ef570d35e1aaa88467160cf3f1b1..b525369fb6f3bb80c1553ae41b1e3bddeda29936 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -307,6 +307,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
@ -72,7 +72,7 @@ index 8cc02ee9b1a710e35eb65a5a095681cc7dc542bb..4e4e5b7e8c387cf13cf5bc5e39d334c3
|
||||
// CraftBukkit start
|
||||
public CraftPlayer.TransferCookieConnection transferCookieConnection;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
index 0beb5ab48c5405d9bc2ad8d0c430312f456d38c2..5297798c2be1ba85569c2b92ed221956bf75477a 100644
|
||||
index 12ebd7829c7f6814ccd79ae96aa9023afcc64696..c1b76a1ebc1eea7ab70cf61d8175a31794dd122a 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
@@ -299,6 +299,11 @@ public final class NaturalSpawner {
|
@ -11,7 +11,7 @@ sleep by default, which avoids the problem and makes it more obvious to check if
|
||||
enabled. We also unload chunks during sleep to prevent memory leaks caused by plugin chunk loads.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 9dfa6bb83469620a446509656ea1ad140b2e683f..af8dbfcc9df105896c8574d2d9dd647ac30ae04d 100644
|
||||
index e636a96ea6220fda671a31d3d9cdea468a558768..64b56abf8900d0424100da460fc68ac964394793 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1638,6 +1638,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@ -32,7 +32,7 @@ index 9dfa6bb83469620a446509656ea1ad140b2e683f..af8dbfcc9df105896c8574d2d9dd647a
|
||||
this.tickConnection();
|
||||
this.server.spark.tickEnd(((double)(System.nanoTime() - lastTick) / 1000000D)); // Paper - spark
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
index 52e61f75f922a075ccc745198f4ba6ad8fa58ea2..149a542c4afa09d491cb33ae33563ba15786758d 100644
|
||||
index a2633780619d73c29a23cb8b6a208ca9ba549fb0..c3ec370b83b895be0f03662e3884fa4a2442a2a6 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
@@ -160,7 +160,7 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
@ -9,7 +9,7 @@ When enabled, ender pearls will not load chunks and will save to the world inste
|
||||
public net.minecraft.world.entity.projectile.Projectile cachedOwner
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 4e4e5b7e8c387cf13cf5bc5e39d334c3222c9103..cffbd3300967e5d80b5973b35a76235bb2aa1b73 100644
|
||||
index b525369fb6f3bb80c1553ae41b1e3bddeda29936..2e8ecf3bbb9f9ceba6f896738fa1ab8e2bd0fed6 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -836,6 +836,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
@ -30,7 +30,7 @@ index 4e4e5b7e8c387cf13cf5bc5e39d334c3222c9103..cffbd3300967e5d80b5973b35a76235b
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index cf42042c754b30e41c0ec8a6a15195369bdbd199..1fcd9cd9344b0d2c4752042b07142db7d727dce8 100644
|
||||
index a03ff473a683611670ee274b0eec5a395ee6981a..30de3d1a7792c38ae946f19cb0e14637919b5001 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -602,7 +602,13 @@ public abstract class PlayerList {
|
Loading…
Reference in New Issue
Block a user