Skip to content

Commit 30de494

Browse files
committed
port Apply display names from item forms of entities to entities and vice versa patch
1 parent fd69ad5 commit 30de494

3 files changed

Lines changed: 116 additions & 159 deletions

File tree

patches/server/0098-Apply-display-names-from-item-forms-of-entities-to-e.patch

Lines changed: 0 additions & 159 deletions
This file was deleted.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
3+
Date: Tue, 17 Nov 2020 03:23:48 -0800
4+
Subject: [PATCH] Apply display names from item forms of entities to entities
5+
and vice versa
6+
7+
8+
diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java
9+
index 9f5b23fe003de62458a58b0f6af13e23606e3e85..9327841ad53bb6057394e0d009491a9e8e5c0344 100644
10+
--- a/net/minecraft/world/entity/decoration/ArmorStand.java
11+
+++ b/net/minecraft/world/entity/decoration/ArmorStand.java
12+
@@ -561,6 +561,7 @@ public class ArmorStand extends LivingEntity {
13+
14+
private org.bukkit.event.entity.EntityDeathEvent brokenByPlayer(ServerLevel level, DamageSource damageSource) { // Paper
15+
ItemStack itemStack = new ItemStack(Items.ARMOR_STAND);
16+
+ if (level.purpurConfig.persistentDroppableEntityDisplayNames) // Purpur - Apply display names from item forms of entities to entities and vice versa
17+
itemStack.set(DataComponents.CUSTOM_NAME, this.getCustomName());
18+
this.drops.add(new DefaultDrop(itemStack, stack -> Block.popResource(this.level(), this.blockPosition(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior
19+
return this.brokenByAnything(level, damageSource); // Paper
20+
diff --git a/net/minecraft/world/entity/decoration/ItemFrame.java b/net/minecraft/world/entity/decoration/ItemFrame.java
21+
index 65e1d7c5ac94b1cfb921fa009be59d3e5872f0b5..3ee1d8798db666ee8d83556047e40ff217cda732 100644
22+
--- a/net/minecraft/world/entity/decoration/ItemFrame.java
23+
+++ b/net/minecraft/world/entity/decoration/ItemFrame.java
24+
@@ -223,7 +223,11 @@ public class ItemFrame extends HangingEntity {
25+
this.removeFramedMap(item);
26+
} else {
27+
if (dropItem) {
28+
- this.spawnAtLocation(level, this.getFrameItemStack());
29+
+ // Purpur start - Apply display names from item forms of entities to entities and vice versa
30+
+ final ItemStack itemFrame = this.getFrameItemStack();
31+
+ if (!level.purpurConfig.persistentDroppableEntityDisplayNames) itemFrame.set(DataComponents.CUSTOM_NAME, null);
32+
+ this.spawnAtLocation(level, itemFrame);
33+
+ // Purpur end - Apply display names from item forms of entities to entities and vice versa
34+
}
35+
36+
if (!item.isEmpty()) {
37+
diff --git a/net/minecraft/world/entity/decoration/Painting.java b/net/minecraft/world/entity/decoration/Painting.java
38+
index 5b905a4d49c44b04d5795c2bf297f3c69d183d7c..b6429a2bbb6fc1e08610ab20e50f8f0414f0ad26 100644
39+
--- a/net/minecraft/world/entity/decoration/Painting.java
40+
+++ b/net/minecraft/world/entity/decoration/Painting.java
41+
@@ -162,7 +162,11 @@ public class Painting extends HangingEntity implements VariantHolder<Holder<Pain
42+
if (level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
43+
this.playSound(SoundEvents.PAINTING_BREAK, 1.0F, 1.0F);
44+
if (!(entity instanceof Player player && player.hasInfiniteMaterials())) {
45+
- this.spawnAtLocation(level, Items.PAINTING);
46+
+ // Purpur start - Apply display names from item forms of entities to entities and vice versa
47+
+ final ItemStack painting = new ItemStack(Items.PAINTING);
48+
+ if (!this.level().purpurConfig.persistentDroppableEntityDisplayNames) painting.set(net.minecraft.core.component.DataComponents.CUSTOM_NAME, null);
49+
+ this.spawnAtLocation(level, painting);
50+
+ // Purpur end - Apply display names from item forms of entities to entities and vice versa
51+
}
52+
}
53+
}
54+
diff --git a/net/minecraft/world/entity/vehicle/AbstractBoat.java b/net/minecraft/world/entity/vehicle/AbstractBoat.java
55+
index 4e724a12f13032075aeff7cf71b9ceabd5a7bd88..b1b312e45ed4514eaa6fb3941af64b641220c5bd 100644
56+
--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java
57+
+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java
58+
@@ -879,7 +879,13 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable {
59+
60+
@Override
61+
public final ItemStack getPickResult() {
62+
- return new ItemStack(this.dropItem.get());
63+
+ // Purpur start - Apply display names from item forms of entities to entities and vice versa
64+
+ final ItemStack boat = new ItemStack(this.dropItem.get());
65+
+ if (!this.level().purpurConfig.persistentDroppableEntityDisplayNames) {
66+
+ boat.set(net.minecraft.core.component.DataComponents.CUSTOM_NAME, null);
67+
+ }
68+
+ return boat;
69+
+ // Purpur end - Apply display names from item forms of entities to entities and vice versa
70+
}
71+
72+
public static enum Status {
73+
diff --git a/net/minecraft/world/item/ArmorStandItem.java b/net/minecraft/world/item/ArmorStandItem.java
74+
index d82e6651999a2650ec8884c4c3d8de4133cb42a4..a26b9fe964c79da57aaa0f755a81934f51a79913 100644
75+
--- a/net/minecraft/world/item/ArmorStandItem.java
76+
+++ b/net/minecraft/world/item/ArmorStandItem.java
77+
@@ -51,6 +51,10 @@ public class ArmorStandItem extends Item {
78+
return InteractionResult.FAIL;
79+
}
80+
// CraftBukkit end
81+
+ // Purpur start - Apply display names from item forms of entities to entities and vice versa
82+
+ if (!serverLevel.purpurConfig.persistentDroppableEntityDisplayNames) armorStand.setCustomName(null);
83+
+ if (serverLevel.purpurConfig.armorstandSetNameVisible && armorStand.getCustomName() != null) armorStand.setCustomNameVisible(true);
84+
+ // Purpur end - Apply display names from item forms of entities to entities and vice versa
85+
serverLevel.addFreshEntityWithPassengers(armorStand);
86+
level.playSound(
87+
null, armorStand.getX(), armorStand.getY(), armorStand.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F
88+
diff --git a/net/minecraft/world/item/BoatItem.java b/net/minecraft/world/item/BoatItem.java
89+
index 13ce174e4f7e406f57a68ea0d3ef0ee3367f3f3b..ca86122e38688b29340cd8413ccf1746315e292a 100644
90+
--- a/net/minecraft/world/item/BoatItem.java
91+
+++ b/net/minecraft/world/item/BoatItem.java
92+
@@ -63,6 +63,7 @@ public class BoatItem extends Item {
93+
return InteractionResult.FAIL;
94+
} else {
95+
boat.setYRot(player.getYRot());
96+
+ if (!level.purpurConfig.persistentDroppableEntityDisplayNames) boat.setCustomName(null); // Purpur - Apply display names from item forms of entities to entities and vice versa
97+
if (!level.noCollision(boat, boat.getBoundingBox())) {
98+
return InteractionResult.FAIL;
99+
} else {
100+
diff --git a/net/minecraft/world/item/HangingEntityItem.java b/net/minecraft/world/item/HangingEntityItem.java
101+
index 85980c7e5ad63398e0f0948fb0250f580251fe63..cd9e0398876567afc337db8f6ff0ebb0ee162383 100644
102+
--- a/net/minecraft/world/item/HangingEntityItem.java
103+
+++ b/net/minecraft/world/item/HangingEntityItem.java
104+
@@ -62,6 +62,7 @@ public class HangingEntityItem extends Item {
105+
CustomData customData = itemInHand.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY);
106+
if (!customData.isEmpty()) {
107+
EntityType.updateCustomEntityTag(level, player, hangingEntity, customData);
108+
+ if (!level.purpurConfig.persistentDroppableEntityDisplayNames) hangingEntity.setCustomName(null); // Purpur - Apply display names from item forms of entities to entities and vice versa
109+
}
110+
111+
if (hangingEntity.survives()) {

purpur-server/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ private Map<String, Object> getMap(String path, Map<String, Object> def) {
8989
}
9090

9191
public float armorstandStepHeight = 0.0F;
92+
public boolean armorstandSetNameVisible = false;
9293
private void armorstandSettings() {
9394
armorstandStepHeight = (float) getDouble("gameplay-mechanics.armorstand.step-height", armorstandStepHeight);
95+
armorstandSetNameVisible = getBoolean("gameplay-mechanics.armorstand.set-name-visible-when-placing-with-custom-name", armorstandSetNameVisible);
9496
}
9597

9698
public boolean arrowMovementResetsDespawnCounter = true;
@@ -106,6 +108,7 @@ private void arrowSettings() {
106108
public boolean entitiesCanUsePortals = true;
107109
public int raidCooldownSeconds = 0;
108110
public int animalBreedingCooldownSeconds = 0;
111+
public boolean persistentDroppableEntityDisplayNames = true;
109112
private void miscGameplayMechanicsSettings() {
110113
useBetterMending = getBoolean("gameplay-mechanics.use-better-mending", useBetterMending);
111114
boatEjectPlayersOnLand = getBoolean("gameplay-mechanics.boat.eject-players-on-land", boatEjectPlayersOnLand);
@@ -115,6 +118,8 @@ private void miscGameplayMechanicsSettings() {
115118
entitiesCanUsePortals = getBoolean("gameplay-mechanics.entities-can-use-portals", entitiesCanUsePortals);
116119
raidCooldownSeconds = getInt("gameplay-mechanics.raid-cooldown-seconds", raidCooldownSeconds);
117120
animalBreedingCooldownSeconds = getInt("gameplay-mechanics.animal-breeding-cooldown-seconds", animalBreedingCooldownSeconds);
121+
persistentDroppableEntityDisplayNames = getBoolean("gameplay-mechanics.persistent-droppable-entity-display-names", persistentDroppableEntityDisplayNames);
122+
118123
}
119124

120125
public int daytimeTicks = 12000;

0 commit comments

Comments
 (0)