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 0f48cba7d4a5246baa58aaf7e42deff93a0307de..8ed90c7e793c12a130a3214f54aab5482e8e1a8a 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java @@ -475,6 +475,7 @@ public class ArmorStand extends LivingEntity { private org.bukkit.event.entity.EntityDeathEvent brokenByPlayer(final ServerLevel level, final DamageSource source) { // Paper ItemStack result = new ItemStack(Items.ARMOR_STAND); + if (level.purpurConfig.persistentDroppableEntityDisplayNames) // Purpur - Apply display names from item forms of entities to entities and vice versa result.set(DataComponents.CUSTOM_NAME, this.getCustomName()); this.drops.add(new DefaultDrop(result, stack -> Block.popResource(this.level(), this.blockPosition(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior return this.brokenByAnything(level, source); // Paper diff --git a/net/minecraft/world/entity/decoration/ItemFrame.java b/net/minecraft/world/entity/decoration/ItemFrame.java index 9cc2af3db862fdfa45a67ef4b9c49581d7d69d36..b62bf660b9ccc479afdd9d277a78aa857211ef12 100644 --- a/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/net/minecraft/world/entity/decoration/ItemFrame.java @@ -248,7 +248,11 @@ public class ItemFrame extends HangingEntity { this.removeFramedMap(itemStack); } else { if (withFrame) { - 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 (!itemStack.isEmpty()) { diff --git a/net/minecraft/world/entity/decoration/painting/Painting.java b/net/minecraft/world/entity/decoration/painting/Painting.java index e43a510250b7c9b2b5542c30a9aca8be23004794..bb4081d0345a59b209c076fafaee1d1872ea0285 100644 --- a/net/minecraft/world/entity/decoration/painting/Painting.java +++ b/net/minecraft/world/entity/decoration/painting/Painting.java @@ -182,7 +182,11 @@ public class Painting extends HangingEntity { if (level.getGameRules().get(GameRules.ENTITY_DROPS)) { this.playSound(SoundEvents.PAINTING_BREAK, 1.0F, 1.0F); if (!(causedBy 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/boat/AbstractBoat.java b/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java index b78a488780dcf1be542fcb2c271b06939ede7053..37386231ba0de8cec1a671b95ca9cc96446115be 100644 --- a/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java +++ b/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java @@ -820,7 +820,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 } @Override diff --git a/net/minecraft/world/item/ArmorStandItem.java b/net/minecraft/world/item/ArmorStandItem.java index 62b2da0f028d21f6f759bb13acaf0ed62c673386..f0cb4717a0ffb30ca81d957e0d5f468c187dd693 100644 --- a/net/minecraft/world/item/ArmorStandItem.java +++ b/net/minecraft/world/item/ArmorStandItem.java @@ -52,6 +52,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) entity.setCustomName(null); + if (serverLevel.purpurConfig.armorstandSetNameVisible && entity.getCustomName() != null) entity.setCustomNameVisible(true); + // Purpur end - Apply display names from item forms of entities to entities and vice versa serverLevel.addFreshEntityWithPassengers(entity); level.playSound(null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F); entity.gameEvent(GameEvent.ENTITY_PLACE, context.getPlayer()); diff --git a/net/minecraft/world/item/BoatItem.java b/net/minecraft/world/item/BoatItem.java index 8d30c52c46b5f81cd0b9eef6b9c2301613f23892..7c4786b14acbeaa9fd8f98281ed74efbccdd15c9 100644 --- a/net/minecraft/world/item/BoatItem.java +++ b/net/minecraft/world/item/BoatItem.java @@ -65,6 +65,7 @@ public class BoatItem extends Item { } 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; } diff --git a/net/minecraft/world/item/HangingEntityItem.java b/net/minecraft/world/item/HangingEntityItem.java index b90397101ffb45b1a0aee3103be2d3100ae02788..a611db7d20c8652abac02c2bb80bfd974a990df0 100644 --- a/net/minecraft/world/item/HangingEntityItem.java +++ b/net/minecraft/world/item/HangingEntityItem.java @@ -60,7 +60,7 @@ public class HangingEntityItem extends Item { entity = new GlowItemFrame(level, blockPos, clickedFace); } - EntityType.createDefaultStackConfig(level, itemInHand, player).accept(entity); + EntityType.appendDefaultStackConfig(entity1 -> {if (!level.purpurConfig.persistentDroppableEntityDisplayNames) entity1.setCustomName(null);}, level, itemInHand, player).accept(entity); // Purpur - Apply display names from item forms of entities to entities and vice versa if (entity.survives()) { if (!level.isClientSide()) { // CraftBukkit start - fire HangingPlaceEvent