Dieser Commit ist enthalten in:
Jason Penilla 2024-04-24 22:16:04 -07:00
Ursprung 25f7c68e6b
Commit 690b1cd321
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0E75A301420E48F8
23 geänderte Dateien mit 74 neuen und 67 gelöschten Zeilen

Datei anzeigen

@ -6125,7 +6125,7 @@ index a3d44867e6243f30640df91a0285ed735a9f1f34..be9fde876cb22296afd01fb5d55be1f1
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 2119fc6f72461199ae8969ab0d9b8fab26d775a8..7653d56ceb687a2784a4030412c1034fb02e0f8c 100644
index 2119fc6f72461199ae8969ab0d9b8fab26d775a8..b12921579cb9ab3cbf5607841cc84f2f843624ea 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -48,9 +48,9 @@ public class ChunkHolder {
@ -6171,12 +6171,12 @@ index 2119fc6f72461199ae8969ab0d9b8fab26d775a8..7653d56ceb687a2784a4030412c1034f
+ public @Nullable ChunkAccess getAvailableChunkNow() {
+ // TODO can we just getStatusFuture(EMPTY)?
+ for (ChunkStatus curr = ChunkStatus.FULL, next = curr.getParent(); curr != next; curr = next, next = next.getParent()) {
+ CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> future = this.getFutureIfPresentUnchecked(curr);
+ Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure> either = future.getNow(null);
+ if (either == null || either.left().isEmpty()) {
+ CompletableFuture<ChunkResult<ChunkAccess>> future = this.getFutureIfPresentUnchecked(curr);
+ ChunkResult<ChunkAccess> either = future.getNow(null);
+ if (either == null || either.isSuccess()) {
+ continue;
+ }
+ return either.left().get();
+ return either.orElseThrow(IllegalStateException::new);
+ }
+ return null;
+ }
@ -6214,11 +6214,11 @@ index 2119fc6f72461199ae8969ab0d9b8fab26d775a8..7653d56ceb687a2784a4030412c1034f
}
+ // Paper start
+ public ChunkStatus getChunkHolderStatus() {
+ public @Nullable ChunkStatus getChunkHolderStatus() {
+ for (ChunkStatus curr = ChunkStatus.FULL, next = curr.getParent(); curr != next; curr = next, next = next.getParent()) {
+ CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> future = this.getFutureIfPresentUnchecked(curr);
+ Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure> either = future.getNow(null);
+ if (either == null || !either.left().isPresent()) {
+ CompletableFuture<ChunkResult<ChunkAccess>> future = this.getFutureIfPresentUnchecked(curr);
+ ChunkResult<ChunkAccess> either = future.getNow(null);
+ if (either == null || !either.isSuccess()) {
+ continue;
+ }
+ return curr;
@ -6291,8 +6291,8 @@ index 2119fc6f72461199ae8969ab0d9b8fab26d775a8..7653d56ceb687a2784a4030412c1034f
this.tickingChunkFuture = chunkStorage.prepareTickingChunk(this);
this.scheduleFullChunkPromotion(chunkStorage, this.tickingChunkFuture, executor, FullChunkStatus.BLOCK_TICKING);
+ // Paper start - cache ticking ready status
+ this.tickingChunkFuture.thenAccept(either -> {
+ either.ifLeft(chunk -> {
+ this.tickingChunkFuture.thenAccept(chunkResult -> {
+ chunkResult.ifSuccess(chunk -> {
+ // note: Here is a very good place to add callbacks to logic waiting on this.
+ ChunkHolder.this.isTickingReady = true;
+ io.papermc.paper.chunk.system.ChunkSystem.onChunkTicking(chunk, this);
@ -6306,7 +6306,7 @@ index 2119fc6f72461199ae8969ab0d9b8fab26d775a8..7653d56ceb687a2784a4030412c1034f
- this.tickingChunkFuture.complete(ChunkHolder.UNLOADED_LEVEL_CHUNK);
+ // Paper start
+ if (this.isTickingReady) {
+ io.papermc.paper.chunk.system.ChunkSystem.onChunkNotTicking(this.tickingChunkFuture.join().left().get(), this); // Paper
+ io.papermc.paper.chunk.system.ChunkSystem.onChunkNotTicking(this.tickingChunkFuture.join().orElseThrow(IllegalStateException::new), this); // Paper
+ }
+ // Paper end
+ this.tickingChunkFuture.complete(ChunkHolder.UNLOADED_LEVEL_CHUNK); this.isTickingReady = false; // Paper - cache chunk ticking stage

Datei anzeigen

@ -652,7 +652,7 @@ index dbde2402fd46b0d06e8efeb90be6fb98d7ae7798..f33e5cf6d456e615050047e924d9b242
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
index c2493c15d8fe4587d6ee2db100cc13303b66b39b..218b2b50aa6ebdf1768da21ad61be888f620565e 100644
index c2493c15d8fe4587d6ee2db100cc13303b66b39b..6a6473ebf03e5b1e502db7e66203783b9980d072 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
@@ -19,6 +19,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
@ -663,7 +663,7 @@ index c2493c15d8fe4587d6ee2db100cc13303b66b39b..218b2b50aa6ebdf1768da21ad61be888
protected RandomizableContainerBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
@@ -45,6 +46,52 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
@@ -45,6 +46,57 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
this.lootTableSeed = lootTableSeed;
}
@ -673,9 +673,14 @@ index c2493c15d8fe4587d6ee2db100cc13303b66b39b..218b2b50aa6ebdf1768da21ad61be888
+ // Copied from super with changes, always check the original method
+ this.lootableData.loadNbt(nbt); // Paper
+ if (nbt.contains("LootTable", 8)) {
+ this.setLootTable(ResourceLocation.tryParse(nbt.getString("LootTable")));
+ try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.lootTable); } catch (IllegalArgumentException ex) { this.lootTable = null; } // Paper - validate
+ this.setLootTableSeed(nbt.getLong("LootTableSeed"));
+ final var loc = new net.minecraft.resources.ResourceLocation(nbt.getString("LootTable"));
+ this.setLootTable(ResourceKey.create(net.minecraft.core.registries.Registries.LOOT_TABLE, loc));
+ try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.lootTable.location()); } catch (IllegalArgumentException ex) { this.lootTable = null; } // Paper - validate
+ if (nbt.contains("LootTableSeed", 4)) {
+ this.setLootTableSeed(nbt.getLong("LootTableSeed"));
+ } else {
+ this.setLootTableSeed(0L);
+ }
+ return false; // Paper - always load the items, table may still remain
+ } else {
+ return false;
@ -694,11 +699,11 @@ index c2493c15d8fe4587d6ee2db100cc13303b66b39b..218b2b50aa6ebdf1768da21ad61be888
+ // Copied from super with changes, always check the original method
+ net.minecraft.world.level.Level level = this.getLevel();
+ BlockPos blockPos = this.getBlockPos();
+ ResourceLocation resourceLocation = this.getLootTable();
+ if (this.lootableData.shouldReplenish(player) && level != null) { // Paper
+ net.minecraft.world.level.storage.loot.LootTable lootTable = level.getServer().getLootData().getLootTable(resourceLocation);
+ ResourceKey<LootTable> resourceKey = this.getLootTable();
+ if (this.lootableData.shouldReplenish(player) && resourceKey != null && level != null && level.getServer() != null) { // Paper
+ net.minecraft.world.level.storage.loot.LootTable lootTable = level.getServer().reloadableRegistries().getLootTable(resourceKey);
+ if (player instanceof net.minecraft.server.level.ServerPlayer) {
+ net.minecraft.advancements.CriteriaTriggers.GENERATE_LOOT.trigger((net.minecraft.server.level.ServerPlayer)player, resourceLocation);
+ net.minecraft.advancements.CriteriaTriggers.GENERATE_LOOT.trigger((net.minecraft.server.level.ServerPlayer)player, resourceKey);
+ }
+
+ this.lootableData.processRefill(player); // Paper

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Add Raw Byte ItemStack Serialization
Serializes using NBT which is safer for server data migrations than bukkits format.
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 9e6e6ba95d5cd6cc5d4ada6ac5637b7b82e6fc97..291a9befb2abf95739fdc93faddb4864eb75853a 100644
index 9e6e6ba95d5cd6cc5d4ada6ac5637b7b82e6fc97..9d81a9893ea556b93127130e575be6c422247049 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -475,6 +475,53 @@ public final class CraftMagicNumbers implements UnsafeValues {
@ -19,7 +19,7 @@ index 9e6e6ba95d5cd6cc5d4ada6ac5637b7b82e6fc97..291a9befb2abf95739fdc93faddb4864
+ Preconditions.checkNotNull(item, "null cannot be serialized");
+ Preconditions.checkArgument(item.getType() != Material.AIR, "air cannot be serialized");
+
+ return serializeNbtToBytes((item instanceof CraftItemStack ? ((CraftItemStack) item).handle : CraftItemStack.asNMSCopy(item)).save(new CompoundTag()));
+ return serializeNbtToBytes((net.minecraft.nbt.CompoundTag) (item instanceof CraftItemStack ? ((CraftItemStack) item).handle : CraftItemStack.asNMSCopy(item)).save(MinecraftServer.getServer().registryAccess()));
+ }
+
+ @Override
@ -27,10 +27,10 @@ index 9e6e6ba95d5cd6cc5d4ada6ac5637b7b82e6fc97..291a9befb2abf95739fdc93faddb4864
+ Preconditions.checkNotNull(data, "null cannot be deserialized");
+ Preconditions.checkArgument(data.length > 0, "cannot deserialize nothing");
+
+ CompoundTag compound = deserializeNbtFromBytes(data);
+ net.minecraft.nbt.CompoundTag compound = deserializeNbtFromBytes(data);
+ final int dataVersion = compound.getInt("DataVersion");
+ compound = (CompoundTag) MinecraftServer.getServer().fixerUpper.update(References.ITEM_STACK, new Dynamic<>(NbtOps.INSTANCE, compound), dataVersion, this.getDataVersion()).getValue();
+ return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(compound));
+ compound = (net.minecraft.nbt.CompoundTag) MinecraftServer.getServer().fixerUpper.update(References.ITEM_STACK, new Dynamic<>(NbtOps.INSTANCE, compound), dataVersion, this.getDataVersion()).getValue();
+ return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.parse(MinecraftServer.getServer().registryAccess(), compound).orElseThrow());
+ }
+
+ private byte[] serializeNbtToBytes(CompoundTag compound) {
@ -47,8 +47,8 @@ index 9e6e6ba95d5cd6cc5d4ada6ac5637b7b82e6fc97..291a9befb2abf95739fdc93faddb4864
+ return outputStream.toByteArray();
+ }
+
+ private CompoundTag deserializeNbtFromBytes(byte[] data) {
+ CompoundTag compound;
+ private net.minecraft.nbt.CompoundTag deserializeNbtFromBytes(byte[] data) {
+ net.minecraft.nbt.CompoundTag compound;
+ try {
+ compound = net.minecraft.nbt.NbtIo.readCompressed(
+ new java.io.ByteArrayInputStream(data), net.minecraft.nbt.NbtAccounter.unlimitedHeap()

Datei anzeigen

@ -21,7 +21,7 @@ index c8e4e37b706bd8cb9698ac2d13d0d8668e2d1d14..909575a02bf5f7040eb9c8edb034e7b6
+ // Paper end - Expose entity id counter
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 291a9befb2abf95739fdc93faddb4864eb75853a..274747142472119677fa825b174e02aae0bf68eb 100644
index 9d81a9893ea556b93127130e575be6c422247049..afd99d6a1c0face439cea5cf3e9646fe7139e77f 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -522,6 +522,11 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -15,7 +15,7 @@ manually reload the advancement data for all players, which
normally takes place as a part of the datapack reloading.
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 274747142472119677fa825b174e02aae0bf68eb..c0878cf9948774986996127e250004f0f21d6b31 100644
index afd99d6a1c0face439cea5cf3e9646fe7139e77f..75d78e99a9191547d95c340c34876398b694bee3 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -333,7 +333,13 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -39,7 +39,7 @@ index ce108f1cea8027aa7aab444689f7a29f2e54cc20..7b311f60ceae9942eeee0d2c7a170278
flag = true;
world.gameEvent((Entity) player, (Holder) GameEvent.SHEAR, pos);
diff --git a/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java b/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
index aa8667f0b14dc8944dd3457b431162e59bf54ada..4f4667cb036e8f5700ce175da5bf94725c64c9a7 100644
index aa8667f0b14dc8944dd3457b431162e59bf54ada..d52abece78866fb4202e54d21be8105261401d9b 100644
--- a/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/PumpkinBlock.java
@@ -40,10 +40,18 @@ public class PumpkinBlock extends Block {
@ -50,7 +50,7 @@ index aa8667f0b14dc8944dd3457b431162e59bf54ada..4f4667cb036e8f5700ce175da5bf9472
+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), new java.util.ArrayList<>());
+ event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.PUMPKIN_SEEDS, 4)));
+ if (!event.callEvent()) {
+ return InteractionResult.PASS;
+ return ItemInteractionResult.PASS;
+ }
+ // Paper end - Add PlayerShearBlockEvent
Direction direction = hit.getDirection();

Datei anzeigen

@ -67,7 +67,7 @@ index 99fa8f65801b1816b788fa42d49d6672bf331579..6debfd5866d4411ef8d51995bd07a0e2
// Check if a World already exists with the UID.
if (this.getWorld(world.getUID()) != null) {
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index c0878cf9948774986996127e250004f0f21d6b31..788a85a65cc77b7c826a9804e52ef5883bb2ab61 100644
index 75d78e99a9191547d95c340c34876398b694bee3..a3366affccd901f35e5a018f4fb7614c621d2912 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -533,6 +533,11 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -7,7 +7,7 @@ Subject: [PATCH] Item Rarity API
public net.minecraft.world.item.Item rarity
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 788a85a65cc77b7c826a9804e52ef5883bb2ab61..3781f5bfaf4f156b7c5d383a8591e0853258a04c 100644
index a3366affccd901f35e5a018f4fb7614c621d2912..1b4ea6cd4388b8d273816725dcd15d16f99d5695 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -538,6 +538,20 @@ public final class CraftMagicNumbers implements UnsafeValues {
@ -21,12 +21,12 @@ index 788a85a65cc77b7c826a9804e52ef5883bb2ab61..3781f5bfaf4f156b7c5d383a8591e085
+ if (item == null) {
+ throw new IllegalArgumentException(material + " is not an item, and rarity does not apply to blocks");
+ }
+ return io.papermc.paper.inventory.ItemRarity.values()[item.rarity.ordinal()];
+ return io.papermc.paper.inventory.ItemRarity.values()[item.components().getOrDefault(net.minecraft.core.component.DataComponents.RARITY, net.minecraft.world.item.Rarity.COMMON).ordinal()];
+ }
+
+ @Override
+ public io.papermc.paper.inventory.ItemRarity getItemStackRarity(org.bukkit.inventory.ItemStack itemStack) {
+ return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()];
+ return io.papermc.paper.inventory.ItemRarity.values()[itemStack.getRarity().ordinal()];
+ }
// Paper end

Datei anzeigen

@ -5,12 +5,12 @@ Subject: [PATCH] Expose protocol version
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 3781f5bfaf4f156b7c5d383a8591e0853258a04c..3640e0d4ba4629f78a0030d132e1e1ddb1177557 100644
index 1b4ea6cd4388b8d273816725dcd15d16f99d5695..75a53b4e8aa917399bc2054c3dde3e2f56362b45 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -552,6 +552,11 @@ public final class CraftMagicNumbers implements UnsafeValues {
public io.papermc.paper.inventory.ItemRarity getItemStackRarity(org.bukkit.inventory.ItemStack itemStack) {
return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()];
return io.papermc.paper.inventory.ItemRarity.values()[itemStack.getRarity().ordinal()];
}
+
+ @Override

Datei anzeigen

@ -5,11 +5,11 @@ Subject: [PATCH] ItemStack repair check API
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 3640e0d4ba4629f78a0030d132e1e1ddb1177557..a82f21809b14d36fd8e440dcc7fd11f57cdbd3dc 100644
index 75a53b4e8aa917399bc2054c3dde3e2f56362b45..6b3fbdf0a53f95c43eee7b745d85e8fcf84413b0 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -553,6 +553,14 @@ public final class CraftMagicNumbers implements UnsafeValues {
return io.papermc.paper.inventory.ItemRarity.values()[getItem(itemStack.getType()).getRarity(CraftItemStack.asNMSCopy(itemStack)).ordinal()];
return io.papermc.paper.inventory.ItemRarity.values()[itemStack.getRarity().ordinal()];
}
+ @Override

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Attributes API for item defaults
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index a82f21809b14d36fd8e440dcc7fd11f57cdbd3dc..81e4ba5afba072f0a3b139538e2b146b9bafad6a 100644
index 6b3fbdf0a53f95c43eee7b745d85e8fcf84413b0..d85adc8aa11579d94ab48f6360e3df4c5796af30 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -561,6 +561,19 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -81,7 +81,7 @@ index 0000000000000000000000000000000000000000..68044b8439c302114240d0ae4da93ab3
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 81e4ba5afba072f0a3b139538e2b146b9bafad6a..4b01afda33e05a10fbdd588b4637ecead9b4da61 100644
index d85adc8aa11579d94ab48f6360e3df4c5796af30..e747c87ff8f1101119a9fb33c4d52fd97ef04938 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -578,6 +578,18 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -39,7 +39,7 @@ index 1002123cd0c6f57cecc4e80f5f21cc6ff5886d37..e96023b71845526383288917e8d7c575
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 4b01afda33e05a10fbdd588b4637ecead9b4da61..704eaa3cae99e2c1f9750029b9d86709ea019df0 100644
index e747c87ff8f1101119a9fb33c4d52fd97ef04938..97a8748284547ee6c507d9f763772e34b2371d90 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -590,6 +590,12 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -50,19 +50,20 @@ index 9edcdc71b28cf08e42fbe44723ba540e8d4f7808..a61638bc8200f6aa25d9c3254aea6c0c
@Override
public boolean isInvisible() { // Paper - moved up from LivingEntity
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 704eaa3cae99e2c1f9750029b9d86709ea019df0..8191fedcdc7d96de9574f567a8e95ce121a15df4 100644
index 97a8748284547ee6c507d9f763772e34b2371d90..ab9cf64fdde15e80c4c6fb101ee4a328844aa112 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -501,6 +501,32 @@ public final class CraftMagicNumbers implements UnsafeValues {
return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(compound));
@@ -501,7 +501,33 @@ public final class CraftMagicNumbers implements UnsafeValues {
return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.parse(MinecraftServer.getServer().registryAccess(), compound).orElseThrow());
}
- private byte[] serializeNbtToBytes(CompoundTag compound) {
+ @Override
+ public byte[] serializeEntity(org.bukkit.entity.Entity entity) {
+ Preconditions.checkNotNull(entity, "null cannot be serialized");
+ Preconditions.checkArgument(entity instanceof org.bukkit.craftbukkit.entity.CraftEntity, "only CraftEntities can be serialized");
+
+ CompoundTag compound = new CompoundTag();
+ net.minecraft.nbt.CompoundTag compound = new net.minecraft.nbt.CompoundTag();
+ ((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle().serializeEntity(compound);
+ return serializeNbtToBytes(compound);
+ }
@ -72,9 +73,9 @@ index 704eaa3cae99e2c1f9750029b9d86709ea019df0..8191fedcdc7d96de9574f567a8e95ce1
+ Preconditions.checkNotNull(data, "null cannot be deserialized");
+ Preconditions.checkArgument(data.length > 0, "cannot deserialize nothing");
+
+ CompoundTag compound = deserializeNbtFromBytes(data);
+ net.minecraft.nbt.CompoundTag compound = deserializeNbtFromBytes(data);
+ int dataVersion = compound.getInt("DataVersion");
+ compound = (CompoundTag) MinecraftServer.getServer().fixerUpper.update(References.ENTITY, new Dynamic<>(NbtOps.INSTANCE, compound), dataVersion, this.getDataVersion()).getValue();
+ compound = (net.minecraft.nbt.CompoundTag) MinecraftServer.getServer().fixerUpper.update(References.ENTITY, new Dynamic<>(NbtOps.INSTANCE, compound), dataVersion, this.getDataVersion()).getValue();
+ if (!preserveUUID) {
+ // Generate a new UUID so we don't have to worry about deserializing the same entity twice
+ compound.remove("UUID");
@ -83,6 +84,7 @@ index 704eaa3cae99e2c1f9750029b9d86709ea019df0..8191fedcdc7d96de9574f567a8e95ce1
+ .orElseThrow(() -> new IllegalArgumentException("An ID was not found for the data. Did you downgrade?")).getBukkitEntity();
+ }
+
private byte[] serializeNbtToBytes(CompoundTag compound) {
+ private byte[] serializeNbtToBytes(net.minecraft.nbt.CompoundTag compound) {
compound.putInt("DataVersion", getDataVersion());
java.io.ByteArrayOutputStream outputStream = new java.io.ByteArrayOutputStream();
try {

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Add NamespacedKey biome methods
Co-authored-by: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com>
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 8191fedcdc7d96de9574f567a8e95ce121a15df4..b2755299789dea3bcc49e66d3647a6e8a5080b4d 100644
index ab9cf64fdde15e80c4c6fb101ee4a328844aa112..14a73354698a1d0592eb0fc10c73fc2d25c02e4e 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -622,6 +622,19 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Only tick item frames if players can see it
In the event that an item frame cannot be seen by any players, ticking the item frame every tick is unnecessary. This can be a very hot section of the entity tracker when lots of item frames are present on a server, so this reduces the logic which speeds it up.
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index f355dd986bf861da3edb90d7e05f901e19686fef..b195de05371e9762654b69365f0e722443425d33 100644
index f355dd986bf861da3edb90d7e05f901e19686fef..979571cc12f81e09df8570f7deb32f4c604188bd 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -113,7 +113,7 @@ public class ServerEntity {
@ -14,7 +14,7 @@ index f355dd986bf861da3edb90d7e05f901e19686fef..b195de05371e9762654b69365f0e7224
Entity entity = this.entity;
- if (entity instanceof ItemFrame entityitemframe) {
+ if (!this.trackedPlayers.isEmpty() && entity instanceof ItemFrame) { // Paper - Perf: Only tick item frames if players can see it
+ if (!this.trackedPlayers.isEmpty() && entity instanceof ItemFrame entityitemframe) { // Paper - Perf: Only tick item frames if players can see it
if (true || this.tickCount % 10 == 0) { // CraftBukkit - Moved below, should always enter this block
ItemStack itemstack = entityitemframe.getItem();

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Cache map ids on item frames
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index b195de05371e9762654b69365f0e722443425d33..fbb138aefe19237aeeba2f5fc8070bf81e289dc3 100644
index 979571cc12f81e09df8570f7deb32f4c604188bd..0373b2de2b992b648f346d6df3960a3586a54567 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -118,7 +118,7 @@ public class ServerEntity {
@ -13,19 +13,19 @@ index b195de05371e9762654b69365f0e722443425d33..fbb138aefe19237aeeba2f5fc8070bf8
if (this.level.paperConfig().maps.itemFrameCursorUpdateInterval > 0 && this.tickCount % this.level.paperConfig().maps.itemFrameCursorUpdateInterval == 0 && itemstack.getItem() instanceof MapItem) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks // Paper - Make item frame map cursor update interval configurable
- MapId mapid = (MapId) itemstack.get(DataComponents.MAP_ID);
+ Integer integer = entityitemframe.cachedMapId; // Paper - Perf: Cache map ids on item frames
+ MapId mapid = entityitemframe.cachedMapId; // Paper - Perf: Cache map ids on item frames
MapItemSavedData worldmap = MapItem.getSavedData(mapid, this.level);
if (worldmap != null) {
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 6bf89686ce5cf700ac06ec1e38f53af745098fa3..3f35e16a91b3cf360a3b8a69ee495aaca9210e13 100644
index 6bf89686ce5cf700ac06ec1e38f53af745098fa3..da0d1c9a1c4ae081bff9ca4230c9a1503885c354 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
@@ -49,6 +49,7 @@ public class ItemFrame extends HangingEntity {
public static final int NUM_ROTATIONS = 8;
public float dropChance;
public boolean fixed;
+ public Integer cachedMapId; // Paper - Perf: Cache map ids on item frames
+ public @Nullable MapId cachedMapId; // Paper - Perf: Cache map ids on item frames
public ItemFrame(EntityType<? extends ItemFrame> type, Level world) {
super(type, world);
@ -33,7 +33,7 @@ index 6bf89686ce5cf700ac06ec1e38f53af745098fa3..3f35e16a91b3cf360a3b8a69ee495aac
}
private void onItemChanged(ItemStack stack) {
+ this.cachedMapId = MapItem.getMapId(stack); // Paper - Perf: Cache map ids on item frames
+ this.cachedMapId = stack.getComponents().get(net.minecraft.core.component.DataComponents.MAP_ID); // Paper - Perf: Cache map ids on item frames
if (!stack.isEmpty() && stack.getFrame() != this) {
stack.setEntityRepresentation(this);
}

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Fix custom statistic criteria creation
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index b2755299789dea3bcc49e66d3647a6e8a5080b4d..9ed12c6f896470f140f9ed4bdc565d2b4edda1eb 100644
index 14a73354698a1d0592eb0fc10c73fc2d25c02e4e..b5b165fc9d28afa5bac24daee98df472ac254ee1 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -635,6 +635,12 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Fix UnsafeValues#loadAdvancement
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 9ed12c6f896470f140f9ed4bdc565d2b4edda1eb..1cfd122fd734b359705e8091215dc5f6332e6f0b 100644
index b5b165fc9d28afa5bac24daee98df472ac254ee1..af98e9e0777ecca333b32245262d453d71afa396 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -320,7 +320,27 @@ public final class CraftMagicNumbers implements UnsafeValues {
@ -23,7 +23,7 @@ index 9ed12c6f896470f140f9ed4bdc565d2b4edda1eb..1cfd122fd734b359705e8091215dc5f6
+
+ MinecraftServer.getServer().getAdvancements().advancements = mapBuilder.build();
+ final net.minecraft.advancements.AdvancementTree tree = MinecraftServer.getServer().getAdvancements().tree();
+ tree.addAll(List.of(holder));
+ tree.addAll(java.util.List.of(holder));
+
+ // recalculate advancement position
+ final net.minecraft.advancements.AdvancementNode node = tree.get(minecraftkey);

Datei anzeigen

@ -39,7 +39,7 @@ index 027f2734b0ff226437f4c94430215929b6ea2219..35f627c58e93c03ee58b44877398432b
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z);
// Paper start - Configurable entity tracking range by Y
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index fbb138aefe19237aeeba2f5fc8070bf81e289dc3..8f36986b4de15df264beec5628f33066c83be35a 100644
index 0373b2de2b992b648f346d6df3960a3586a54567..22eec853588ded2d255ab69d408f8e987832abe2 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -164,7 +164,13 @@ public class ServerEntity {

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Add api for spawn egg texture colors
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 1cfd122fd734b359705e8091215dc5f6332e6f0b..bc6d26573ade3715c7a0c8ec8626c42152f1c7a5 100644
index af98e9e0777ecca333b32245262d453d71afa396..31acd769bdfdff0128275e401a6209df093506d3 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -663,6 +663,15 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -739,7 +739,7 @@ index d96399e9bf1a58db5a4a22e58abb99e7660e0694..66bdac50130f523f9dc4379b103b7a46
+ // Paper end - lifecycle events
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index bc6d26573ade3715c7a0c8ec8626c42152f1c7a5..14bd0fe7e6781d6c15cdc66713f36ded22c5a4f1 100644
index 31acd769bdfdff0128275e401a6209df093506d3..c6ce4e9428b5d6d117def376accdfb0c12b49565 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -672,6 +672,13 @@ public final class CraftMagicNumbers implements UnsafeValues {

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] ItemStack Tooltip API
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 14bd0fe7e6781d6c15cdc66713f36ded22c5a4f1..d6aa8b0d5d23114d252eaa907a5e50eb24298635 100644
index c6ce4e9428b5d6d117def376accdfb0c12b49565..901ce145d8b034559256cf10d97f46ecff1a4003 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -662,6 +662,18 @@ public final class CraftMagicNumbers implements UnsafeValues {
@ -14,13 +14,13 @@ index 14bd0fe7e6781d6c15cdc66713f36ded22c5a4f1..d6aa8b0d5d23114d252eaa907a5e50eb
// Paper end
+ // Paper start - expose itemstack tooltip lines
+ @Override
+ public List<net.kyori.adventure.text.Component> computeTooltipLines(final ItemStack itemStack, final io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, final org.bukkit.entity.Player player) {
+ public java.util.List<net.kyori.adventure.text.Component> computeTooltipLines(final ItemStack itemStack, final io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, final org.bukkit.entity.Player player) {
+ Preconditions.checkArgument(tooltipContext != null, "tooltipContext cannot be null");
+ net.minecraft.world.item.TooltipFlag.Default flag = tooltipContext.isAdvanced() ? net.minecraft.world.item.TooltipFlag.ADVANCED : net.minecraft.world.item.TooltipFlag.NORMAL;
+ if (tooltipContext.isCreative()) {
+ flag = flag.asCreative();
+ }
+ final List<net.minecraft.network.chat.Component> lines = CraftItemStack.asNMSCopy(itemStack).getTooltipLines(player == null ? null : ((org.bukkit.craftbukkit.entity.CraftPlayer) player).getHandle(), flag);
+ final java.util.List<net.minecraft.network.chat.Component> lines = CraftItemStack.asNMSCopy(itemStack).getTooltipLines(player == null ? null : ((org.bukkit.craftbukkit.entity.CraftPlayer) player).getHandle(), flag);
+ return lines.stream().map(io.papermc.paper.adventure.PaperAdventure::asAdventure).toList();
+ }
+ // Paper end - expose itemstack tooltip lines