Persistent BlockEntity Lore and DisplayName

Makes it so that when a BlockEntity is placed in the world and then broken, the dropped ItemStack retains any original custom display name/lore.
This commit is contained in:
Jason Penilla
2025-01-12 13:25:06 -08:00
committed by granny
parent 2949506adb
commit eb7d596b45
5 changed files with 128 additions and 164 deletions

View File

@@ -1,5 +1,23 @@
--- a/net/minecraft/world/item/BlockItem.java
+++ b/net/minecraft/world/item/BlockItem.java
@@ -152,7 +_,16 @@
}
protected boolean updateCustomBlockEntityTag(BlockPos pos, Level level, @Nullable Player player, ItemStack stack, BlockState state) {
- return updateCustomBlockEntityTag(level, player, pos, stack);
+ // Purpur start - Persistent BlockEntity Lore and DisplayName
+ boolean handled = updateCustomBlockEntityTag(level, player, pos, stack);
+ if (level.purpurConfig.persistentTileEntityLore) {
+ BlockEntity blockEntity1 = level.getBlockEntity(pos);
+ if (blockEntity1 != null) {
+ blockEntity1.setPersistentLore(stack.getOrDefault(DataComponents.LORE, net.minecraft.world.item.component.ItemLore.EMPTY));
+ }
+ }
+ return handled;
+ // Purpur end - Persistent BlockEntity Lore and DisplayName
}
@Nullable
@@ -217,6 +_,7 @@
}