mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@5436d44 Deprecate several Keyed#getKey methods (#10357) PaperMC/Paper@a7f1dc6 Change online mode default for Velocity configuration (#10413) PaperMC/Paper@37db2d7 [ci skip] Update book page/char limit for book meta doc (#10415) PaperMC/Paper@526795b Update patches to handle vineflower decompiler (#10406) PaperMC/Paper@8fe90de [ci skip] Referenced InventoryDragEvent in documentation of InventoryClickEvent (#10395) PaperMC/Paper@46d462b Fix StackOverflowException thrown on shutdown (Fixes #10404) (#10408) PaperMC/Paper@f061e76 Fix hit criteria advancement triggered before changing state (#10409) PaperMC/Paper@3263470 Add color transition and clone functions to ParticleBuilder (#10342) PaperMC/Paper@4445d23 Deprecate ItemStack#setType & add ItemStack#withType (#10290)
169 lines
9.7 KiB
Diff
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 8cb248a185d880bf82ea4746341fe3db5dc89459..aca5e7a2b0eab93c613b03834509366f7119ec03 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
|
@@ -607,7 +607,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 c34701f95580e4cf45fe086115563127432a28c5..2363d9eaad655389c7b7d67d545ef8025f550431 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
@@ -268,7 +268,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 10ee43de05d9f4e0ab980ee5069fe59c0f137403..af07901daaf6a0e5cd7e4b1e07fb491566807932 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/Painting.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/Painting.java
|
|
@@ -155,7 +155,13 @@ public class Painting extends HangingEntity implements VariantHolder<Holder<Pain
|
|
return;
|
|
}
|
|
|
|
- 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 96c6b4c37a556da8a4c6807db121c44c3f1b0729..81e0930acccd014e977b88d22e10346627f0edb0 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
|
@@ -968,7 +968,13 @@ public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> {
|
|
|
|
@Override
|
|
public ItemStack getPickResult() {
|
|
- return new ItemStack(this.getDropItem());
|
|
+ // Purpur start
|
|
+ final ItemStack boat = new ItemStack(this.getDropItem());
|
|
+ if (this.level().purpurConfig.persistentDroppableEntityDisplayNames && this.hasCustomName()) {
|
|
+ boat.setHoverName(this.getCustomName());
|
|
+ }
|
|
+ return boat;
|
|
+ // Purpur end
|
|
}
|
|
|
|
public static enum Type implements StringRepresentable {
|
|
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 67a5a201d0b26ca7b27e6d0c3ffb9f8b6e16bce0..ec3d60b561de45349b705b7f14592be930af4b91 100644
|
|
--- a/src/main/java/net/minecraft/world/item/BoatItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/BoatItem.java
|
|
@@ -71,6 +71,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 4e2619e07b177cd8ce732e58da538de89b627098..2d9429ef5884f0ee542c2fb197ae263c2e5d6577 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -97,8 +97,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;
|
|
@@ -111,6 +113,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;
|
|
@@ -122,6 +125,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);
|