remove custom names from non-living

This commit is contained in:
Sen 2025-08-02 20:53:00 +02:00
parent f29623eec6
commit 50fec6dd56
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
46 changed files with 290 additions and 511 deletions

View file

@ -183,12 +183,12 @@ public class DamageSource
EntityLiving killer = victim.getAttackingEntity();
// String s = this.display;
// String s1 = s + "Player";
return killer != null ? String.format(this.displayExtra, victim.getColoredName(this.color), killer.getColoredName(this.color)) : String.format(this.display, victim.getColoredName(this.color));
return killer != null ? String.format(this.displayExtra, victim.getEnclosedName(this.color), killer.getEnclosedName(this.color)) : String.format(this.display, victim.getEnclosedName(this.color));
}
public String getKillMessage(EntityLiving victim)
{
return String.format(this.displayKill, victim.getColoredName(this.color));
return String.format(this.displayKill, victim.getEnclosedName(this.color));
}
/**

View file

@ -150,7 +150,6 @@ public abstract class Entity
this.dataWatcher = new DataWatcher(this);
this.dataWatcher.addObject(0, Byte.valueOf((byte)0));
this.dataWatcher.addObject(1, "");
this.entityInit();
}
@ -1501,12 +1500,6 @@ public abstract class Entity
// tagCompund.setBoolean("Invulnerable", this.invulnerable);
// tagCompund.setInteger("PortalCooldown", this.portalTimer);
if (this.getCustomNameTag() != null && this.getCustomNameTag().length() > 0)
{
tag.setString("CustomName", this.getCustomNameTag());
// tagCompund.setBoolean("CustomNameVisible", this.getAlwaysRenderNameTag());
}
// if (this.isSilent())
// {
// tagCompund.setBoolean("Silent", this.isSilent());
@ -1573,11 +1566,6 @@ public abstract class Entity
this.setPosition(this.posX, this.posY, this.posZ);
this.setRotation(this.rotYaw, this.rotPitch);
if (tag.hasString("CustomName") && tag.getString("CustomName").length() > 0)
{
this.setCustomNameTag(tag.getString("CustomName"));
}
// this.setAlwaysRenderNameTag(tagCompund.getBoolean("CustomNameVisible"));
// this.setSilent(tagCompund.getBoolean("Silent"));
this.ignoreFall = tag.getBool("IgnoreFall");
@ -2166,28 +2154,6 @@ public abstract class Entity
this.fallDistance = 0.0F;
}
/**
* Get the name of this object. For players this returns their username
*/
public String getTypeName()
{
if (this.hasCustomName())
{
return this.getCustomNameTag();
}
else
{
String s = EntityRegistry.getEntityString(this);
if (s == null)
{
s = "generic";
}
return EntityRegistry.getEntityName(s);
}
}
/**
* Return the Entity parts making up this Entity (currently only for dragons)
*/
@ -2378,27 +2344,27 @@ public abstract class Entity
return true;
}
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public final String getTypeName()
{
return EntityRegistry.getEntityName(EntityRegistry.getEntityString(this));
}
public String getLabel()
{
return null;
}
public String getName()
{
return this.getTypeName();
// this.formatComponent(comp);
// return comp;
}
public String getDisplayName()
{
return this.hasCustomName() ? this.getName() : null;
}
public final String getCommandName()
public final String getRawName()
{
return Color.stripCodes(this.getName());
}
public final String getColoredName(Color reset)
public final String getEnclosedName(Color reset)
{
return Color.DARK_GRAY + "[" + this.getName() + Color.DARK_GRAY + "]" + (reset == null ? Color.RESET : reset);
}
@ -2408,27 +2374,6 @@ public abstract class Entity
// return comp;
// }
/**
* Sets the custom name tag for this entity
*/
public void setCustomNameTag(String name)
{
this.dataWatcher.updateObject(1, name);
}
public String getCustomNameTag()
{
return this.dataWatcher.getWatchableObjectString(1);
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return this.dataWatcher.getWatchableObjectString(1).length() > 0;
}
// public void setAlwaysRenderNameTag(boolean alwaysRenderNameTag)
// {
// this.dataWatcher.updateObject(3, Byte.valueOf((byte)(alwaysRenderNameTag ? 1 : 0)));

View file

@ -56,7 +56,7 @@ public class EntityDamageSource extends DamageSource
ItemStack item = this.damageSourceEntity instanceof EntityNPC ? ((EntityNPC)this.damageSourceEntity).getHeldItem() : null;
// String s = "death.attack." + this.damageType;
// String s1 = s + "Item";
return item != null ? String.format(this.displayExtra, victim.getColoredName(this.color), this.damageSourceEntity.getColoredName(this.color), item.getColoredName(this.color)) : String.format(this.display, victim.getColoredName(this.color), this.damageSourceEntity.getColoredName(this.color));
return item != null ? String.format(this.displayExtra, victim.getEnclosedName(this.color), this.damageSourceEntity.getEnclosedName(this.color), item.getColoredName(this.color)) : String.format(this.display, victim.getEnclosedName(this.color), this.damageSourceEntity.getEnclosedName(this.color));
}
// /**

View file

@ -37,10 +37,10 @@ public class EntityDamageSourceIndirect extends EntityDamageSource
*/
public String getDeathMessage(EntityLiving victim)
{
String killer = this.indirectEntity == null ? this.damageSourceEntity.getColoredName(this.color) : this.indirectEntity.getColoredName(this.color);
String killer = this.indirectEntity == null ? this.damageSourceEntity.getEnclosedName(this.color) : this.indirectEntity.getEnclosedName(this.color);
ItemStack item = this.indirectEntity instanceof EntityNPC ? ((EntityNPC)this.indirectEntity).getHeldItem() : null;
// String s = "death.attack." + this.damageType;
// String s1 = s + "Item";
return item != null ? String.format(this.displayExtra, victim.getColoredName(this.color), killer, item.getColoredName(this.color)) : String.format(this.display, victim.getColoredName(this.color), killer);
return item != null ? String.format(this.displayExtra, victim.getEnclosedName(this.color), killer, item.getColoredName(this.color)) : String.format(this.display, victim.getEnclosedName(this.color), killer);
}
}

View file

@ -337,12 +337,9 @@ public class EntityCat extends EntityTameable
// return false;
// }
/**
* Get the name of this object. For players this returns their username
*/
public String getTypeName()
public String getName()
{
return this.hasCustomName() ? this.getCustomNameTag() : (this.isTamed() ? "Katze" : super.getTypeName());
return this.getAlignment().color + (this.hasCustomName() ? this.getCustomNameTag() : (this.isTamed() ? "Katze" : this.getTypeName()));
}
public void setTamed(boolean tamed)

View file

@ -140,14 +140,11 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
return this.dataWatcher.getWatchableObjectInt(20);
}
/**
* Get the name of this object. For players this returns their username
*/
public String getTypeName()
public String getName()
{
if (this.hasCustomName())
{
return this.getCustomNameTag();
return this.getAlignment().color + this.getCustomNameTag();
}
else
{
@ -157,13 +154,13 @@ public class EntityHorse extends EntityAnimal implements IInvBasic {
{
case 0:
default:
return "Pferd";
return this.getAlignment().color + "Pferd";
case 1:
return "Esel";
return this.getAlignment().color + "Esel";
case 2:
return "Maultier";
return this.getAlignment().color + "Maultier";
}
}
}

View file

@ -296,8 +296,8 @@ public class EntityRabbit extends EntityAnimal {
this.dataWatcher.updateObject(18, Byte.valueOf((byte)type));
}
public String getTypeName() {
return !this.hasCustomName() && this.getRabbitType() == 99 ? "Killer-Kaninchen" : super.getTypeName();
public String getName() {
return !this.hasCustomName() && this.getRabbitType() == 99 ? this.getAlignment().color + "Killer-Kaninchen" : super.getName();
}
public Object onInitialSpawn(Object livingdata) {

View file

@ -19,7 +19,6 @@ import common.world.World;
public abstract class EntityCart extends Entity
{
private boolean isInReverse;
private String entityName;
/** Minecart rotational logic matrix */
private static final int[][][] matrix = new int[][][] {{{0, 0, -1}, {0, 0, 1}}, {{ -1, 0, 0}, {1, 0, 0}}, {{ -1, -1, 0}, {1, 0, 0}}, {{ -1, 0, 0}, {1, -1, 0}}, {{0, 0, -1}, {0, -1, 1}}, {{0, -1, -1}, {0, 0, 1}}, {{0, 0, 1}, {1, 0, 0}}, {{0, 0, 1}, { -1, 0, 0}}, {{0, 0, -1}, { -1, 0, 0}}, {{0, 0, -1}, {1, 0, 0}}};
@ -155,12 +154,6 @@ public abstract class EntityCart extends Entity
if (Vars.objectDrop)
{
ItemStack itemstack = new ItemStack(Items.minecart, 1);
if (this.entityName != null)
{
itemstack.setStackDisplayName(this.entityName);
}
this.entityDropItem(itemstack, 0.0F);
}
}
@ -716,18 +709,10 @@ public abstract class EntityCart extends Entity
protected void readEntity(TagObject tagCompund)
{
if (tagCompund.hasString("CustomName") && tagCompund.getString("CustomName").length() > 0)
{
this.entityName = tagCompund.getString("CustomName");
}
}
protected void writeEntity(TagObject tagCompound)
{
if (this.entityName != null && this.entityName.length() > 0)
{
tagCompound.setString("CustomName", this.entityName);
}
}
/**
@ -910,52 +895,6 @@ public abstract class EntityCart extends Entity
{
return 6;
}
/**
* Sets the custom name tag for this entity
*/
public void setCustomNameTag(String name)
{
this.entityName = name;
}
/**
* Get the name of this object. For players this returns their username
*/
public String getTypeName()
{
return this.entityName != null ? this.entityName : super.getTypeName();
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return this.entityName != null;
}
public String getCustomNameTag()
{
return this.entityName;
}
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public String getName()
{
if (this.hasCustomName())
{
return this.entityName;
// this.formatComponent(chatcomponenttext);
// return chatcomponenttext;
}
else
{
return super.getName();
}
}
public int getTrackingRange() {
return 80;

View file

@ -445,15 +445,10 @@ public class EntityItem extends Entity
}
}
/**
* Get the name of this object. For players this returns their username
*/
public String getTypeName()
public String getName()
{
if(this.hasCustomName())
return this.getCustomNameTag();
ItemStack stack = this.getEntityItem();
return super.getTypeName() + " (" + (stack.isStacked() ? stack.getSize() + " * " : "") + stack.getItem().getDisplay() + ")";
return this.getTypeName() + " (" + (stack.isStacked() ? stack.getSize() + " * " : "") + stack.getItem().getDisplay() + ")";
}
/**
@ -596,7 +591,7 @@ public class EntityItem extends Entity
return this.getEntityItem().getItem().isMagnetic();
}
public String getDisplayName()
public String getLabel()
{
ItemStack stack = this.getEntityItem();
if(!stack.isStacked())

View file

@ -7,75 +7,52 @@ import common.init.Items;
import common.item.Item;
import common.world.World;
public class EntityMinecart extends EntityCart
{
public EntityMinecart(World worldIn)
{
super(worldIn);
}
public class EntityMinecart extends EntityCart {
public EntityMinecart(World worldIn) {
super(worldIn);
}
public EntityMinecart(World worldIn, double x, double y, double z)
{
super(worldIn, x, y, z);
}
public EntityMinecart(World worldIn, double x, double y, double z) {
super(worldIn, x, y, z);
}
/**
* First layer of player interaction
*/
public boolean interactFirst(EntityNPC playerIn)
{
// if (this.passenger != null && this.passenger.isPlayer() && this.passenger != playerIn)
// {
// return true;
// }
// else
if (this.passenger != null && this.passenger != playerIn)
{
return false;
}
else
{
if (!this.worldObj.client)
{
playerIn.mountEntity(this);
}
public boolean interactFirst(EntityNPC playerIn) {
if(this.passenger != null && this.passenger != playerIn) {
return false;
}
else {
if(!this.worldObj.client) {
playerIn.mountEntity(this);
}
return true;
}
}
return true;
}
}
/**
* Called every tick the minecart is on an activator rail. Args: x, y, z, is the rail receiving power
*/
public void onActivatorRailPass(int x, int y, int z, boolean receivingPower)
{
if (receivingPower)
{
if (this.passenger != null)
{
this.passenger.mountEntity((Entity)null);
}
public void onActivatorRailPass(int x, int y, int z, boolean receivingPower) {
if(receivingPower) {
if(this.passenger != null) {
this.passenger.mountEntity((Entity)null);
}
if (this.getRollingAmplitude() == 0)
{
this.setRollingDirection(-this.getRollingDirection());
this.setRollingAmplitude(10);
this.setDamage(50);
this.setBeenAttacked();
}
}
}
if(this.getRollingAmplitude() == 0) {
this.setRollingDirection(-this.getRollingDirection());
this.setRollingAmplitude(10);
this.setDamage(50);
this.setBeenAttacked();
}
}
}
public boolean canRide()
{
return true;
}
public Item getItem() {
return Items.minecart;
}
public EntityType getType() {
return EntityType.VEHICLE;
}
public boolean canRide() {
return true;
}
public Item getItem() {
return Items.minecart;
}
public EntityType getType() {
return EntityType.VEHICLE;
}
}

View file

@ -19,212 +19,151 @@ import common.world.Explosion;
import common.world.State;
import common.world.World;
public class EntityTntCart extends EntityCart
{
private int minecartTNTFuse = -1;
public class EntityTntCart extends EntityCart {
private int minecartTNTFuse = -1;
public EntityTntCart(World worldIn)
{
super(worldIn);
}
public EntityTntCart(World worldIn) {
super(worldIn);
}
public EntityTntCart(World worldIn, double x, double y, double z)
{
super(worldIn, x, y, z);
}
public EntityTntCart(World worldIn, double x, double y, double z) {
super(worldIn, x, y, z);
}
public boolean canRide()
{
return false;
}
public boolean canRide() {
return false;
}
public State getDisplayTile()
{
return Blocks.tnt.getState();
}
public State getDisplayTile() {
return Blocks.tnt.getState();
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
public void onUpdate() {
super.onUpdate();
if (this.minecartTNTFuse > 0)
{
--this.minecartTNTFuse;
this.worldObj.clientParticle(ParticleType.SMOKE, this.posX, this.posY + 0.5D, this.posZ);
}
else if (this.minecartTNTFuse == 0)
{
this.explodeCart(this.motionX * this.motionX + this.motionZ * this.motionZ);
}
if(this.minecartTNTFuse > 0) {
--this.minecartTNTFuse;
this.worldObj.clientParticle(ParticleType.SMOKE, this.posX, this.posY + 0.5D, this.posZ);
}
else if(this.minecartTNTFuse == 0) {
this.explodeCart(this.motionX * this.motionX + this.motionZ * this.motionZ);
}
if (this.collidedHorizontally)
{
double d0 = this.motionX * this.motionX + this.motionZ * this.motionZ;
if(this.collidedHorizontally) {
double d0 = this.motionX * this.motionX + this.motionZ * this.motionZ;
if (d0 >= 0.009999999776482582D)
{
this.explodeCart(d0);
}
}
}
if(d0 >= 0.009999999776482582D) {
this.explodeCart(d0);
}
}
}
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource source, int amount)
{
Entity entity = source.getSourceOfDamage();
public boolean attackEntityFrom(DamageSource source, int amount) {
Entity entity = source.getSourceOfDamage();
if (entity instanceof EntityArrow)
{
EntityArrow entityarrow = (EntityArrow)entity;
if(entity instanceof EntityArrow) {
EntityArrow entityarrow = (EntityArrow)entity;
if (entityarrow.isBurning())
{
this.explodeCart(entityarrow.motionX * entityarrow.motionX + entityarrow.motionY * entityarrow.motionY + entityarrow.motionZ * entityarrow.motionZ);
}
}
if(entityarrow.isBurning()) {
this.explodeCart(entityarrow.motionX * entityarrow.motionX + entityarrow.motionY * entityarrow.motionY + entityarrow.motionZ * entityarrow.motionZ);
}
}
return super.attackEntityFrom(source, amount);
}
return super.attackEntityFrom(source, amount);
}
public void killMinecart(DamageSource source)
{
super.killMinecart(source);
double d0 = this.motionX * this.motionX + this.motionZ * this.motionZ;
public void killMinecart(DamageSource source) {
super.killMinecart(source);
double d0 = this.motionX * this.motionX + this.motionZ * this.motionZ;
if (!source.isExplosion() && Vars.objectDrop)
{
this.entityDropItem(new ItemStack(Items.tnt), 0.0F);
}
if(!source.isExplosion() && Vars.objectDrop) {
this.entityDropItem(new ItemStack(Items.tnt), 0.0F);
}
if (source.isFireDamage() || source.isExplosion() || d0 >= 0.009999999776482582D)
{
this.explodeCart(d0);
}
}
if(source.isFireDamage() || source.isExplosion() || d0 >= 0.009999999776482582D) {
this.explodeCart(d0);
}
}
/**
* Makes the minecart explode.
*/
protected void explodeCart(double p_94103_1_)
{
if (!this.worldObj.client)
{
double d0 = Math.sqrt(p_94103_1_);
protected void explodeCart(double p_94103_1_) {
if(!this.worldObj.client) {
double d0 = Math.sqrt(p_94103_1_);
if (d0 > 5.0D)
{
d0 = 5.0D;
}
if(d0 > 5.0D) {
d0 = 5.0D;
}
this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(4.0D + this.rand.doublev() * 1.5D * d0), true);
this.setDead();
}
}
this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(4.0D + this.rand.doublev() * 1.5D * d0), true);
this.setDead();
}
}
public void fall(float distance, float damageMultiplier)
{
if (distance >= 3.0F)
{
float f = distance / 10.0F;
this.explodeCart((double)(f * f));
}
public void fall(float distance, float damageMultiplier) {
if(distance >= 3.0F) {
float f = distance / 10.0F;
this.explodeCart((double)(f * f));
}
super.fall(distance, damageMultiplier);
}
super.fall(distance, damageMultiplier);
}
/**
* Called every tick the minecart is on an activator rail. Args: x, y, z, is the rail receiving power
*/
public void onActivatorRailPass(int x, int y, int z, boolean receivingPower)
{
if (receivingPower && this.minecartTNTFuse < 0)
{
this.ignite();
}
}
public void onActivatorRailPass(int x, int y, int z, boolean receivingPower) {
if(receivingPower && this.minecartTNTFuse < 0) {
this.ignite();
}
}
@Clientside
public void handleStatusUpdate(byte id)
{
if (id == 10)
{
this.ignite();
}
else
{
super.handleStatusUpdate(id);
}
}
@Clientside
public void handleStatusUpdate(byte id) {
if(id == 10) {
this.ignite();
}
else {
super.handleStatusUpdate(id);
}
}
/**
* Ignites this TNT cart.
*/
public void ignite()
{
this.minecartTNTFuse = 80;
public void ignite() {
this.minecartTNTFuse = 80;
if (!this.worldObj.client)
{
this.worldObj.setEntityState(this, (byte)10);
if(!this.worldObj.client) {
this.worldObj.setEntityState(this, (byte)10);
this.worldObj.playSoundAtEntity(this, SoundEvent.FUSE, 1.0F);
}
}
// if (!this.isSilent())
// {
this.worldObj.playSoundAtEntity(this, SoundEvent.FUSE, 1.0F);
// }
}
}
public int getFuseTicks() {
return this.minecartTNTFuse;
}
/**
* Gets the remaining fuse time in ticks.
*/
public int getFuseTicks()
{
return this.minecartTNTFuse;
}
public boolean isIgnited() {
return this.minecartTNTFuse > -1;
}
/**
* Returns true if the TNT minecart is ignited.
*/
public boolean isIgnited()
{
return this.minecartTNTFuse > -1;
}
public float getExplosionResistance(Explosion explosionIn, World worldIn, BlockPos pos, State blockStateIn) {
return !this.isIgnited() || !BlockRail.isRailBlock(blockStateIn) && !BlockRail.isRailBlock(worldIn, pos.up()) ? super.getExplosionResistance(explosionIn, worldIn, pos, blockStateIn) : 0.0F;
}
/**
* Explosion resistance of a block relative to this entity
*/
public float getExplosionResistance(Explosion explosionIn, World worldIn, BlockPos pos, State blockStateIn)
{
return !this.isIgnited() || !BlockRail.isRailBlock(blockStateIn) && !BlockRail.isRailBlock(worldIn, pos.up()) ? super.getExplosionResistance(explosionIn, worldIn, pos, blockStateIn) : 0.0F;
}
public boolean verifyExplosion(Explosion explosionIn, World worldIn, BlockPos pos, State blockStateIn, float p_174816_5_) {
return !this.isIgnited() || !BlockRail.isRailBlock(blockStateIn) && !BlockRail.isRailBlock(worldIn, pos.up()) ? super.verifyExplosion(explosionIn, worldIn, pos, blockStateIn, p_174816_5_)
: false;
}
public boolean verifyExplosion(Explosion explosionIn, World worldIn, BlockPos pos, State blockStateIn, float p_174816_5_)
{
return !this.isIgnited() || !BlockRail.isRailBlock(blockStateIn) && !BlockRail.isRailBlock(worldIn, pos.up()) ? super.verifyExplosion(explosionIn, worldIn, pos, blockStateIn, p_174816_5_) : false;
}
protected void readEntity(TagObject tagCompund) {
super.readEntity(tagCompund);
this.minecartTNTFuse = tagCompund.getInt("TNTFuse");
}
protected void readEntity(TagObject tagCompund)
{
super.readEntity(tagCompund);
this.minecartTNTFuse = tagCompund.getInt("TNTFuse");
}
protected void writeEntity(TagObject tagCompound) {
super.writeEntity(tagCompound);
tagCompound.setInt("TNTFuse", this.minecartTNTFuse);
}
protected void writeEntity(TagObject tagCompound)
{
super.writeEntity(tagCompound);
tagCompound.setInt("TNTFuse", this.minecartTNTFuse);
}
public Item getItem() {
return Items.minecart;
}
public EntityType getType() {
return EntityType.EXPLOSIVE;
}
public Item getItem() {
return Items.minecart;
}
public EntityType getType() {
return EntityType.EXPLOSIVE;
}
}

View file

@ -52,7 +52,7 @@ public class EntityXp extends Entity implements IObjectData
this.motionZ = (double)((float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D) * 2.0F);
this.xpValue = expValue;
if(!worldIn.client)
this.setCustomNameTag("" + this.xpValue);
this.setAmount(this.xpValue);
}
/**
@ -72,6 +72,17 @@ public class EntityXp extends Entity implements IObjectData
protected void entityInit()
{
this.dataWatcher.addObject(1, 1);
}
public void setAmount(int amount)
{
this.dataWatcher.updateObject(1, amount);
}
public int getAmount()
{
return this.dataWatcher.getWatchableObjectInt(1);
}
public int getBrightnessForRender(float partialTicks)
@ -240,7 +251,7 @@ public class EntityXp extends Entity implements IObjectData
other.delayBeforeCanPickup = Math.max(other.delayBeforeCanPickup, this.delayBeforeCanPickup);
other.xpOrbAge = Math.min(other.xpOrbAge, this.xpOrbAge);
other.worldObj.setEntityState(other, (byte)other.getTextureByXP());
other.setCustomNameTag("" + other.xpValue);
other.setAmount(other.xpValue);
this.setDead();
return true;
}
@ -304,7 +315,7 @@ public class EntityXp extends Entity implements IObjectData
this.xpOrbHealth = tagCompund.getShort("Health") & 255;
this.xpOrbAge = tagCompund.getShort("Age");
this.xpValue = tagCompund.getShort("Value");
this.setCustomNameTag("" + this.xpValue);
this.setAmount(this.xpValue);
}
/**
@ -391,12 +402,9 @@ public class EntityXp extends Entity implements IObjectData
// return false;
// }
public String getDisplayName()
public String getLabel()
{
// if(!this.hasCustomName()) {
// return super.getDisplayName();
// }
return this.hasCustomName() ? Color.GREEN + this.getCustomNameTag() : null;
return Color.GREEN + "" + this.getAmount();
}
public EntityType getType() {

View file

@ -4055,22 +4055,15 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
public String getName()
{
// if(this.isPlayer())
// return this.getAlignment().color + (this.hasCustomName() ? this.getCustomNameTag() : "<?>");
String text = this.getPrefix();
// Enum cls = this.getNpcClass();
if(text == null || text.isEmpty()) {
text = this.getTypeName();
text = this.hasCustomName() ? this.getCustomNameTag() : this.getTypeName();
}
else {
// text = new TextComponent("entity.className." + cls.name().toLowerCase());
if(this.hasCustomName())
text += " " + this.getCustomNameTag();
}
return this.getAlignment().color + text;
// this.formatComponent(comp);
// text.setColor();
// return comp;
}
public float getEyeHeight()

View file

@ -146,7 +146,7 @@ public class EntityDie extends EntityThrowable implements IObjectData
return true;
}
public String getDisplayName()
public String getLabel()
{
if(this.getValue() == 0)
return null;

View file

@ -177,12 +177,28 @@ public abstract class EntityLiving extends Entity
protected void entityInit()
{
this.dataWatcher.addObject(1, "");
this.dataWatcher.addObject(4, (byte)0); // arrows
this.dataWatcher.addObject(5, 1); // max health
this.dataWatcher.addObject(6, 1); // health
this.dataWatcher.addObject(7, 0); // age
}
public void setCustomNameTag(String name)
{
this.dataWatcher.updateObject(1, name);
}
public String getCustomNameTag()
{
return this.dataWatcher.getWatchableObjectString(1);
}
public boolean hasCustomName()
{
return this.dataWatcher.getWatchableObjectString(1).length() > 0;
}
protected void applyEntityAttributes()
{
}
@ -530,6 +546,10 @@ public abstract class EntityLiving extends Entity
public void writeEntity(TagObject tagCompound)
{
if (this.getCustomNameTag() != null && this.getCustomNameTag().length() > 0)
{
tagCompound.setString("CustomName", this.getCustomNameTag());
}
tagCompound.setInt("MaxHealth", this.getMaxHealth());
tagCompound.setInt("Health", this.getHealth());
// tagCompound.setShort("Health", (short)((int)Math.ceil((double)this.getHealth())));
@ -581,6 +601,10 @@ public abstract class EntityLiving extends Entity
public void readEntity(TagObject tagCompund)
{
if (tagCompund.hasString("CustomName") && tagCompund.getString("CustomName").length() > 0)
{
this.setCustomNameTag(tagCompund.getString("CustomName"));
}
this.setAbsorptionAmount(tagCompund.getInt("Absorption"));
this.setSpeedBase(tagCompund.getFloat("SpeedBase"));
@ -2292,7 +2316,7 @@ public abstract class EntityLiving extends Entity
String kill;
IPlayer receiver = null;
if(this.combat.size() == 0) {
msg = kill = natural ? String.format("%s starb", this.getColoredName(Color.LIGHT_GRAY)) : null;
msg = kill = natural ? String.format("%s starb", this.getEnclosedName(Color.LIGHT_GRAY)) : null;
}
else {
CombatEntry strong = null;
@ -2331,16 +2355,16 @@ public abstract class EntityLiving extends Entity
ItemStack fallItem = fallEnt instanceof EntityNPC ? ((EntityNPC)fallEnt).getHeldItem() : null;
receiver = fallEnt.isPlayer() ? ((EntityNPC)fallEnt).connection : null;
if(fallItem != null) { // && fallItem.hasDisplayName()) {
msg = String.format("%s wurde von %s mit %s zum Fallen verdammt", this.getColoredName(Color.CYAN),
fallEnt.getColoredName(Color.CYAN), fallItem.getColoredName(Color.CYAN));
msg = String.format("%s wurde von %s mit %s zum Fallen verdammt", this.getEnclosedName(Color.CYAN),
fallEnt.getEnclosedName(Color.CYAN), fallItem.getColoredName(Color.CYAN));
kill = String.format(Color.CYAN + "* %s mit %s zum Fallen verdammt",
this.getColoredName(Color.CYAN), fallItem.getColoredName(Color.CYAN));
this.getEnclosedName(Color.CYAN), fallItem.getColoredName(Color.CYAN));
}
else {
msg = String.format("%s wurde von %s zum Fallen verdammt", this.getColoredName(Color.CYAN),
fallEnt.getColoredName(Color.CYAN));
msg = String.format("%s wurde von %s zum Fallen verdammt", this.getEnclosedName(Color.CYAN),
fallEnt.getEnclosedName(Color.CYAN));
kill = String.format(Color.CYAN + "* %s zum Fallen verdammt",
this.getColoredName(Color.CYAN));
this.getEnclosedName(Color.CYAN));
}
}
else if(lastEnt != null) {
@ -2348,24 +2372,24 @@ public abstract class EntityLiving extends Entity
receiver = lastEnt.isPlayer() ? ((EntityNPC)lastEnt).connection : null;
if(lastItem != null) { // && lastItem.hasDisplayName()) {
msg = String.format("%s fiel zu tief und wurde von %s mit %s erledigt",
this.getColoredName(Color.BLUE),
lastEnt.getColoredName(Color.BLUE), lastItem.getColoredName(Color.BLUE));
this.getEnclosedName(Color.BLUE),
lastEnt.getEnclosedName(Color.BLUE), lastItem.getColoredName(Color.BLUE));
kill = String.format(Color.BLUE + "* %s mit %s erledigt",
this.getColoredName(Color.BLUE), lastItem.getColoredName(Color.BLUE));
this.getEnclosedName(Color.BLUE), lastItem.getColoredName(Color.BLUE));
}
else {
msg = String.format("%s fiel zu tief und wurde von %s erledigt", this.getColoredName(Color.BLUE),
lastEnt.getColoredName(Color.BLUE));
kill = String.format(Color.BLUE + "%s erledigt", this.getColoredName(Color.BLUE));
msg = String.format("%s fiel zu tief und wurde von %s erledigt", this.getEnclosedName(Color.BLUE),
lastEnt.getEnclosedName(Color.BLUE));
kill = String.format(Color.BLUE + "%s erledigt", this.getEnclosedName(Color.BLUE));
}
}
else {
msg = kill = natural ? String.format("%s wurde zum Fallen verdammt", this.getColoredName(Color.CYAN)) : null;
msg = kill = natural ? String.format("%s wurde zum Fallen verdammt", this.getEnclosedName(Color.CYAN)) : null;
}
}
else {
msg = kill = natural ? String.format("%s fiel " + (fall.blockType() == null ? "aus zu großer Höhe" : fall.blockType()),
this.getColoredName(Color.NEON)) : null;
this.getEnclosedName(Color.NEON)) : null;
}
}
else {
@ -3158,10 +3182,10 @@ public abstract class EntityLiving extends Entity
public String getName()
{
return this.getAlignment().color + this.getTypeName();
return this.getAlignment().color + (this.hasCustomName() ? this.getCustomNameTag() : this.getTypeName());
}
public String getDisplayName()
public String getLabel()
{
return this.getName();
}

View file

@ -92,22 +92,12 @@ public class ItemCharTemplate extends Item
d0 = 0.5D;
}
// int amount = Math.min(stack.stackSize, 128);
// for(int z = 0; z < amount; z++) {
Entity entity = spawnNpc(worldIn, this.spawned, (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D, false);
if (entity != null)
if (entity instanceof EntityLiving living && stack.hasDisplayName())
{
if (stack.hasDisplayName())
{
entity.setCustomNameTag(stack.getDisplayName());
}
// if (!playerIn.creative)
// {
// }
living.setCustomNameTag(stack.getDisplayName());
}
// }
return true;
}

View file

@ -56,11 +56,6 @@ public class ItemMinecart extends Item
EntityCart entityminecart = new EntityMinecart(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.0625D + d0, (double)pos.getZ() + 0.5D);
if (stack.hasDisplayName())
{
entityminecart.setCustomNameTag(stack.getDisplayName());
}
worldIn.spawnEntityInWorld(entityminecart);
// if(this.minecartType == EnumMinecartType.COMMAND_BLOCK)
// ((EntityMinecartCommandBlock)entityminecart).getCommandBlockLogic().setEnabled(((EntityNPCMP)playerIn).canUse(Permissions.CMDBLOCK));
@ -118,11 +113,6 @@ public class ItemMinecart extends Item
EntityCart entityminecart = new EntityMinecart(world, d0, d1 + d3, d2);
if (stack.hasDisplayName())
{
entityminecart.setCustomNameTag(stack.getDisplayName());
}
world.spawnEntityInWorld(entityminecart);
stack.split(1);
return stack;

View file

@ -89,27 +89,12 @@ public class ItemMobTemplate extends Item
}
// int amount = Math.min(stack.stackSize, 128);
// for(int z = 0; z < amount; z++) {
Entity entity = spawnCreature(worldIn, this.entityId, (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D, false);
if (entity != null)
if (entity instanceof EntityLiving living && stack.hasDisplayName())
{
// if (entity instanceof EntityLiving)
// {
// ((EntityLiving)entity).disableDespawn();
// }
if (entity instanceof EntityLiving && stack.hasDisplayName())
{
entity.setCustomNameTag(stack.getDisplayName());
}
// if (!playerIn.creative)
// {
// }
living.setCustomNameTag(stack.getDisplayName());
}
// }
return true;
}