Files
Purpur/patches/server/0126-Apply-display-names-from-item-forms-of-entities-to-e.patch
BillyGalbreath 1362f49b24 Updated Upstream (Paper, Tuinity, & Airplane)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
bca97a8f7 replace spaces in world key (touches #5397)
de94f6485 Refactor chat message composition (#5396)
e27f334bb [CI-SKIP] Fix makemcdevsrc.sh for nms relocations (#5389)
ae15e85da Updated Upstream (CraftBukkit)
26fe0ac5a Only set despawnTimer for Wandering Traders spawned by MobSpawnerTrader (#5391)
b748eb7b8 Fix VanillaMobGoalTest#testBukkitMap (#5390)
18dbbb578 [Auto] Updated Upstream (CraftBukkit)
fac9cc5d5 [CI-SKIP] Ignore .gitignore
087aa70e7 Deprecate ItemStack#setLore(List<String>) and ItemStack#getLore, add Component based alternatives
9889c651c apply fixup
c310f0a61 Updated Upstream (Bukkit/CraftBukkit)
f17560ab0 wtf is this t file -jmp
347f3a9b8 fix compile
700e9e6a5 rebase
cf4dc464a Revert de5f4e469...c270abe96
6870db613 script & POM fix
743c6533c Replace ** with * (BSD/macOS)
376d7b097 Don't remove the .java
fcb3fd42a Fix macOS/BSD support
8cfc05249 Link correctly
ba1031ca7 Rename work dir
c8d844ab7 Actually fix preloading this time
e62aa5e3e Fix class preloading
1c03cf898 It's mojang math, not minecraft math
1034873df Apply fixups
39b125771 Use revision file
956150da7 Welcome to 1.16.5-R0.2
ccb217c01 Change cache keys
0d217001c more work
f6d820f07 It compiles
0f78e9525 More work
1718f61bf Updated Upstream (CraftBukkit/Spigot)
b28d46114 Update scripts for NMS repackaging

Tuinity Changes:
9bdcb9b8e Delete work dir when running jar
6351d7ca7 Update Upstream (Paper)
932c199a6 Generate md-dev correctly
bf3e73778 Make packet limiter work from IDE
1686f3861 Fix packet limiter config
f40f7b425 Update README.md styling (#264)
da1c3ace5 GH Actions Changes (#213)
5f325ecf1 Update Upstream (Paper)
0f83fe48d Update Upstream (Paper)

Airplane Changes:
f94d39947 Merge pull request #18 from notOM3GA/upstream/nms-repackage
0fc622631 Force build for Flare update
08439d6a9 Update Upstream (Tuinity)
2021-03-21 23:00:01 -05:00

187 lines
11 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: jmp <jasonpenilla2@me.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/EntityArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/EntityArmorStand.java
index 89d3734489b65245e815376edf4e2d9baea1563a..43dc0925887e2e9e86445cccff57be7994ca0d58 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/EntityArmorStand.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/EntityArmorStand.java
@@ -588,7 +588,13 @@ public class EntityArmorStand extends EntityLiving {
}
private void f(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.world.purpurConfig.persistentDroppableEntityDisplayNames && this.hasCustomName()) {
+ armorStand.setName(this.getCustomName());
+ }
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(armorStand)); // CraftBukkit - add to drops
+ // Purpur end
this.g(damagesource);
}
diff --git a/src/main/java/net/minecraft/world/entity/decoration/EntityItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/EntityItemFrame.java
index 43152a6c70c9433d627a58051101530ddd693307..eb07db442c5a0da73249f4a02be7dacae0ff0e45 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/EntityItemFrame.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/EntityItemFrame.java
@@ -229,7 +229,13 @@ public class EntityItemFrame extends EntityHanging {
}
if (flag) {
- this.a((IMaterial) Items.ITEM_FRAME);
+ // Purpur start
+ final ItemStack itemFrame = new ItemStack(Items.ITEM_FRAME);
+ if (this.world.purpurConfig.persistentDroppableEntityDisplayNames && this.hasCustomName()) {
+ itemFrame.setName(this.getCustomName());
+ }
+ this.dropItem(itemFrame);
+ // Purpur end
}
if (!itemstack.isEmpty()) {
diff --git a/src/main/java/net/minecraft/world/entity/decoration/EntityPainting.java b/src/main/java/net/minecraft/world/entity/decoration/EntityPainting.java
index 3de0f21648ca60bdfcbc078bca896d51bf84e207..7517e861301e0c329c70aa6f2bf5aa40114b6589 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/EntityPainting.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/EntityPainting.java
@@ -108,7 +108,13 @@ public class EntityPainting extends EntityHanging {
}
}
- this.a((IMaterial) Items.PAINTING);
+ // Purpur start
+ final ItemStack painting = new ItemStack(Items.PAINTING);
+ if (this.world.purpurConfig.persistentDroppableEntityDisplayNames && this.hasCustomName()) {
+ painting.setName(this.getCustomName());
+ }
+ this.dropItem(painting);
+ // Purpur end
}
}
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java
index e5cda8c040c93639211dacbf5b0c7cd6a9df9e6d..9cd1a2a2a8db1d8daf7c712d6bd03fad1b048485 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/EntityBoat.java
@@ -201,7 +201,13 @@ public class EntityBoat extends Entity {
}
// CraftBukkit end
if (!flag && this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
- this.a((IMaterial) this.g());
+ // Purpur start
+ final ItemStack boat = new ItemStack(this.getBoatItem());
+ if (this.world.purpurConfig.persistentDroppableEntityDisplayNames && this.hasCustomName()) {
+ boat.setName(this.getCustomName());
+ }
+ this.dropItem(boat);
+ // Purpur end
}
this.die();
diff --git a/src/main/java/net/minecraft/world/item/ItemArmorStand.java b/src/main/java/net/minecraft/world/item/ItemArmorStand.java
index cd46df5485ebfd597ea72360a27872d46174ee19..245d3fe09feb9dc27b097642d40664a9f2377581 100644
--- a/src/main/java/net/minecraft/world/item/ItemArmorStand.java
+++ b/src/main/java/net/minecraft/world/item/ItemArmorStand.java
@@ -63,6 +63,14 @@ public class ItemArmorStand extends Item {
return EnumInteractionResult.FAIL;
}
// CraftBukkit end
+ // Purpur start
+ if (itemactioncontext.getWorld().purpurConfig.persistentDroppableEntityDisplayNames && itemactioncontext.getItemStack().hasName()) {
+ entityarmorstand.setCustomName(itemactioncontext.getItemStack().getName());
+ if (itemactioncontext.getWorld().purpurConfig.armorstandSetNameVisible) {
+ entityarmorstand.setCustomNameVisible(true);
+ }
+ }
+ // Purpur end
worldserver.addAllEntities(entityarmorstand); // Paper - moved down
world.playSound((EntityHuman) null, entityarmorstand.locX(), entityarmorstand.locY(), entityarmorstand.locZ(), SoundEffects.ENTITY_ARMOR_STAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F);
}
diff --git a/src/main/java/net/minecraft/world/item/ItemBoat.java b/src/main/java/net/minecraft/world/item/ItemBoat.java
index 1d812b3e27f87213afc3e441eb20ca984458ce2a..636a8bc76d436fc770b4e05a93f1991210b64230 100644
--- a/src/main/java/net/minecraft/world/item/ItemBoat.java
+++ b/src/main/java/net/minecraft/world/item/ItemBoat.java
@@ -65,6 +65,11 @@ public class ItemBoat extends Item {
entityboat.setType(this.b);
entityboat.yaw = entityhuman.yaw;
+ // Purpur start
+ if (world.purpurConfig.persistentDroppableEntityDisplayNames && itemstack.hasName()) {
+ entityboat.setCustomName(itemstack.getName());
+ }
+ // Purpur end
if (!world.getCubes(entityboat, entityboat.getBoundingBox().g(-0.1D))) {
return InteractionResultWrapper.fail(itemstack);
} else {
diff --git a/src/main/java/net/minecraft/world/item/ItemHanging.java b/src/main/java/net/minecraft/world/item/ItemHanging.java
index bbd3bb2d12e500d15485598783d39b0cb63a6d83..8e4c3304779cfccf7d45d4843f9c15bffce8ba07 100644
--- a/src/main/java/net/minecraft/world/item/ItemHanging.java
+++ b/src/main/java/net/minecraft/world/item/ItemHanging.java
@@ -39,7 +39,7 @@ public class ItemHanging extends Item {
return EnumInteractionResult.FAIL;
} else {
World world = itemactioncontext.getWorld();
- Object object;
+ Entity object; // Purpur
if (this.a == EntityTypes.PAINTING) {
object = new EntityPainting(world, blockposition1, enumdirection);
@@ -55,6 +55,11 @@ public class ItemHanging extends Item {
if (nbttagcompound != null) {
EntityTypes.a(world, entityhuman, (Entity) object, nbttagcompound);
+ // Purpur start
+ if (itemactioncontext.getWorld().purpurConfig.persistentDroppableEntityDisplayNames && itemactioncontext.getItemStack().hasName()) {
+ object.setCustomName(itemactioncontext.getItemStack().getName());
+ }
+ // Purpur end
}
if (((EntityHanging) object).survives()) {
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 81e2ccfa4f6cf6a4ad9236cf0ce94df8dc3ec5b6..132972755ac74838f3386e0fac5033380b71fce5 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -788,6 +788,7 @@ public final class ItemStack {
return this.getItem().h(this);
}
+ public ItemStack setName(@Nullable IChatBaseComponent component) { return this.a(component); } // Purpur - OBFHELPER
public ItemStack a(@Nullable IChatBaseComponent ichatbasecomponent) {
NBTTagCompound nbttagcompound = this.a("display");
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 2d4dea3c432fcf52dffd126f8bd910be03c20b1c..e1af622206f28186e7eebf135f3786c7a771b337 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -83,8 +83,10 @@ public class PurpurWorldConfig {
return PurpurConfig.config.getString("world-settings." + worldName + "." + path, PurpurConfig.config.getString("world-settings.default." + path));
}
+ public boolean armorstandSetNameVisible = false;
public float armorstandStepHeight = 0.0F;
private void armorstandSettings() {
+ armorstandSetNameVisible = getBoolean("gameplay-mechanics.armorstand.set-name-visible-when-placing-with-custom-name", armorstandSetNameVisible);
armorstandStepHeight = (float) getDouble("gameplay-mechanics.armorstand.step-height", armorstandStepHeight);
}
@@ -217,6 +219,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 int raidCooldownSeconds = 0;
@@ -229,6 +232,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);
raidCooldownSeconds = getInt("gameplay-mechanics.raid-cooldown-seconds", raidCooldownSeconds);