Files
Purpur/patches/server/0133-Apply-display-names-from-item-forms-of-entities-to-e.patch
jmp c7b279fe1b Updated Upstream (Paper & Tuinity)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
05af2837c [CI-SKIP] Improved the annotation test output
586966949 abstract custom set tags, add entity tags
c7667378e Added PlayerLoomPatternSelectEvent
00972e80d Reimplement GS4QueryEvent
544c5c278 Re-add coral block tags (#4987)
7d56c8deb Added PlayerLecternPageChangeEvent
c7cdf255b Add BlockFailedDispenseEvent
c8a8d6fbe Added world settings for mobs picking up loot
91eda5bd3 Added ServerResourcesReloadedEvent
be81b4f5c Add a Enchantable MaterialTag
975d18703 Add doors to material tags
d075e748e colorful itemdump
f3ba3dee0 Added WorldGameRuleChangeEvent
086d20118 Guardian beam workaround
b63c890ec Support spawning item stacks
d7d74c552 added height config for bamboo
7878e3bc2 Use setAmount for Recipe Amount
50e70697b Add EntityLoadCrossbowEvent
f344e092c Add Anti-Xray bypass permission
9fd31e675 fix for nerfed slime mobs splitting
4a7962cd1 Zombie API - breaking doors
5650a41f5 Fix interact event not being called in adventure
2c9ed4335 Add PlayerFlowerPotManipulateEvent
1f32290b6 [Auto] Updated Upstream (CraftBukkit)
d87694a20 Redact Velocity forwarding secret properly (#4980)
24a0b0206 [Auto] Updated Upstream (CraftBukkit)
7681042ef [Auto] Updated Upstream (Bukkit/CraftBukkit)
7dea3dba6 [Auto] Updated Upstream (CraftBukkit)
4b3792920 JavaDoc fixes
f13b4727e Allow disabling mob spawner spawn egg transformation
525b50737 Cache burn durations
2c37d1077 Optimized tick ready check
b4000b01a Add API to get the Material of Boats and Minecarts
f1317386d Fix sign lazy initialisation
9f61759d9 Updated Upstream (CraftBukkit/Spigot) (#4972)
aaff430b6 [CI-SKIP] Use GitHub Actions for build status
9f4055d99 Fix harming potion dupe
7bfb781ff Additional Block Material API's
0eaffd008 Micro Optimize DataBits

Tuinity Changes:
9e5cabb6e Port starlight changes
2021-01-04 15:21:27 -08:00

221 lines
12 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/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
index faa221038df6bed02a2433855ed7c7e0f89c6024..6efe59e0385e144c59804e9e5e18e6910b1f6667 100644
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
@@ -553,7 +553,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/server/EntityBoat.java b/src/main/java/net/minecraft/server/EntityBoat.java
index 4f95976f9a852fa89cedd1fe81d2077fe5d118ee..0254a9e971b2dd93436a38815bfd1dcca9a2ec67 100644
--- a/src/main/java/net/minecraft/server/EntityBoat.java
+++ b/src/main/java/net/minecraft/server/EntityBoat.java
@@ -155,7 +155,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/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index 4b524c2165e95a4d3d78b84b7b15416a4ea7d622..d1ed9856d3362e1bed37d60c268b7e91c404d25d 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -1367,7 +1367,13 @@ public abstract class EntityInsentient extends EntityLiving {
this.by = null;
if (!this.world.isClientSide && flag1) {
this.forceDrops = true; // CraftBukkit
- this.a((IMaterial) Items.LEAD);
+ // Purpur start
+ final ItemStack lead = new ItemStack(Items.LEAD);
+ if (this.world.purpurConfig.persistentDroppableEntityDisplayNames && this.hasCustomName()) {
+ lead.setName(this.getCustomName());
+ }
+ this.dropItem(lead);
+ // Purpur end
this.forceDrops = false; // CraftBukkit
}
@@ -1443,7 +1449,13 @@ public abstract class EntityInsentient extends EntityLiving {
}
if (this.ticksLived > 100) {
- this.a((IMaterial) Items.LEAD);
+ // Purpur start
+ final ItemStack lead = new ItemStack(Items.LEAD);
+ if (this.world.purpurConfig.persistentDroppableEntityDisplayNames && this.hasCustomName()) {
+ lead.setName(this.getCustomName());
+ }
+ this.dropItem(lead);
+ // Purpur end
this.by = null;
}
}
diff --git a/src/main/java/net/minecraft/server/EntityItemFrame.java b/src/main/java/net/minecraft/server/EntityItemFrame.java
index 661db537f6ac2b5a80e2e40a25966a2e3039199d..a43a42aa696994a17dda790d01d09e0abdaade00 100644
--- a/src/main/java/net/minecraft/server/EntityItemFrame.java
+++ b/src/main/java/net/minecraft/server/EntityItemFrame.java
@@ -199,7 +199,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/server/EntityPainting.java b/src/main/java/net/minecraft/server/EntityPainting.java
index 4b7cd7c59fefbd56d38e0301b08d06ce92c9d8a2..d01fc8b11026536be30c8149aca253280524811f 100644
--- a/src/main/java/net/minecraft/server/EntityPainting.java
+++ b/src/main/java/net/minecraft/server/EntityPainting.java
@@ -92,7 +92,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/server/ItemArmorStand.java b/src/main/java/net/minecraft/server/ItemArmorStand.java
index c9a5d3b583076cf8f2f32b12c142beb3f5e22dc0..315faee9e35d27071a62ea1d335dfbe5351582ca 100644
--- a/src/main/java/net/minecraft/server/ItemArmorStand.java
+++ b/src/main/java/net/minecraft/server/ItemArmorStand.java
@@ -43,6 +43,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/server/ItemBoat.java b/src/main/java/net/minecraft/server/ItemBoat.java
index 0580ce55ec945b5bc6ce8c5d0cee13b03ccc7d1a..6183da7ad2a458f4ada288ec82fdaf097d771122 100644
--- a/src/main/java/net/minecraft/server/ItemBoat.java
+++ b/src/main/java/net/minecraft/server/ItemBoat.java
@@ -52,6 +52,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/server/ItemHanging.java b/src/main/java/net/minecraft/server/ItemHanging.java
index a3eaeeda875d96fe4b047bd6bf993018722c96b9..f2f800087adb0238b4b672b9f6f4c8c4836f2891 100644
--- a/src/main/java/net/minecraft/server/ItemHanging.java
+++ b/src/main/java/net/minecraft/server/ItemHanging.java
@@ -26,7 +26,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);
@@ -42,6 +42,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/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
index 623bcb93cbdf0f67ee999104936f9d60c5228037..eb115a9c2aac9abe28d36f6284ca84f694a4898d 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -738,6 +738,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 ef0c2320780c623df4dd638c9272110a2fb2e530..458aa1882da2015928c334e0f40b14ee36ba667d 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);
}
@@ -199,6 +201,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;
@@ -211,6 +214,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);