Files
Purpur/patches/server/0118-Apply-display-names-from-item-forms-of-entities-to-e.patch
William Blake Galbreath 69c7c31f9a Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
26c37d99d5 create random seeds for features using SecureRandom
589bf2f1bf Upgrade gson to 2.8.8 (Closes #6370)
0a6103597b Get entity default attributes (#6449)
40057019e0 Correctly inflate villager activation bounding box (#6798)
e5f9241d15 Left handed API (#6775)
40ee63496c Add advancement display API (#6175)
9d570042ed Add ItemFactory#getMonsterEgg API (#6772)
55ca459515 rename method to getSpawnEgg
bb397ba74c Add critical damage API (#6275)
f47aeafe00 Add Horse Animation API (#5599)
7a0886180f AT & Mapping fixes (#6809)
5553432644 docs: Update gradle instructions for Java 16 (#6811) [ci skip]
a1f49e4c60 Fix command suggestion leak (#6592)
9472d38f3c Fix method name for Critical damage (#6813)
2021-10-21 10:58:20 -05:00

175 lines
10 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 fee2bd03d007e6d69706f8cb953a2f6ae59cac35..bb710e62477df3048d5219f1edfa9ffdefacb41d 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -597,7 +597,13 @@ public class ArmorStand extends LivingEntity {
}
private void brokenByPlayer(DamageSource damageSource) {
- drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.ARMOR_STAND))); // CraftBukkit - add to drops
+ // Purpur start
+ final ItemStack armorStand = new ItemStack(Items.ARMOR_STAND);
+ if (this.level.purpurConfig.persistentDroppableEntityDisplayNames && this.hasCustomName()) {
+ armorStand.setHoverName(this.getCustomName());
+ }
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(armorStand)); // CraftBukkit - add to drops
+ // Purpur end
this.brokenByAnything(damageSource);
}
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 b829efdb40051a41b3bf1cabb8bf7d7c952797b5..90f1ecd97eef93316f61bf5d761d33c313e1a077 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
@@ -257,7 +257,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 a853e2cc2e3f06a0ca0bb1799b3fd02890ae6521..a8265cd631d335d4eaec1918bd48570ee1fc9429 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/Painting.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/Painting.java
@@ -114,7 +114,13 @@ public class Painting extends HangingEntity {
}
}
- this.spawnAtLocation((ItemLike) 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 6acd2dc6ec9c3761fa330c74df8c7e7b19266f8e..f46ebe98c173d9a6cb6d6e375b55fd9b3f75e13c 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
@@ -209,7 +209,13 @@ public class Boat extends Entity {
}
// CraftBukkit end
if (!flag && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
- 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
}
this.discard();
diff --git a/src/main/java/net/minecraft/world/item/ArmorStandItem.java b/src/main/java/net/minecraft/world/item/ArmorStandItem.java
index 44d63145480d38a4ec3a38be108200af070bcffa..7de67b75010f0da52004c911f6ee98eb133fdaed 100644
--- a/src/main/java/net/minecraft/world/item/ArmorStandItem.java
+++ b/src/main/java/net/minecraft/world/item/ArmorStandItem.java
@@ -63,6 +63,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);
world.gameEvent((Entity) context.getPlayer(), GameEvent.ENTITY_PLACE, (Entity) entityarmorstand);
diff --git a/src/main/java/net/minecraft/world/item/BoatItem.java b/src/main/java/net/minecraft/world/item/BoatItem.java
index 8998f6233a3135fda928469ae8bb7119e16eee1a..62a8600e0d684a147f4bfe027b3dd4f71bf665ad 100644
--- a/src/main/java/net/minecraft/world/item/BoatItem.java
+++ b/src/main/java/net/minecraft/world/item/BoatItem.java
@@ -67,6 +67,11 @@ public class BoatItem extends Item {
entityboat.setType(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())) { // Paper
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 e5b042f2445eb06fb8075ba539c836595814fa14..8cdede6a9698d6c99b4f08edc2a3403fec854f66 100644
--- a/src/main/java/net/minecraft/world/item/HangingEntityItem.java
+++ b/src/main/java/net/minecraft/world/item/HangingEntityItem.java
@@ -40,7 +40,7 @@ public class HangingEntityItem extends Item {
return InteractionResult.FAIL;
} else {
Level world = context.getLevel();
- Object object;
+ Entity object; // Purpur
if (this.type == EntityType.PAINTING) {
object = new Painting(world, blockposition1, enumdirection);
@@ -58,6 +58,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/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index ad100c889c43bfb702819028862ca49a68695032..4a567fcc95561bbd40cbbb9533cfe81149fb1874 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -101,8 +101,10 @@ public class PurpurWorldConfig {
}
public float armorstandStepHeight = 0.0F;
+ public boolean armorstandSetNameVisible = false;
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 int daytimeTicks = 12000;
@@ -358,6 +360,7 @@ public class PurpurWorldConfig {
public boolean entitiesCanUsePortals = true;
public boolean milkCuresBadOmen = true;
public boolean persistentTileEntityDisplayNames = false;
+ public boolean persistentDroppableEntityDisplayNames = false;
public double tridentLoyaltyVoidReturnHeight = 0.0D;
public double voidDamageHeight = -64.0D;
public double voidDamageDealt = 4.0D;
@@ -370,6 +373,7 @@ public class PurpurWorldConfig {
entitiesCanUsePortals = getBoolean("gameplay-mechanics.entities-can-use-portals", entitiesCanUsePortals);
milkCuresBadOmen = getBoolean("gameplay-mechanics.milk-cures-bad-omen", milkCuresBadOmen);
persistentTileEntityDisplayNames = getBoolean("gameplay-mechanics.persistent-tileentity-display-names-and-lore", persistentTileEntityDisplayNames);
+ 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);