mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
160 lines
9.0 KiB
Diff
160 lines
9.0 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/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java
|
|
index edb0cd90e28016c44b0aaf5c9ed5d7bdbced5295..12ff824ffa81ea45f76337ec2b6d80b01047b698 100644
|
|
--- a/net/minecraft/world/entity/decoration/ArmorStand.java
|
|
+++ b/net/minecraft/world/entity/decoration/ArmorStand.java
|
|
@@ -618,6 +618,7 @@ public class ArmorStand extends LivingEntity {
|
|
private org.bukkit.event.entity.EntityDeathEvent brokenByPlayer(ServerLevel world, DamageSource damageSource) { // Paper
|
|
ItemStack itemstack = new ItemStack(Items.ARMOR_STAND);
|
|
|
|
+ if (this.level().purpurConfig.persistentDroppableEntityDisplayNames)
|
|
itemstack.set(DataComponents.CUSTOM_NAME, this.getCustomName());
|
|
this.drops.add(new DefaultDrop(itemstack, stack -> Block.popResource(this.level(), this.blockPosition(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior
|
|
return this.brokenByAnything(world, damageSource); // Paper
|
|
diff --git a/net/minecraft/world/entity/decoration/ItemFrame.java b/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
index 7d83ad8a61f6aafbc063506c1858554f9b700b70..fd1bd4fb88d1bd4a0734db463dc1be640c736d34 100644
|
|
--- a/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
+++ b/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
@@ -240,7 +240,13 @@ public class ItemFrame extends HangingEntity {
|
|
}
|
|
|
|
if (dropSelf) {
|
|
- this.spawnAtLocation(world, this.getFrameItemStack());
|
|
+ // Purpur start
|
|
+ final ItemStack itemFrame = this.getFrameItemStack();
|
|
+ if (!this.level().purpurConfig.persistentDroppableEntityDisplayNames) {
|
|
+ itemFrame.set(DataComponents.CUSTOM_NAME, null);
|
|
+ }
|
|
+ this.spawnAtLocation(world, itemFrame);
|
|
+ // Purpur end
|
|
}
|
|
|
|
if (!itemstack.isEmpty()) {
|
|
diff --git a/net/minecraft/world/entity/decoration/Painting.java b/net/minecraft/world/entity/decoration/Painting.java
|
|
index fd0e78a2318e3950d011c17358245e107b38154a..0fcab828e81176323cbdf16c0ec714d9a2846ae5 100644
|
|
--- a/net/minecraft/world/entity/decoration/Painting.java
|
|
+++ b/net/minecraft/world/entity/decoration/Painting.java
|
|
@@ -179,7 +179,13 @@ public class Painting extends HangingEntity implements VariantHolder<Holder<Pain
|
|
}
|
|
}
|
|
|
|
- this.spawnAtLocation(world, (ItemLike) Items.PAINTING);
|
|
+ // Purpur start
|
|
+ final ItemStack painting = new ItemStack((ItemLike) Items.PAINTING);
|
|
+ if (!this.level().purpurConfig.persistentDroppableEntityDisplayNames) {
|
|
+ painting.set(net.minecraft.core.component.DataComponents.CUSTOM_NAME, null);
|
|
+ }
|
|
+ this.spawnAtLocation(world, painting);
|
|
+ // Purpur end
|
|
}
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/vehicle/AbstractBoat.java b/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
index a301f32a292afb010f3888732e339897b176243d..1a4fb057025689a22b3dd05f531f0d8639d7e47b 100644
|
|
--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java
|
|
@@ -930,7 +930,13 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable {
|
|
|
|
@Override
|
|
public final ItemStack getPickResult() {
|
|
- return new ItemStack((ItemLike) this.dropItem.get());
|
|
+ // Purpur start
|
|
+ final ItemStack boat = new ItemStack((ItemLike) this.dropItem.get());
|
|
+ if (!this.level().purpurConfig.persistentDroppableEntityDisplayNames) {
|
|
+ boat.set(net.minecraft.core.component.DataComponents.CUSTOM_NAME, null);
|
|
+ }
|
|
+ return boat;
|
|
+ // Purpur end
|
|
}
|
|
|
|
public static enum Status {
|
|
diff --git a/net/minecraft/world/item/ArmorStandItem.java b/net/minecraft/world/item/ArmorStandItem.java
|
|
index cb4baebe22eeab17aed67a5ecc506b932fe2230b..c1a6734cc08de1c9fc413b1fa81a199ac9547ec2 100644
|
|
--- a/net/minecraft/world/item/ArmorStandItem.java
|
|
+++ b/net/minecraft/world/item/ArmorStandItem.java
|
|
@@ -59,6 +59,14 @@ public class ArmorStandItem extends Item {
|
|
return InteractionResult.FAIL;
|
|
}
|
|
// CraftBukkit end
|
|
+ // Purpur start
|
|
+ if (!world.purpurConfig.persistentDroppableEntityDisplayNames) {
|
|
+ entityarmorstand.setCustomName(null);
|
|
+ }
|
|
+ if (world.purpurConfig.armorstandSetNameVisible && entityarmorstand.getCustomName() != null) {
|
|
+ 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/net/minecraft/world/item/BoatItem.java b/net/minecraft/world/item/BoatItem.java
|
|
index e51ffd6c5047ee907a58f3029f0ea7fc66aedfa7..78d41d57df9cb61b295f1f54db1e1d62c13db701 100644
|
|
--- a/net/minecraft/world/item/BoatItem.java
|
|
+++ b/net/minecraft/world/item/BoatItem.java
|
|
@@ -71,6 +71,11 @@ public class BoatItem extends Item {
|
|
return InteractionResult.FAIL;
|
|
} else {
|
|
abstractboat.setYRot(user.getYRot());
|
|
+ // Purpur start
|
|
+ if (!world.purpurConfig.persistentDroppableEntityDisplayNames) {
|
|
+ abstractboat.setCustomName(null);
|
|
+ }
|
|
+ // Purpur end
|
|
if (!world.noCollision(abstractboat, abstractboat.getBoundingBox())) {
|
|
return InteractionResult.FAIL;
|
|
} else {
|
|
diff --git a/net/minecraft/world/item/HangingEntityItem.java b/net/minecraft/world/item/HangingEntityItem.java
|
|
index cdc17ad948d8ac5de62f14b1a561433d33211f32..44a7cee7df2927a923455e8cedaab59307b42506 100644
|
|
--- a/net/minecraft/world/item/HangingEntityItem.java
|
|
+++ b/net/minecraft/world/item/HangingEntityItem.java
|
|
@@ -75,6 +75,11 @@ public class HangingEntityItem extends Item {
|
|
|
|
if (!customdata.isEmpty()) {
|
|
EntityType.updateCustomEntityTag(world, entityhuman, (Entity) object, customdata);
|
|
+ // Purpur start
|
|
+ if (!world.purpurConfig.persistentDroppableEntityDisplayNames) {
|
|
+ ((Entity) object).setCustomName(null);
|
|
+ }
|
|
+ // 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 e363a93bdfcef7408ecdd5618b63c345ab9525b4..4efb19a627b3735fe2ded2108576d76296b605f3 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -98,8 +98,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;
|
|
@@ -115,6 +117,7 @@ public class PurpurWorldConfig {
|
|
public boolean entitiesCanUsePortals = true;
|
|
public int raidCooldownSeconds = 0;
|
|
public int animalBreedingCooldownSeconds = 0;
|
|
+ public boolean persistentDroppableEntityDisplayNames = true;
|
|
private void miscGameplayMechanicsSettings() {
|
|
useBetterMending = getBoolean("gameplay-mechanics.use-better-mending", useBetterMending);
|
|
boatEjectPlayersOnLand = getBoolean("gameplay-mechanics.boat.eject-players-on-land", boatEjectPlayersOnLand);
|
|
@@ -124,6 +127,8 @@ public class PurpurWorldConfig {
|
|
entitiesCanUsePortals = getBoolean("gameplay-mechanics.entities-can-use-portals", entitiesCanUsePortals);
|
|
raidCooldownSeconds = getInt("gameplay-mechanics.raid-cooldown-seconds", raidCooldownSeconds);
|
|
animalBreedingCooldownSeconds = getInt("gameplay-mechanics.animal-breeding-cooldown-seconds", animalBreedingCooldownSeconds);
|
|
+ persistentDroppableEntityDisplayNames = getBoolean("gameplay-mechanics.persistent-droppable-entity-display-names", persistentDroppableEntityDisplayNames);
|
|
+
|
|
}
|
|
|
|
public int daytimeTicks = 12000;
|