Java Code Examples for net.minecraft.entity.Entity#getCustomNameTag()
The following examples show how to use
net.minecraft.entity.Entity#getCustomNameTag() .
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: PowerOrbManager.java From SkyblockAddons with MIT License | 6 votes |
/** * Detects a power orb from an entity, and puts it in this manager. * * @param entity The entity to detect whether it is a power orb or not. */ public void detectPowerOrb(Entity entity) { String customNameTag = entity.getCustomNameTag(); PowerOrb powerOrb = PowerOrb.getByDisplayname(customNameTag); if (powerOrb != null && Minecraft.getMinecraft().thePlayer != null && powerOrb.isInRadius(entity.getDistanceSqToEntity(Minecraft.getMinecraft().thePlayer))) { // TODO Make sure this works... customNameTag = TextUtils.stripColor(customNameTag); Matcher matcher = POWER_ORB_PATTERN.matcher(customNameTag); if (matcher.matches()) { String secondsString = matcher.group("seconds"); try { // Apparently they don't have a second count for moment after spawning, that's what this try-catch is for put(powerOrb, Integer.parseInt(secondsString)); } catch (NumberFormatException ex) { // It's okay, just don't add the power orb I guess... } } } }
Example 2
Source File: MinecraftTypeHelper.java From malmo with MIT License | 6 votes |
/** 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 3
Source File: RenderManagerHook.java From SkyblockAddons with MIT License | 5 votes |
public static void shouldRender(Entity entityIn, ReturnValue<Boolean> returnValue) { SkyblockAddons main = SkyblockAddons.getInstance(); if (main.getUtils().isOnSkyblock()) { Location currentLocation = main.getUtils().getLocation(); if (entityIn instanceof EntityItem && entityIn.ridingEntity instanceof EntityArmorStand && entityIn.ridingEntity.isInvisible()) { // Conditions for skeleton helmet flying bones if (main.getConfigValues().isEnabled(Feature.HIDE_BONES)) { returnValue.cancel(); } } if (main.getConfigValues().isEnabled(Feature.HIDE_PLAYERS_NEAR_NPCS)) { if (entityIn instanceof EntityOtherPlayerMP && NPCUtils.isNearAnyNPCWithTag(entityIn, Tag.IMPORTANT) && !NPCUtils.isNPC(entityIn)) { returnValue.cancel(); } } if (main.getConfigValues().isEnabled(Feature.HIDE_PLAYERS_IN_LOBBY)) { if (currentLocation == Location.VILLAGE || currentLocation == Location.AUCTION_HOUSE || currentLocation == Location.BANK) { if ((entityIn instanceof EntityOtherPlayerMP || entityIn instanceof EntityFX || entityIn instanceof EntityItemFrame) && entityIn.getDistanceToEntity(Minecraft.getMinecraft().thePlayer) > 7) { returnValue.cancel(); } } } if(main.getConfigValues().isEnabled(Feature.HIDE_SVEN_PUP_NAMETAGS)) { if (entityIn instanceof EntityArmorStand && entityIn.hasCustomName()) { String customNameTag = entityIn.getCustomNameTag(); if (customNameTag.contains("Sven Pup")) { returnValue.cancel(); } } } } }