Files
Purpur/purpur-server/minecraft-patches/features/0013-Apply-display-names-from-item-forms-of-entities-to-e.patch
granny d7de13dd4d Update to 1.21.10 & Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@0ff899da Prevent world mutation on copper golem spawn cancel (#13152)
PaperMC/Paper@bae47d3e Update to 1.21.10 (#13127)
PaperMC/Paper@8339bb31 Update DataConverter constants for 1.21.10
PaperMC/Paper@3982efa0 Sync Moonrise
PaperMC/Paper@fa57d4b7 Remove Vanilla packet processing at start of tick
PaperMC/Paper@fba780d6 Rebuild patches
2025-10-07 20:51:02 -07:00

113 lines
7.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Tue, 17 Nov 2020 03:23:48 -0800
Subject: [PATCH] Apply display names from item forms of entities to entities
and vice versa
diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java
index 3412b6dcc2d65986a4f657a6efd7b9fee63d5f8b..d2c5cf955cf8eb534f7bf0afebded9fdf209f117 100644
--- a/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -450,6 +450,7 @@ public class ArmorStand extends LivingEntity {
private org.bukkit.event.entity.EntityDeathEvent brokenByPlayer(ServerLevel level, DamageSource damageSource) { // Paper
ItemStack itemStack = new ItemStack(Items.ARMOR_STAND);
+ if (level.purpurConfig.persistentDroppableEntityDisplayNames) // Purpur - Apply display names from item forms of entities to entities and vice versa
itemStack.set(DataComponents.CUSTOM_NAME, this.getCustomName());
this.drops.add(new DefaultDrop(itemStack, stack -> Block.popResource(this.level(), this.blockPosition(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior
return this.brokenByAnything(level, damageSource); // Paper
diff --git a/net/minecraft/world/entity/decoration/ItemFrame.java b/net/minecraft/world/entity/decoration/ItemFrame.java
index e6012d2cfe9b84782c8d5a0ba424eeda98086c09..6bf12f09c189ccaf45552f76d50f6743d93db0c3 100644
--- a/net/minecraft/world/entity/decoration/ItemFrame.java
+++ b/net/minecraft/world/entity/decoration/ItemFrame.java
@@ -246,7 +246,11 @@ public class ItemFrame extends HangingEntity {
this.removeFramedMap(item);
} else {
if (dropItem) {
- this.spawnAtLocation(level, this.getFrameItemStack());
+ // Purpur start - Apply display names from item forms of entities to entities and vice versa
+ final ItemStack itemFrame = this.getFrameItemStack();
+ if (!level.purpurConfig.persistentDroppableEntityDisplayNames) itemFrame.set(DataComponents.CUSTOM_NAME, null);
+ this.spawnAtLocation(level, itemFrame);
+ // Purpur end - Apply display names from item forms of entities to entities and vice versa
}
if (!item.isEmpty()) {
diff --git a/net/minecraft/world/entity/decoration/Painting.java b/net/minecraft/world/entity/decoration/Painting.java
index cc34cadac8896a5f546d0879e795fea08d0c3f98..26a08b16de2318d5080be59a29c5f11e3597426d 100644
--- a/net/minecraft/world/entity/decoration/Painting.java
+++ b/net/minecraft/world/entity/decoration/Painting.java
@@ -182,7 +182,11 @@ public class Painting extends HangingEntity {
if (level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.playSound(SoundEvents.PAINTING_BREAK, 1.0F, 1.0F);
if (!(entity instanceof Player player && player.hasInfiniteMaterials())) {
- this.spawnAtLocation(level, Items.PAINTING);
+ // Purpur start - Apply display names from item forms of entities to entities and vice versa
+ final ItemStack painting = new ItemStack(Items.PAINTING);
+ if (!this.level().purpurConfig.persistentDroppableEntityDisplayNames) painting.set(net.minecraft.core.component.DataComponents.CUSTOM_NAME, null);
+ this.spawnAtLocation(level, painting);
+ // Purpur end - Apply display names from item forms of entities to entities and vice versa
}
}
}
diff --git a/net/minecraft/world/entity/vehicle/AbstractBoat.java b/net/minecraft/world/entity/vehicle/AbstractBoat.java
index 464d342d8e24f33745cb09d0d61aad35cf98ebdf..e6abec1b9245e07c8f0636272bece71865f59d9b 100644
--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java
+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java
@@ -821,7 +821,13 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable {
@Override
public final ItemStack getPickResult() {
- return new ItemStack(this.dropItem.get());
+ // Purpur start - Apply display names from item forms of entities to entities and vice versa
+ final ItemStack boat = new ItemStack(this.dropItem.get());
+ if (!this.level().purpurConfig.persistentDroppableEntityDisplayNames) {
+ boat.set(net.minecraft.core.component.DataComponents.CUSTOM_NAME, null);
+ }
+ return boat;
+ // Purpur end - Apply display names from item forms of entities to entities and vice versa
}
public static enum Status {
diff --git a/net/minecraft/world/item/ArmorStandItem.java b/net/minecraft/world/item/ArmorStandItem.java
index 962483d6f7225f13f121141882262d36dacad8cb..89d4bc00898fd8f6d40cda87c04c5983e2ea223c 100644
--- a/net/minecraft/world/item/ArmorStandItem.java
+++ b/net/minecraft/world/item/ArmorStandItem.java
@@ -51,6 +51,10 @@ public class ArmorStandItem extends Item {
return InteractionResult.FAIL;
}
// CraftBukkit end
+ // Purpur start - Apply display names from item forms of entities to entities and vice versa
+ if (!serverLevel.purpurConfig.persistentDroppableEntityDisplayNames) armorStand.setCustomName(null);
+ if (serverLevel.purpurConfig.armorstandSetNameVisible && armorStand.getCustomName() != null) armorStand.setCustomNameVisible(true);
+ // Purpur end - Apply display names from item forms of entities to entities and vice versa
serverLevel.addFreshEntityWithPassengers(armorStand);
level.playSound(
null, armorStand.getX(), armorStand.getY(), armorStand.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F
diff --git a/net/minecraft/world/item/BoatItem.java b/net/minecraft/world/item/BoatItem.java
index e849d3b8d3cc0203fa7736f88a669c67af699110..fdf09c4fe801a36589f54982b07371d2f9421084 100644
--- a/net/minecraft/world/item/BoatItem.java
+++ b/net/minecraft/world/item/BoatItem.java
@@ -63,6 +63,7 @@ public class BoatItem extends Item {
return InteractionResult.FAIL;
} else {
boat.setYRot(player.getYRot());
+ if (!level.purpurConfig.persistentDroppableEntityDisplayNames) boat.setCustomName(null); // Purpur - Apply display names from item forms of entities to entities and vice versa
if (!level.noCollision(boat, boat.getBoundingBox())) {
return InteractionResult.FAIL;
} else {
diff --git a/net/minecraft/world/item/HangingEntityItem.java b/net/minecraft/world/item/HangingEntityItem.java
index 0880db37298f9f338baa76028c132b4bb25f1d42..4a236dd14250bf0f1ce63e67349a4c48f104420c 100644
--- a/net/minecraft/world/item/HangingEntityItem.java
+++ b/net/minecraft/world/item/HangingEntityItem.java
@@ -59,7 +59,7 @@ public class HangingEntityItem extends Item {
hangingEntity = new GlowItemFrame(level, blockPos, clickedFace);
}
- EntityType.<HangingEntity>createDefaultStackConfig(level, itemInHand, player).accept(hangingEntity);
+ EntityType.<HangingEntity>appendDefaultStackConfig(entity -> {if (!level.purpurConfig.persistentDroppableEntityDisplayNames) entity.setCustomName(null);}, level, itemInHand, player).accept(hangingEntity); // Purpur - Apply display names from item forms of entities to entities and vice versa
if (hangingEntity.survives()) {
if (!level.isClientSide()) {
// CraftBukkit start - fire HangingPlaceEvent