Files
Purpur/patches/server/0105-Apply-display-names-from-item-forms-of-entities-to-e.patch
granny 028d47bf9f Updated Upstream (Paper & Pufferfish)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@990be16 Iterate over entity array copy for entity scheduler
PaperMC/Paper@3f6c4b0 Add event for player editing sign (#9300)
PaperMC/Paper@7103f81 Only tick item frames if players can see it (#9377)
PaperMC/Paper@cf0f013 Avoid duplicate death event call for armorstands (#9223)
PaperMC/Paper@8582999 Deprecate duplicate chat completion methods (#9401)
PaperMC/Paper@e4b40dd Fix entity selectors while spectating (#9402)
PaperMC/Paper@82cd69f [ci skip] Update Repo style and change project url in README (#9407)
PaperMC/Paper@2c9c5e4 Fix replenishable container entities save/load existing contents (#9417)
PaperMC/Paper@437e8da Improve command function perm level checks (#9411)
PaperMC/Paper@225c950 Hotfix double entity removal making entity scheduler retire call
PaperMC/Paper@fead63e Add option to disable NoteBlock and Tripwire updates (#9368)

Pufferfish Changes:
pufferfish-gg/Pufferfish@50f3124 Updated Upstream (Paper)
pufferfish-gg/Pufferfish@5673490 Add option to suppress null ID disconnections in logs
pufferfish-gg/Pufferfish@1e911fb Fix issue with that last patch
2023-06-30 12:37:27 -07:00

169 lines
9.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/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
index 5524a69952130ec38e151509ba7733459146d1b0..76222084727c269d376d0df5702204c0bdf59d81 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -606,7 +606,7 @@ public class ArmorStand extends LivingEntity {
private org.bukkit.event.entity.EntityDeathEvent brokenByPlayer(DamageSource damageSource) { // Paper
ItemStack itemstack = new ItemStack(Items.ARMOR_STAND);
- if (this.hasCustomName()) {
+ if (this.level().purpurConfig.persistentDroppableEntityDisplayNames && this.hasCustomName()) { // Purpur
itemstack.setHoverName(this.getCustomName());
}
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
index 955316687e2e29ad75a0052317a7b0f89034c82a..19fa9b30768e1d3d095b5efdde1399d5ac7df821 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
@@ -272,7 +272,13 @@ public class ItemFrame extends HangingEntity {
}
if (alwaysDrop) {
- this.spawnAtLocation(this.getFrameItemStack());
+ // Purpur start
+ final ItemStack itemFrame = this.getFrameItemStack();
+ if (this.level().purpurConfig.persistentDroppableEntityDisplayNames && this.hasCustomName()) {
+ itemFrame.setHoverName(this.getCustomName());
+ }
+ this.spawnAtLocation(itemFrame);
+ // Purpur end
}
if (!itemstack.isEmpty()) {
diff --git a/src/main/java/net/minecraft/world/entity/decoration/Painting.java b/src/main/java/net/minecraft/world/entity/decoration/Painting.java
index d5784a19cec98eb199a51acd9e1f4de8c6bf7265..4b3a8e4a084585d56dd10a08405463b1a677368b 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/Painting.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/Painting.java
@@ -159,7 +159,13 @@ public class Painting extends HangingEntity implements VariantHolder<Holder<Pain
}
}
- this.spawnAtLocation(Items.PAINTING);
+ // Purpur start
+ final ItemStack painting = new ItemStack(Items.PAINTING);
+ if (this.level().purpurConfig.persistentDroppableEntityDisplayNames && this.hasCustomName()) {
+ painting.setHoverName(this.getCustomName());
+ }
+ this.spawnAtLocation(painting);
+ // Purpur end
}
}
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
index cb8443c9bc902741dfe6746baca9129214ab503b..a941b00f0e4b667925ca68cc706245b05478ad77 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
@@ -223,7 +223,13 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
}
protected void destroy(DamageSource source) {
- this.spawnAtLocation((ItemLike) this.getDropItem());
+ // Purpur start
+ final ItemStack boat = new ItemStack(this.getDropItem());
+ if (this.level().purpurConfig.persistentDroppableEntityDisplayNames && this.hasCustomName()) {
+ boat.setHoverName(this.getCustomName());
+ }
+ this.spawnAtLocation(boat);
+ // Purpur end
}
@Override
diff --git a/src/main/java/net/minecraft/world/item/ArmorStandItem.java b/src/main/java/net/minecraft/world/item/ArmorStandItem.java
index 7cffc64573008502bdd14ae4906fe51166b12fb3..1feafdbb48cf760cb6ebf95d5be2c32bdb1ad44f 100644
--- a/src/main/java/net/minecraft/world/item/ArmorStandItem.java
+++ b/src/main/java/net/minecraft/world/item/ArmorStandItem.java
@@ -58,6 +58,14 @@ public class ArmorStandItem extends Item {
return InteractionResult.FAIL;
}
// CraftBukkit end
+ // Purpur start
+ if (world.purpurConfig.persistentDroppableEntityDisplayNames && itemstack.hasCustomHoverName()) {
+ entityarmorstand.setCustomName(itemstack.getHoverName());
+ if (world.purpurConfig.armorstandSetNameVisible) {
+ entityarmorstand.setCustomNameVisible(true);
+ }
+ }
+ // Purpur end
worldserver.addFreshEntityWithPassengers(entityarmorstand);
world.playSound((Player) null, entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F);
entityarmorstand.gameEvent(GameEvent.ENTITY_PLACE, context.getPlayer());
diff --git a/src/main/java/net/minecraft/world/item/BoatItem.java b/src/main/java/net/minecraft/world/item/BoatItem.java
index aec7ac31a35b1cc81f40b3fbeb5cf95c0f2c8a6c..cbcd35e60a2c344c83978abf0b94c2120ff53dee 100644
--- a/src/main/java/net/minecraft/world/item/BoatItem.java
+++ b/src/main/java/net/minecraft/world/item/BoatItem.java
@@ -69,6 +69,11 @@ public class BoatItem extends Item {
entityboat.setVariant(this.type);
entityboat.setYRot(user.getYRot());
+ // Purpur start
+ if (world.purpurConfig.persistentDroppableEntityDisplayNames && itemstack.hasCustomHoverName()) {
+ entityboat.setCustomName(itemstack.getHoverName());
+ }
+ // Purpur end
if (!world.noCollision(entityboat, entityboat.getBoundingBox())) {
return InteractionResultHolder.fail(itemstack);
} else {
diff --git a/src/main/java/net/minecraft/world/item/HangingEntityItem.java b/src/main/java/net/minecraft/world/item/HangingEntityItem.java
index b2ad6d230de2c29f371178bccde1111c7532ee70..6667926519a0f1c151e53f59cce36e7417dfc1cd 100644
--- a/src/main/java/net/minecraft/world/item/HangingEntityItem.java
+++ b/src/main/java/net/minecraft/world/item/HangingEntityItem.java
@@ -48,7 +48,7 @@ public class HangingEntityItem extends Item {
return InteractionResult.FAIL;
} else {
Level world = context.getLevel();
- Object object;
+ Entity object; // Purpur
if (this.type == EntityType.PAINTING) {
Optional<Painting> optional = Painting.create(world, blockposition1, enumdirection);
@@ -72,6 +72,11 @@ public class HangingEntityItem extends Item {
if (nbttagcompound != null) {
EntityType.updateCustomEntityTag(world, entityhuman, (Entity) object, nbttagcompound);
+ // Purpur start
+ if (world.purpurConfig.persistentDroppableEntityDisplayNames && itemstack.hasCustomHoverName()) {
+ object.setCustomName(itemstack.getHoverName());
+ }
+ // Purpur end
}
if (((HangingEntity) object).survives()) {
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index ec00f1a76f5d9c26766348d445df64cff31963b1..5f7c0cda2e0ec0064f0fec80cfffd2ae6bad154c 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -98,8 +98,10 @@ public class PurpurWorldConfig {
}
public float armorstandStepHeight = 0.0F;
+ public boolean armorstandSetNameVisible = true;
private void armorstandSettings() {
armorstandStepHeight = (float) getDouble("gameplay-mechanics.armorstand.step-height", armorstandStepHeight);
+ armorstandSetNameVisible = getBoolean("gameplay-mechanics.armorstand.set-name-visible-when-placing-with-custom-name", armorstandSetNameVisible);
}
public boolean arrowMovementResetsDespawnCounter = true;
@@ -112,6 +114,7 @@ public class PurpurWorldConfig {
public boolean disableDropsOnCrammingDeath = false;
public boolean entitiesCanUsePortals = true;
public boolean milkCuresBadOmen = true;
+ public boolean persistentDroppableEntityDisplayNames = true;
public double tridentLoyaltyVoidReturnHeight = 0.0D;
public double voidDamageHeight = -64.0D;
public double voidDamageDealt = 4.0D;
@@ -123,6 +126,7 @@ public class PurpurWorldConfig {
disableDropsOnCrammingDeath = getBoolean("gameplay-mechanics.disable-drops-on-cramming-death", disableDropsOnCrammingDeath);
entitiesCanUsePortals = getBoolean("gameplay-mechanics.entities-can-use-portals", entitiesCanUsePortals);
milkCuresBadOmen = getBoolean("gameplay-mechanics.milk-cures-bad-omen", milkCuresBadOmen);
+ persistentDroppableEntityDisplayNames = getBoolean("gameplay-mechanics.persistent-droppable-entity-display-names", persistentDroppableEntityDisplayNames);
tridentLoyaltyVoidReturnHeight = getDouble("gameplay-mechanics.trident-loyalty-void-return-height", tridentLoyaltyVoidReturnHeight);
voidDamageHeight = getDouble("gameplay-mechanics.void-damage-height", voidDamageHeight);
voidDamageDealt = getDouble("gameplay-mechanics.void-damage-dealt", voidDamageDealt);