mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-22 02:47:43 +01:00
113 lines
7.7 KiB
Diff
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 5dfd78a0e00cae85feff8acd785cdfdf23433ba6..e6813da9d002b90acd44db1435f5fa9bf1bbed47 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 90fd3ca5ecd29befa9237222e9f86a8a79a011e4..7e96617f0d5e8777873b4c2cccd012d656612f96 100644
|
|
--- a/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
+++ b/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
@@ -237,7 +237,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 4dcf6daa146645f096ac8815588c837715073c22..d947801b616af5b5dcdcc8bb70b36f97d6a69fdd 100644
|
|
--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
@@ -825,7 +825,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 13ce174e4f7e406f57a68ea0d3ef0ee3367f3f3b..ca86122e38688b29340cd8413ccf1746315e292a 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 5f9c166b8ba9e9dcabb7398308e7520a88335eae..e9e3a036290a5facc36cf6a484d03d4d3bfb65a5 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
|