diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 8f92f02f..11a33185 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -1147,7 +1147,7 @@ public class Client implements IThreadListener { if(entity.vehicle instanceof EntityLiving living) { int vh = living.getHealth(); int vhMax = living.getMaxHealth(); - y = this.drawStat(x, y, living.getDisplayName(), vh, vhMax, 0xff6060); + y = this.drawStat(x, y, living.getLabel(), vh, vhMax, 0xff6060); } if(entity.getManaPoints() > 0) { int mana = entity.getManaPoints(); @@ -1191,7 +1191,7 @@ public class Client implements IThreadListener { } else if(this.pointed != null && this.pointed.type == ObjectType.ENTITY && this.pointed.entity != null) { Entity entity = this.pointed.entity; - desc = (entity instanceof EntityNPC npc ? (!npc.canCounter(this.player) ? Color.GREEN : (npc.canAttack(this.player) ? Color.RED : Color.BLUE)) : Color.LIGHT_GRAY) + entity.getCommandName(); + desc = (entity instanceof EntityNPC npc ? (!npc.canCounter(this.player) ? Color.GREEN : (npc.canAttack(this.player) ? Color.RED : Color.BLUE)) : Color.LIGHT_GRAY) + entity.getRawName(); line1 = entity.getInfo(this.player); line2 = Color.CYAN + EntityRegistry.getEntityName(EntityRegistry.getEntityString(entity)); if(entity instanceof EntityLiving living) { @@ -1973,7 +1973,7 @@ public class Client implements IThreadListener { + (entity.isWet() ? "W" : "") + (entity.canAttackWithItem() ? "A" : "") + (entity.passenger != null ? "H" : "") + (entity.vehicle != null ? "R" : "") + (entity.doesEntityNotTriggerPressurePlate() ? "L" : "") + "\n" + - (entity.hasCustomName() ? "Name: '" + Color.stripCodes(entity.getCustomNameTag()) + "'" : "Name: n/a") + (entity instanceof EntityLiving living && living.hasCustomName() ? "Name: '" + Color.stripCodes(living.getCustomNameTag()) + "'" : "Name: n/a") ; } diff --git a/client/src/main/java/client/renderer/entity/Render.java b/client/src/main/java/client/renderer/entity/Render.java index 7731f363..652d4bbc 100755 --- a/client/src/main/java/client/renderer/entity/Render.java +++ b/client/src/main/java/client/renderer/entity/Render.java @@ -28,7 +28,7 @@ public abstract class Render protected void renderName(T entity, double x, double y, double z) { - String name = entity.getDisplayName(); + String name = entity.getLabel(); if(name != null && !name.isEmpty()) this.manager.renderLabel(entity, name, x, y, z, 64); } diff --git a/client/src/main/java/client/renderer/entity/RenderXp.java b/client/src/main/java/client/renderer/entity/RenderXp.java index a900fcda..84be78b5 100755 --- a/client/src/main/java/client/renderer/entity/RenderXp.java +++ b/client/src/main/java/client/renderer/entity/RenderXp.java @@ -66,7 +66,7 @@ public class RenderXp extends Render { protected void renderName(EntityXp entity, double x, double y, double z) { - String name = entity.getDisplayName(); + String name = entity.getLabel(); if(name != null && !name.isEmpty()) this.manager.renderLabel(entity, name, x, y - 0.5, z, 64); } diff --git a/client/src/main/java/client/renderer/entity/RendererLivingEntity.java b/client/src/main/java/client/renderer/entity/RendererLivingEntity.java index d37bba83..05abf9fe 100755 --- a/client/src/main/java/client/renderer/entity/RendererLivingEntity.java +++ b/client/src/main/java/client/renderer/entity/RendererLivingEntity.java @@ -500,7 +500,7 @@ public abstract class RendererLivingEntity extends Rende public void renderName(T entity, double x, double y, double z) { - String name = entity.getDisplayName(); + String name = entity.getLabel(); if(name != null && !name.isEmpty()) this.manager.renderLabel(entity, name, x, entity.isSneakingVisually() ? y - 0.25 : y, z, 64); if(entity.isEntityAlive()) diff --git a/common/src/main/java/common/entity/DamageSource.java b/common/src/main/java/common/entity/DamageSource.java index 4b1769e3..17353a68 100755 --- a/common/src/main/java/common/entity/DamageSource.java +++ b/common/src/main/java/common/entity/DamageSource.java @@ -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)); } /** diff --git a/common/src/main/java/common/entity/Entity.java b/common/src/main/java/common/entity/Entity.java index 98acd55a..40275c99 100755 --- a/common/src/main/java/common/entity/Entity.java +++ b/common/src/main/java/common/entity/Entity.java @@ -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))); diff --git a/common/src/main/java/common/entity/EntityDamageSource.java b/common/src/main/java/common/entity/EntityDamageSource.java index e1499f47..a31cdb39 100755 --- a/common/src/main/java/common/entity/EntityDamageSource.java +++ b/common/src/main/java/common/entity/EntityDamageSource.java @@ -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)); } // /** diff --git a/common/src/main/java/common/entity/EntityDamageSourceIndirect.java b/common/src/main/java/common/entity/EntityDamageSourceIndirect.java index 4c96d449..05b79cc1 100755 --- a/common/src/main/java/common/entity/EntityDamageSourceIndirect.java +++ b/common/src/main/java/common/entity/EntityDamageSourceIndirect.java @@ -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); } } diff --git a/common/src/main/java/common/entity/animal/EntityCat.java b/common/src/main/java/common/entity/animal/EntityCat.java index 75cf3510..d4d2cbde 100755 --- a/common/src/main/java/common/entity/animal/EntityCat.java +++ b/common/src/main/java/common/entity/animal/EntityCat.java @@ -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) diff --git a/common/src/main/java/common/entity/animal/EntityHorse.java b/common/src/main/java/common/entity/animal/EntityHorse.java index 0c234a44..8372eac4 100755 --- a/common/src/main/java/common/entity/animal/EntityHorse.java +++ b/common/src/main/java/common/entity/animal/EntityHorse.java @@ -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"; } } } diff --git a/common/src/main/java/common/entity/animal/EntityRabbit.java b/common/src/main/java/common/entity/animal/EntityRabbit.java index eaa0c77d..d3fd9400 100755 --- a/common/src/main/java/common/entity/animal/EntityRabbit.java +++ b/common/src/main/java/common/entity/animal/EntityRabbit.java @@ -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) { diff --git a/common/src/main/java/common/entity/item/EntityCart.java b/common/src/main/java/common/entity/item/EntityCart.java index 1643b9f9..37c1971a 100755 --- a/common/src/main/java/common/entity/item/EntityCart.java +++ b/common/src/main/java/common/entity/item/EntityCart.java @@ -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; diff --git a/common/src/main/java/common/entity/item/EntityItem.java b/common/src/main/java/common/entity/item/EntityItem.java index e6dabe31..fcd00d8a 100755 --- a/common/src/main/java/common/entity/item/EntityItem.java +++ b/common/src/main/java/common/entity/item/EntityItem.java @@ -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()) diff --git a/common/src/main/java/common/entity/item/EntityMinecart.java b/common/src/main/java/common/entity/item/EntityMinecart.java index 5a5ae391..7af44a78 100755 --- a/common/src/main/java/common/entity/item/EntityMinecart.java +++ b/common/src/main/java/common/entity/item/EntityMinecart.java @@ -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; + } } diff --git a/common/src/main/java/common/entity/item/EntityTntCart.java b/common/src/main/java/common/entity/item/EntityTntCart.java index f5a79342..6da24992 100755 --- a/common/src/main/java/common/entity/item/EntityTntCart.java +++ b/common/src/main/java/common/entity/item/EntityTntCart.java @@ -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; + } } diff --git a/common/src/main/java/common/entity/item/EntityXp.java b/common/src/main/java/common/entity/item/EntityXp.java index df2111c0..d31b1a25 100755 --- a/common/src/main/java/common/entity/item/EntityXp.java +++ b/common/src/main/java/common/entity/item/EntityXp.java @@ -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() { diff --git a/common/src/main/java/common/entity/npc/EntityNPC.java b/common/src/main/java/common/entity/npc/EntityNPC.java index d3a5cf14..8e004dc2 100755 --- a/common/src/main/java/common/entity/npc/EntityNPC.java +++ b/common/src/main/java/common/entity/npc/EntityNPC.java @@ -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() diff --git a/common/src/main/java/common/entity/projectile/EntityDie.java b/common/src/main/java/common/entity/projectile/EntityDie.java index 7f2e3cfe..255e240d 100755 --- a/common/src/main/java/common/entity/projectile/EntityDie.java +++ b/common/src/main/java/common/entity/projectile/EntityDie.java @@ -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; diff --git a/common/src/main/java/common/entity/types/EntityLiving.java b/common/src/main/java/common/entity/types/EntityLiving.java index 8a7b020a..213de567 100755 --- a/common/src/main/java/common/entity/types/EntityLiving.java +++ b/common/src/main/java/common/entity/types/EntityLiving.java @@ -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(); } diff --git a/common/src/main/java/common/item/spawner/ItemCharTemplate.java b/common/src/main/java/common/item/spawner/ItemCharTemplate.java index 78635b61..fb643805 100755 --- a/common/src/main/java/common/item/spawner/ItemCharTemplate.java +++ b/common/src/main/java/common/item/spawner/ItemCharTemplate.java @@ -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; } diff --git a/common/src/main/java/common/item/spawner/ItemMinecart.java b/common/src/main/java/common/item/spawner/ItemMinecart.java index 0a24df19..78da1fb1 100755 --- a/common/src/main/java/common/item/spawner/ItemMinecart.java +++ b/common/src/main/java/common/item/spawner/ItemMinecart.java @@ -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; diff --git a/common/src/main/java/common/item/spawner/ItemMobTemplate.java b/common/src/main/java/common/item/spawner/ItemMobTemplate.java index 810b5f13..c64ee240 100755 --- a/common/src/main/java/common/item/spawner/ItemMobTemplate.java +++ b/common/src/main/java/common/item/spawner/ItemMobTemplate.java @@ -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; } diff --git a/server/src/main/java/server/Server.java b/server/src/main/java/server/Server.java index f6dbd865..353b0762 100755 --- a/server/src/main/java/server/Server.java +++ b/server/src/main/java/server/Server.java @@ -920,7 +920,7 @@ public final class Server implements IThreadListener, Executor { Log.NETWORK.info(loginUser + "[" + connection.getCutAddress() + "] hat sich mit Objekt-ID " + player.getId() + " auf " + UniverseRegistry.getName(world.dimension) + ": " - + String.format("%.2f %.2f %.2f", player.posX, player.posY, player.posZ) + " verbunden (" + (tag == null ? "Charakter-Editor" : "'" + player.getCommandName() + "'") + ")"); + + String.format("%.2f %.2f %.2f", player.posX, player.posY, player.posZ) + " verbunden (" + (tag == null ? "Charakter-Editor" : "'" + player.getRawName() + "'") + ")"); List> vars = Lists.newArrayList(); for(Entry var : this.variables.entrySet()) { diff --git a/server/src/main/java/server/command/PlayerItemParser.java b/server/src/main/java/server/command/PlayerItemParser.java index 6c77aa08..b018b4b0 100644 --- a/server/src/main/java/server/command/PlayerItemParser.java +++ b/server/src/main/java/server/command/PlayerItemParser.java @@ -12,7 +12,7 @@ public class PlayerItemParser extends PlayerEntityParser { EntityNPC entity = (EntityNPC)super.parse(env, input); ItemStack stack = entity.getHeldItem(); if(stack == null) - throw new RunException("%s hält keinen Gegenstand in der Hand", entity.getCommandName()); + throw new RunException("%s hält keinen Gegenstand in der Hand", entity.getRawName()); return stack; } diff --git a/server/src/main/java/server/command/commands/CommandClear.java b/server/src/main/java/server/command/commands/CommandClear.java index 3ea90f22..e949f6c2 100644 --- a/server/src/main/java/server/command/commands/CommandClear.java +++ b/server/src/main/java/server/command/commands/CommandClear.java @@ -25,7 +25,7 @@ public class CommandClear extends Command { ((EntityNPC)entity).setMouseItem(null); else ((EntityNPC)entity).setHeldItem(null); - exec.log("Inventar von %s gelöscht", entity.getCommandName()); + exec.log("Inventar von %s gelöscht", entity.getRawName()); done++; } } diff --git a/server/src/main/java/server/command/commands/CommandDeathspot.java b/server/src/main/java/server/command/commands/CommandDeathspot.java index fb979e99..1b62f7f4 100644 --- a/server/src/main/java/server/command/commands/CommandDeathspot.java +++ b/server/src/main/java/server/command/commands/CommandDeathspot.java @@ -24,10 +24,10 @@ public class CommandDeathspot extends Command { public Object exec(CommandEnvironment env, Executor exec, EntityNPC player, List entities) { Position pos = ((Player)player.connection).getLastDeath(); if(pos == null) - throw new RunException("%s hat keinen letzten Todespunkt", player.getCommandName()); + throw new RunException("%s hat keinen letzten Todespunkt", player.getRawName()); for(Entity entity : entities) { entity.teleport(pos); - exec.log("%s zum Todespunkt von %s (%d, %d, %d in %s) teleportiert", entity.getCommandName(), player.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getDisplay()); + exec.log("%s zum Todespunkt von %s (%d, %d, %d in %s) teleportiert", entity.getRawName(), player.getRawName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getDisplay()); } return entities.size(); } diff --git a/server/src/main/java/server/command/commands/CommandEntity.java b/server/src/main/java/server/command/commands/CommandEntity.java index 4e0f495f..04a7e34f 100644 --- a/server/src/main/java/server/command/commands/CommandEntity.java +++ b/server/src/main/java/server/command/commands/CommandEntity.java @@ -28,13 +28,13 @@ public class CommandEntity extends Command { entity.writeTags(etag); if(tag == null) { exec.log("************************************************************"); - exec.log("Daten von %s bei %d, %d, %d in %s:", entity.getCommandName(), pos.getX(), pos.getY(), pos.getZ(), entity.worldObj.dimension.getDisplay()); + exec.log("Daten von %s bei %d, %d, %d in %s:", entity.getRawName(), pos.getX(), pos.getY(), pos.getZ(), entity.worldObj.dimension.getDisplay()); exec.log(etag.format(4)); } else { etag.merge(tag); entity.readTags(etag); - exec.log("Daten von %s bei %d, %d, %d in %s geändert", entity.getCommandName(), pos.getX(), pos.getY(), pos.getZ(), entity.worldObj.dimension.getDisplay()); + exec.log("Daten von %s bei %d, %d, %d in %s geändert", entity.getRawName(), pos.getX(), pos.getY(), pos.getZ(), entity.worldObj.dimension.getDisplay()); } done++; } diff --git a/server/src/main/java/server/command/commands/CommandExp.java b/server/src/main/java/server/command/commands/CommandExp.java index 359ce852..2013f3b8 100644 --- a/server/src/main/java/server/command/commands/CommandExp.java +++ b/server/src/main/java/server/command/commands/CommandExp.java @@ -22,16 +22,16 @@ public class CommandExp extends Command { public void exec(CommandEnvironment env, Executor exec, Integer points, boolean reset, List players) { for(EntityNPC player : players) { if(points == null && !reset) { - exec.log("Erfahrung von %s: Level %d, %d/%d (%d Punkte)", player.getCommandName(), player.experienceLevel, (int)((float)player.xpBarCap() * player.experience), player.xpBarCap(), player.experienceTotal); + exec.log("Erfahrung von %s: Level %d, %d/%d (%d Punkte)", player.getRawName(), player.experienceLevel, (int)((float)player.xpBarCap() * player.experience), player.xpBarCap(), player.experienceTotal); } else if(reset) { player.setExperience(points == null ? 0 : points); - exec.log("Erfahrung von %s " + (points == null ? "zurückgesetzt" : "auf %d Punkte gesetzt (Level %d)"), player.getCommandName(), player.experienceTotal, player.experienceLevel); + exec.log("Erfahrung von %s " + (points == null ? "zurückgesetzt" : "auf %d Punkte gesetzt (Level %d)"), player.getRawName(), player.experienceTotal, player.experienceLevel); } else { int level = player.experienceLevel; player.addExperience(points); - exec.log("%d Erfahrungspunkte an %s gegeben" + (player.experienceLevel != level ? ", ist jetzt Level %d" : ""), points, player.getCommandName(), player.experienceLevel); + exec.log("%d Erfahrungspunkte an %s gegeben" + (player.experienceLevel != level ? ", ist jetzt Level %d" : ""), points, player.getRawName(), player.experienceLevel); } } if(players.size() > 1) { diff --git a/server/src/main/java/server/command/commands/CommandFind.java b/server/src/main/java/server/command/commands/CommandFind.java index 69bc489a..27f61c4f 100644 --- a/server/src/main/java/server/command/commands/CommandFind.java +++ b/server/src/main/java/server/command/commands/CommandFind.java @@ -21,7 +21,7 @@ public class CommandFind extends Command { for(Entity entity : entities) { if(entity.isEntityAlive()) { BlockPos pos = entity.getPosition(); - exec.log("%s bei %d, %d, %d in %s gefunden %s", entity.getCommandName(), pos.getX(), pos.getY(), pos.getZ(), entity.worldObj.dimension.getDisplay(), + exec.log("%s bei %d, %d, %d in %s gefunden %s", entity.getRawName(), pos.getX(), pos.getY(), pos.getZ(), entity.worldObj.dimension.getDisplay(), asCommand(null, "tp #%d", entity.getId())); done++; } diff --git a/server/src/main/java/server/command/commands/CommandGod.java b/server/src/main/java/server/command/commands/CommandGod.java index f88f8310..6f70493c 100644 --- a/server/src/main/java/server/command/commands/CommandGod.java +++ b/server/src/main/java/server/command/commands/CommandGod.java @@ -27,7 +27,7 @@ public class CommandGod extends Command { if(!quiet) player.connection.addFeed(!remove ? (Color.GREEN + "Statuseffekte wurden hinzugefügt") : (Color.RED + "Statuseffekte wurden entfernt")); if(quiet || player.connection != exec) - exec.log("Statuseffekte " + (!remove ? "an %s gegeben" : "von %s entfernt"), player.getCommandName()); + exec.log("Statuseffekte " + (!remove ? "an %s gegeben" : "von %s entfernt"), player.getRawName()); } if(players.size() > 1) exec.log("Statuseffekte " + (!remove ? "an %d Spieler gegeben" : "von %d Spielern entfernt"), players.size()); diff --git a/server/src/main/java/server/command/commands/CommandItem.java b/server/src/main/java/server/command/commands/CommandItem.java index 684acfe8..689beabd 100644 --- a/server/src/main/java/server/command/commands/CommandItem.java +++ b/server/src/main/java/server/command/commands/CommandItem.java @@ -54,7 +54,7 @@ public class CommandItem extends Command { total = amount - total; if(total <= 0) continue; - exec.log("%d * %s zum Inventar von %s hinzugefügt", total, stack.getDisplayName(), player.getCommandName()); + exec.log("%d * %s zum Inventar von %s hinzugefügt", total, stack.getDisplayName(), player.getRawName()); done++; given += total; } diff --git a/server/src/main/java/server/command/commands/CommandMilk.java b/server/src/main/java/server/command/commands/CommandMilk.java index ef3dba27..03a447c3 100644 --- a/server/src/main/java/server/command/commands/CommandMilk.java +++ b/server/src/main/java/server/command/commands/CommandMilk.java @@ -32,12 +32,12 @@ public class CommandMilk extends Command { if(type != null && entity.hasEffect(type)) { int amplifier = entity.getEffect(type).getAmplifier(); entity.removeEffect(type); - exec.log("%s von %s entfernt", type.getDisplay(amplifier), entity.getCommandName()); + exec.log("%s von %s entfernt", type.getDisplay(amplifier), entity.getRawName()); done++; } else if(type == null && !entity.getEffects().isEmpty()) { entity.clearEffects(negative); - exec.log("Alle Effekte von %s entfernt", entity.getCommandName()); + exec.log("Alle Effekte von %s entfernt", entity.getRawName()); done++; } } diff --git a/server/src/main/java/server/command/commands/CommandMore.java b/server/src/main/java/server/command/commands/CommandMore.java index 88fb5961..38361f56 100644 --- a/server/src/main/java/server/command/commands/CommandMore.java +++ b/server/src/main/java/server/command/commands/CommandMore.java @@ -41,7 +41,7 @@ public class CommandMore extends Command { add += this.addItems(player.getHeldItem()); } if(add > 0) { - exec.log("%d " + (add == 1 ? "Gegenstand" : "Gegenstände") + " wurde" + (add == 1 ? "" : "n") + " dem Inventar von %s hinzugefügt", add, player.getCommandName()); + exec.log("%d " + (add == 1 ? "Gegenstand" : "Gegenstände") + " wurde" + (add == 1 ? "" : "n") + " dem Inventar von %s hinzugefügt", add, player.getRawName()); done++; } added += add; diff --git a/server/src/main/java/server/command/commands/CommandNoclip.java b/server/src/main/java/server/command/commands/CommandNoclip.java index 7400ee7e..3bc14cc9 100644 --- a/server/src/main/java/server/command/commands/CommandNoclip.java +++ b/server/src/main/java/server/command/commands/CommandNoclip.java @@ -29,7 +29,7 @@ public class CommandNoclip extends Command { if(!quiet) player.connection.addFeed((!remove ? Color.GREEN : Color.RED) + "NoClip wurde " + (!remove ? "eingeschaltet" : "ausgeschaltet")); if(quiet || player.connection != exec) - exec.log("NoClip für %s " + (!remove ? "eingeschaltet" : "ausgeschaltet"), player.getCommandName()); + exec.log("NoClip für %s " + (!remove ? "eingeschaltet" : "ausgeschaltet"), player.getRawName()); done++; } if(done > 1) diff --git a/server/src/main/java/server/command/commands/CommandOfflinetp.java b/server/src/main/java/server/command/commands/CommandOfflinetp.java index 1d492ea1..ae17660c 100644 --- a/server/src/main/java/server/command/commands/CommandOfflinetp.java +++ b/server/src/main/java/server/command/commands/CommandOfflinetp.java @@ -33,7 +33,7 @@ public class CommandOfflinetp extends Command { throw new RunException("Spieler '%s' konnte nicht gefunden werden", user); for(Entity entity : entities) { entity.teleport(pos); - exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getDisplay()); + exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getRawName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getDisplay()); } return entities.size(); } diff --git a/server/src/main/java/server/command/commands/CommandPlayers.java b/server/src/main/java/server/command/commands/CommandPlayers.java index ebc8c6d6..fca17579 100644 --- a/server/src/main/java/server/command/commands/CommandPlayers.java +++ b/server/src/main/java/server/command/commands/CommandPlayers.java @@ -27,7 +27,7 @@ public class CommandPlayers extends Command { exec.log(Color.GREEN + "Es " + (players.size() == 1 ? "ist" : "sind") + " " + Color.YELLOW + "%d" + Color.GREEN + " Spieler online", players.size()); for(Player player : players) { EntityNPC entity = player.getPresentEntity(); - exec.log("%s%s" + Color.GRAY + ": '%s" + Color.GRAY + "'" + (coords && entity != null ? " [" + Color.ORANGE + "%s @ %d, %d, %d" + Color.GRAY + "]" : ""), player.isAdmin() ? Color.RED : Color.NEON, player.getUser(), entity == null ? Color.DARK_GRAY + "<->" : Color.ACID + entity.getCommandName(), entity == null ? null : entity.worldObj.dimension.getDisplay(), entity == null ? null : ExtMath.floord(entity.posX), entity == null ? null : ExtMath.floord(entity.posY), entity == null ? null : ExtMath.floord(entity.posZ)); + exec.log("%s%s" + Color.GRAY + ": '%s" + Color.GRAY + "'" + (coords && entity != null ? " [" + Color.ORANGE + "%s @ %d, %d, %d" + Color.GRAY + "]" : ""), player.isAdmin() ? Color.RED : Color.NEON, player.getUser(), entity == null ? Color.DARK_GRAY + "<->" : Color.ACID + entity.getRawName(), entity == null ? null : entity.worldObj.dimension.getDisplay(), entity == null ? null : ExtMath.floord(entity.posX), entity == null ? null : ExtMath.floord(entity.posY), entity == null ? null : ExtMath.floord(entity.posZ)); } } } diff --git a/server/src/main/java/server/command/commands/CommandPotion.java b/server/src/main/java/server/command/commands/CommandPotion.java index 9f81b032..436d9db3 100644 --- a/server/src/main/java/server/command/commands/CommandPotion.java +++ b/server/src/main/java/server/command/commands/CommandPotion.java @@ -37,9 +37,9 @@ public class CommandPotion extends Command { entity.addEffect(effect); } if(type.isInstant() || duration == 0) - exec.log("%s an %s gegeben", type.getDisplay(strength - 1), entity.getCommandName()); + exec.log("%s an %s gegeben", type.getDisplay(strength - 1), entity.getRawName()); else - exec.log("%s für %d Sekunden an %s gegeben", type.getDisplay(strength - 1), duration, entity.getCommandName()); + exec.log("%s für %d Sekunden an %s gegeben", type.getDisplay(strength - 1), duration, entity.getRawName()); done++; } } diff --git a/server/src/main/java/server/command/commands/CommandRemove.java b/server/src/main/java/server/command/commands/CommandRemove.java index 56044bc2..25bf1b1a 100644 --- a/server/src/main/java/server/command/commands/CommandRemove.java +++ b/server/src/main/java/server/command/commands/CommandRemove.java @@ -26,7 +26,7 @@ public class CommandRemove extends Command { entity.kill(); else entity.setDead(); - exec.log(kill ? "%s getötet" : "%s entfernt", entity.getCommandName()); + exec.log(kill ? "%s getötet" : "%s entfernt", entity.getRawName()); done++; } } diff --git a/server/src/main/java/server/command/commands/CommandRepair.java b/server/src/main/java/server/command/commands/CommandRepair.java index ca84b803..6d4d53ed 100644 --- a/server/src/main/java/server/command/commands/CommandRepair.java +++ b/server/src/main/java/server/command/commands/CommandRepair.java @@ -48,7 +48,7 @@ public class CommandRepair extends Command { rep++; } if(rep > 0) { - exec.log("%d " + (rep == 1 ? "Gegenstand" : "Gegenstände") + " im Inventar von %s wurde" + (rep == 1 ? "" : "n") + " repariert", rep, player.getCommandName()); + exec.log("%d " + (rep == 1 ? "Gegenstand" : "Gegenstände") + " im Inventar von %s wurde" + (rep == 1 ? "" : "n") + " repariert", rep, player.getRawName()); done++; } repaired += rep; diff --git a/server/src/main/java/server/command/commands/CommandReturn.java b/server/src/main/java/server/command/commands/CommandReturn.java index bc67a645..3dc593a5 100644 --- a/server/src/main/java/server/command/commands/CommandReturn.java +++ b/server/src/main/java/server/command/commands/CommandReturn.java @@ -23,7 +23,7 @@ public class CommandReturn extends Command { Position pos = ((Player)player.connection).getLastTeleport(); if(pos != null) { player.teleport(pos); - exec.log("%s zum letzten Punkt (%d, %d, %d in %s) teleportiert", player.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getDisplay()); + exec.log("%s zum letzten Punkt (%d, %d, %d in %s) teleportiert", player.getRawName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getDisplay()); done++; } } diff --git a/server/src/main/java/server/command/commands/CommandTele.java b/server/src/main/java/server/command/commands/CommandTele.java index 311c9fb6..9ccc1977 100644 --- a/server/src/main/java/server/command/commands/CommandTele.java +++ b/server/src/main/java/server/command/commands/CommandTele.java @@ -28,7 +28,7 @@ public class CommandTele extends Command { public Object exec(CommandEnvironment env, Executor exec, Vec3 position, Dimension dim, Double yaw, Double pitch, List entities) { for(Entity entity : entities) { entity.teleport(position.xCoord, position.yCoord, position.zCoord, yaw == null ? entity.rotYaw : yaw.floatValue(), pitch == null ? entity.rotPitch : pitch.floatValue(), dim); - exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), ExtMath.floord(position.xCoord), ExtMath.floord(position.yCoord), ExtMath.floord(position.zCoord), dim.getDisplay()); + exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getRawName(), ExtMath.floord(position.xCoord), ExtMath.floord(position.yCoord), ExtMath.floord(position.zCoord), dim.getDisplay()); } return entities.size(); } diff --git a/server/src/main/java/server/command/commands/CommandTp.java b/server/src/main/java/server/command/commands/CommandTp.java index 401398c0..4a8e7eb3 100644 --- a/server/src/main/java/server/command/commands/CommandTp.java +++ b/server/src/main/java/server/command/commands/CommandTp.java @@ -22,7 +22,7 @@ public class CommandTp extends Command { Position pos = target.getPos(); for(Entity entity : entities) { entity.teleport(pos); - exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getDisplay()); + exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getRawName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getDisplay()); } return entities.size(); } diff --git a/server/src/main/java/server/command/commands/CommandTphere.java b/server/src/main/java/server/command/commands/CommandTphere.java index 9780476b..5cb76b65 100644 --- a/server/src/main/java/server/command/commands/CommandTphere.java +++ b/server/src/main/java/server/command/commands/CommandTphere.java @@ -23,7 +23,7 @@ public class CommandTphere extends Command { throw new RunException("Keine Position zum Teleportieren vorhanden"); for(Entity entity : entities) { entity.teleport(pos); - exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getDisplay()); + exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getRawName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getDisplay()); } return entities.size(); } diff --git a/server/src/main/java/server/command/commands/CommandWarp.java b/server/src/main/java/server/command/commands/CommandWarp.java index a859f999..8a1762bd 100644 --- a/server/src/main/java/server/command/commands/CommandWarp.java +++ b/server/src/main/java/server/command/commands/CommandWarp.java @@ -45,7 +45,7 @@ public class CommandWarp extends Command { // } for(Entity entity : entities) { entity.teleport(pos); - exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getDisplay()); + exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getRawName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), pos.getDimension().getDisplay()); } return entities.size(); } diff --git a/server/src/main/java/server/command/commands/CommandWorld.java b/server/src/main/java/server/command/commands/CommandWorld.java index b4cdecf6..c747c15b 100644 --- a/server/src/main/java/server/command/commands/CommandWorld.java +++ b/server/src/main/java/server/command/commands/CommandWorld.java @@ -23,7 +23,7 @@ public class CommandWorld extends Command { for(Entity entity : entities) { BlockPos pos = adjust(world, entity.getPosition()); entity.teleport(pos, world); - exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), pos.getX(), pos.getY(), pos.getZ(), world.dimension.getDisplay()); + exec.log("%s nach %d, %d, %d in %s teleportiert", entity.getRawName(), pos.getX(), pos.getY(), pos.getZ(), world.dimension.getDisplay()); } return entities.size(); } diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index 0dd5eca1..97927523 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -1696,10 +1696,10 @@ public class Player extends User implements Executor, IPlayer Player target = this.server.getPlayer(space < 0 ? line.substring(1) : line.substring(1, space)); if(target == null) return false; - target.addChat(this.entity.getColoredName(Color.LIGHT_GRAY) + " -> " + target.entity.getColoredName(Color.LIGHT_GRAY) + " " + + target.addChat(this.entity.getEnclosedName(Color.LIGHT_GRAY) + " -> " + target.entity.getEnclosedName(Color.LIGHT_GRAY) + " " + line); if(target != this) - this.addChat(target.entity.getColoredName(Color.LIGHT_GRAY) + " -> " + this.entity.getColoredName(Color.LIGHT_GRAY) + " " + + this.addChat(target.entity.getEnclosedName(Color.LIGHT_GRAY) + " -> " + this.entity.getEnclosedName(Color.LIGHT_GRAY) + " " + line); return true; } @@ -1710,7 +1710,7 @@ public class Player extends User implements Executor, IPlayer String str = line.substring(1).trim(); if(str.isEmpty()) return false; - this.server.sendPacket(new SPacketMessage(String.format(Color.LIGHT_GRAY + "* %s %s", this.entity.getColoredName(Color.LIGHT_GRAY), str), Type.CHAT)); + this.server.sendPacket(new SPacketMessage(String.format(Color.LIGHT_GRAY + "* %s %s", this.entity.getEnclosedName(Color.LIGHT_GRAY), str), Type.CHAT)); return true; } @@ -1940,7 +1940,7 @@ public class Player extends User implements Executor, IPlayer case CHAT: if(!this.sendPlayer(msg) && !this.sendEmote(msg)) - this.server.sendPacket(new SPacketMessage(String.format("%s %s", this.entity.getColoredName(Color.LIGHT_GRAY), msg), Type.CHAT)); + this.server.sendPacket(new SPacketMessage(String.format("%s %s", this.entity.getEnclosedName(Color.LIGHT_GRAY), msg), Type.CHAT)); break; case DISPLAY: @@ -3061,7 +3061,7 @@ public class Player extends User implements Executor, IPlayer } public String getEntityName() { - return this.getPresentEntity() == null ? this.getUser() : this.getPresentEntity().getCommandName(); + return this.getPresentEntity() == null ? this.getUser() : this.getPresentEntity().getRawName(); } // public void processCmdBlock(CPacketCmdBlock packetIn) {