Java Code Examples for net.minecraft.entity.Entity#getName()

The following examples show how to use net.minecraft.entity.Entity#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MinecraftTypeHelper.java    From malmo with MIT License 6 votes vote down vote up
/** Does essentially the same as entity.getName(), but without pushing the result
 * through the translation layer. This ensures the result matches what we use in Types.XSD,
 * and prevents things like "entity.ShulkerBullet.name" being returned, where there is no
 * translation provided in the .lang file.
 * @param e The entity
 * @return The entity's name.
 */
public static String getUnlocalisedEntityName(Entity e)
{
    String name;
    if (e.hasCustomName())
    {
        name = e.getCustomNameTag();
    }
    else if (e instanceof EntityPlayer)
    {
        name = e.getName(); // Just returns the user name
    }
    else
    {
        name = EntityList.getEntityString(e);
        if (name == null)
            name = "unknown";
    }
    return name;
}
 
Example 2
Source File: EntityRequest.java    From HoloInventory with MIT License 6 votes vote down vote up
@Override
public ResponseMessage onMessage(EntityRequest message, MessageContext ctx)
{
    World world = DimensionManager.getWorld(message.dim);
    if (world == null) return null;
    Entity entity = world.getEntityByID(message.id);
    if (entity == null) return null;

    if (entity instanceof IInventory) return new PlainInventory(message.id, (IInventory) entity);
    else if (entity instanceof IMerchant) return new MerchantRecipes(message.id, (IMerchant) entity, ctx.getServerHandler().player);
    else if (entity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
    {
        return new PlainInventory(message.id, entity.getName(), entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null));
    }

    return null;
}
 
Example 3
Source File: WallHackModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
private String getNameForEntity(Entity entity) {
        if (entity instanceof EntityItem) {
            final EntityItem item = (EntityItem) entity;
            String itemName = "";

            final int stackSize = item.getItem().getCount();
            if (stackSize > 1) {
                itemName = item.getItem().getDisplayName() + "(" + item.getItem().getCount() + ")";
            } else {
                itemName = item.getItem().getDisplayName();
            }
            return itemName;
        }
        if (entity instanceof EntityEnderCrystal) {
            return "End Crystal";
        }
        if (entity instanceof EntityEnderPearl) {
            final EntityEnderPearl pearl = (EntityEnderPearl) entity;
            //TODO resolve and draw username
//            return pearl.getCachedUniqueIdString();
            return "Ender Pearl";
        }
        if (entity instanceof EntityMinecart) {
            final EntityMinecart minecart = (EntityMinecart) entity;
            return minecart.getCartItem().getDisplayName();
        }
        return entity.getName();
    }
 
Example 4
Source File: CraftCustomEntity.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public CraftCustomEntity(CraftServer server, Entity entity) {
    super(server, entity);
    this.entityName = EntityRegistry.entityTypeMap.get(entity.getClass());
    if (entityName == null) {
        entityName = entity.getName();
    }
}
 
Example 5
Source File: QuestEnemyEncampment.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private String getEnemyNames(QuestData data) {
	String name = getEnemyType(data).get(0);
	try {
		Entity entity = TileEntityToroSpawner.getEntityForId(data.getPlayer().world, name);
		return entity.getName();
	} catch (Exception e) {
		System.out.println("failed to get name of entity [" + name + "] : " + e.getMessage());
		return "unknown enemy";
	}
}
 
Example 6
Source File: OwnerData.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public OwnerData(Entity entity)
{
    UUID uuid = entity.getUniqueID();
    this.ownerUUID = uuid;
    this.ownerUUIDMost = uuid != null ? uuid.getMostSignificantBits() : 0;
    this.ownerUUIDLeast = uuid != null ? uuid.getLeastSignificantBits() : 0;
    this.ownerName = entity.getName();
    this.isPublic = true;
}
 
Example 7
Source File: LexWand.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
private static String getBanMsg(Entity entity, Random rand) {
	String ban_header = "<Lex> BANNED " + TextFormatting.RED + entity.getName();
	String ban_reason =  TextFormatting.WHITE + " " + BAN_MSG[rand.nextInt(BAN_MSG.length)];
	return ban_header + ban_reason;
}
 
Example 8
Source File: EntityUtils.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isFriend(final Entity entity) {
    return entity instanceof EntityPlayer && entity.getName() != null &&
            LiquidBounce.fileManager.friendsConfig.isFriend(ColorUtils.stripColor(entity.getName()));
}
 
Example 9
Source File: QuestKillMobs.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private String mobName(Integer mobType, EntityPlayer player) {
	Entity mob = EntityList.createEntityByIDFromName(new ResourceLocation(MOB_TYPES[mobType]), player.world);
	return mob.getName();
}