mirror of
https://github.com/PurpurMC/Purpur.git
synced 2025-02-17 13:00:04 +08:00
175 lines
9.9 KiB
Diff
175 lines
9.9 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 ba9e851eebb25edf94efe8dfbd591e265ac3ac5a..9dcb46959c723723a369cde50427cbee0349f5a1 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
|
@@ -594,7 +594,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 d2a77b4ca343d19e1c70afe3f3906a9bd53d0eec..2a3ec299283c2cc039877eade6e2ddee8f3812ea 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
@@ -267,7 +267,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 18697701ca6406b2a74f190b22d5b276359547d0..ee72748a8c07587c95bdce8f982fcdd73e8fd8f4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/Painting.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/Painting.java
|
|
@@ -143,7 +143,13 @@ public class Painting extends HangingEntity {
|
|
}
|
|
}
|
|
|
|
- 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 539c9d60cecb63fb2b0858951ff58cc0ea26c446..ed260c5f8cdf9027ad95c81cb84bb91879647836 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
|
@@ -220,7 +220,13 @@ public class Boat extends Entity {
|
|
}
|
|
|
|
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 af81ba310dbd7fdbdccdd0cc74b7c085ad54027f..3e529ea7548a2a6617f70a3c3ad2d8f482c1b5e5 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ArmorStandItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ArmorStandItem.java
|
|
@@ -60,6 +60,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 447e16f06c1686c2a2c6c12c856bdb937a5d050f..c923ca8c405e415999148c0148d2d8238097692d 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.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())) {
|
|
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 4c5671cd4c26c23e61b2196577c554f504a03c55..678e0cb7e5b704ce01eda96b2d74694d0e0b7614 100644
|
|
--- a/src/main/java/net/minecraft/world/item/HangingEntityItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/HangingEntityItem.java
|
|
@@ -41,7 +41,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);
|
|
@@ -65,6 +65,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 834dd3b5244c1f0f0ab0b6b85fd692b315c5b929..1966cdca08f38f440b033a20c4ecb4c3e79d7482 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -99,8 +99,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 boolean arrowMovementResetsDespawnCounter = true;
|
|
@@ -113,6 +115,7 @@ public class PurpurWorldConfig {
|
|
public boolean disableDropsOnCrammingDeath = false;
|
|
public boolean entitiesCanUsePortals = true;
|
|
public boolean milkCuresBadOmen = true;
|
|
+ public boolean persistentDroppableEntityDisplayNames = false;
|
|
public double tridentLoyaltyVoidReturnHeight = 0.0D;
|
|
public double voidDamageHeight = -64.0D;
|
|
public double voidDamageDealt = 4.0D;
|
|
@@ -124,6 +127,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);
|