net.minecraft.entity.Entity.getName()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中net.minecraft.entity.Entity.getName()方法的一些代码示例,展示了Entity.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getName()方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:getName

Entity.getName介绍

暂无

代码示例

代码示例来源:origin: SquidDev-CC/plethora

@Nonnull
@Override
public String getName() {
  return entity.getName();
}

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

protected boolean isTargetNameValid(Entity entity) {
  return entity.getName().matches(regex);
}

代码示例来源:origin: TehNut/HWYLA

@Nonnull
@Override
public List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
  if (!Strings.isNullOrEmpty(FormattingConfig.entityFormat)) {
    try {
      currenttip.add("\u00a7r" + String.format(FormattingConfig.entityFormat, entity.getName()));
    } catch (Exception e) {
      currenttip.add("\u00a7r" + String.format(FormattingConfig.entityFormat, "Unknown"));
    }
  } else currenttip.add("Unknown");
  return currenttip;
}

代码示例来源:origin: Vazkii/Patchouli

private void loadEntity(World world) {
  if(!errored && (entity == null || entity.isDead)) {
    try {
      entity = creator.create(world);
      
      float entitySize = entity.width;
      if(entity.width < entity.height)
        entitySize = entity.height;
      entitySize = Math.max(1F, entitySize);
      
      renderScale = 100F / entitySize * 0.8F * scale;
      offset = Math.max(entity.height, entitySize) * 0.5F + extraOffset;
      
      if(name == null || name.isEmpty())
        name = entity.getName();
    } catch(Exception e) {
      errored = true;
      e.printStackTrace();
    }
  }
}

代码示例来源:origin: SquidDev-CC/plethora

public static HashMap<Object, Object> getBasicProperties(@Nonnull Entity entity, @Nullable IWorldLocation location) {
  HashMap<Object, Object> result = Maps.newHashMap();
  result.put("id", entity.getUniqueID().toString());
  result.put("name", Helpers.getName(entity));
  result.put("displayName", entity.getName());
  result.put("motionX", entity.motionX);
  result.put("motionY", entity.motionY);
  result.put("motionZ", entity.motionZ);
  result.put("pitch", entity.rotationPitch);
  result.put("yaw", entity.rotationYaw);
  if (location != null && location.getWorld() == entity.getEntityWorld()) {
    Vec3d pos = location.getLoc();
    result.put("x", entity.posX - pos.x);
    result.put("y", entity.posY + entity.getEyeHeight() - pos.y);
    result.put("z", entity.posZ - pos.z);
  }
  return result;
}

代码示例来源:origin: CyclopsMC/IntegratedDynamics

@Override
public String toCompactString(ValueEntity value) {
  Optional<UUID> uuid = value.getUuid();
  if (uuid.isPresent()) {
    Optional<Entity> entity = value.getRawValue();
    String entityName = "unknown";
    if(entity.isPresent()) {
      Entity e = entity.get();
      if(e instanceof EntityItem) {
        entityName = ((EntityItem) e).getItem().getDisplayName();
      } else {
        entityName = e.getName();
      }
    }
    return entityName;
  }
  return "";
}

代码示例来源:origin: SquidDev-CC/plethora

@Nonnull
public static String getName(Entity entity) {
  String name = EntityList.getEntityString(entity);
  if (name == null) {
    if (entity instanceof EntityPlayer) {
      return entity.getName();
    } else if (entity.hasCustomName()) {
      return entity.getCustomNameTag();
    } else {
      return "unknown";
    }
  } else {
    return name;
  }
}

代码示例来源:origin: SquidDev-CC/plethora

public PlethoraFakePlayer(WorldServer world, Entity owner, GameProfile profile) {
  super(world, profile != null && profile.isComplete() ? profile : PROFILE);
  connection = new FakeNetHandler(this);
  setSize(0, 0);
  if (owner != null) {
    setCustomNameTag(owner.getName());
    this.owner = new WeakReference<>(owner);
  } else {
    this.owner = null;
  }
}

代码示例来源:origin: TeamWizardry/Wizardry

@Override
public void collideWithEntity(Entity entity) {
  if (getHealth() > 0) {
    if (entity.getName().equals(getName())) return;
    ((EntityLivingBase) entity).motionY += 0.3;
    ((EntityLivingBase) entity).attackEntityAsMob(this);
    ((EntityLivingBase) entity).setRevengeTarget(this);
  }
  entity.fallDistance = 0;
  //if (entity.world.isRemote)
  //	LibParticles.AIR_THROTTLE(world, getPositionVector(), entity, color, color.brighter(), -1);
}

代码示例来源:origin: TehNut/HWYLA

@Nonnull
@Override
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
  Block block = accessor.getBlock();
  // Adds spawned entity to end of block name
  if (block == mobSpawner && accessor.getTileEntity() instanceof TileEntityMobSpawner && config.getConfig("vanilla.spawntype")) {
    String name = currenttip.get(0);
    String mobname = ((TileEntityMobSpawner) accessor.getTileEntity()).getSpawnerBaseLogic().getCachedEntity().getName();//(accessor.getWorld()).getName();
    currenttip.set(0, String.format("%s (%s)", name, mobname));
  }
  // For some reason, the meta gets added to the tooltip. This removes it.
  if (block == redstone) {
    String name = currenttip.get(0).replaceFirst(String.format(" %s", accessor.getMetadata()), "");
    currenttip.set(0, name);
  }
  // Melon Stem instead of Melon Seeds
  if (block == melonStem)
    currenttip.set(0, TextFormatting.WHITE + I18n.translateToLocal("hud.item.melonstem"));
  // Pumpkin Stem instead of Pumpkin Seeds
  if (block == pumpkinStem)
    currenttip.set(0, TextFormatting.WHITE + I18n.translateToLocal("hud.item.pumpkinstem"));
  return currenttip;
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
protected void damageEntity(DamageSource damageSrc, float damageAmount) {
  super.damageEntity(damageSrc, damageAmount);
  if (damageSrc.damageType.equals("player")) {
    //noinspection ConstantConditions
    revengePlayers.put(damageSrc.getTrueSource().getName(), world.getTotalWorldTime() + HIT_REVENGE_TICKS);
  } else if ((damageSrc.damageType.equals("mob") && damageSrc.getTrueSource() instanceof NpcBase)) {
    revengePlayers.put(((NpcBase) damageSrc.getTrueSource()).getOwner().getName(), world.getTotalWorldTime() + HIT_REVENGE_TICKS);
  }
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

public boolean isOwnerOrSameTeamOrFriend(@Nullable Entity entity) {
  if (entity instanceof IOwnable) {
    Owner owner = ((IOwnable) entity).getOwner();
    return isOwnerOrSameTeamOrFriend(entity.world, owner.getUUID(), owner.getName());
  }
  return entity != null && isOwnerOrSameTeamOrFriend(entity.world, entity.getUniqueID(), entity.getName());
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
public boolean isHostileTowards(Entity e) {
  if (e instanceof EntityPlayer || e instanceof NpcPlayerOwned) {
    String playerName = e instanceof EntityPlayer ? e.getName() : ((NpcBase) e).getOwner().getName();
    return revengePlayers.keySet().contains(playerName) || FactionTracker.INSTANCE.getStandingFor(world, playerName, getFaction()) < 0;
  } else if (e instanceof NpcFaction) {
    NpcFaction npc = (NpcFaction) e;
    return !npc.getFaction().equals(factionName) && FactionRegistry.getFaction(getFaction()).isHostileTowards(npc.getFaction());
  } else {
    return FactionRegistry.getFaction(factionName).isTarget(e) || AIHelper.isAdditionalEntityToTarget(e);
  }
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

public static boolean shouldEffectEntity(World world, Entity entity, MissileBase missile) {
  if (!AWVehicleStatics.allowFriendlyFire && missile.shooterLiving instanceof NpcBase) {
    @Nonnull NpcBase npc = ((NpcBase) missile.shooterLiving);
    if (entity instanceof NpcBase) {
      Owner targetNpcOwner = ((NpcBase) entity).getOwner();
      return !npc.getOwner().isOwnerOrSameTeamOrFriend(world, targetNpcOwner.getUUID(), targetNpcOwner.getName());
    } else if (entity instanceof EntityPlayer) {
      return !npc.getOwner().isOwnerOrSameTeamOrFriend(world, entity.getUniqueID(), entity.getName());
    }
  }
  return true;
}

代码示例来源:origin: vadis365/TheErebus

@Override
public void onCollideWithPlayer(EntityPlayer player) {
  super.onCollideWithPlayer(player);
  if (!getEntityWorld().isRemote)
    if (!player.isBeingRidden()) {
      startRiding(player, true);
      setPersistanceOnPlayer(player.getCommandSenderEntity().getName()); // may not work
    }
}

代码示例来源:origin: WayofTime/BloodMagic

public static SoulTicket ticket(World world, Entity entity, int amount) {
    return new SoulTicket(new TextComponentString("teleport|" + world.provider.getDimension() + "|" + entity.getName() + "|" + entity.getPosition().toLong()), amount);
  }
}

代码示例来源:origin: McJtyMods/TheOneProbe

private void showMobSpawnerInfo(IProbeInfo probeInfo, World world, IProbeHitData data, Block block) {
  if (block instanceof BlockMobSpawner) {
    TileEntity te = world.getTileEntity(data.getPos());
    if (te instanceof TileEntityMobSpawner) {
      MobSpawnerBaseLogic logic = ((TileEntityMobSpawner) te).getSpawnerBaseLogic();
      String mobName = logic.getCachedEntity().getName();
      probeInfo.horizontal(probeInfo.defaultLayoutStyle()
        .alignment(ElementAlignment.ALIGN_CENTER))
        .text(LABEL + "Mob: " + INFO + mobName);
    }
  }
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
public void onDeath(DamageSource damageSource) {
  super.onDeath(damageSource);
  if (damageSource.getTrueSource() instanceof EntityPlayer || damageSource.getTrueSource() instanceof NpcPlayerOwned) {
    String playerName = damageSource.getTrueSource() instanceof EntityPlayer ? damageSource.getTrueSource().getName() :
        ((NpcBase) damageSource.getTrueSource()).getOwner().getName();
    FactionTracker.INSTANCE.adjustStandingFor(world, playerName, getFaction(), -AWNPCStatics.factionLossOnDeath);
    setDeathRevengePlayer(playerName);
    world.getEntitiesWithinAABB(NpcFaction.class, new AxisAlignedBB(getPosition()).grow(REVENGE_SET_RANGE))
        .forEach(factionNpc -> {
          if (factionNpc.getFaction().equals(getFaction())) {
            factionNpc.setDeathRevengePlayer(playerName);
          }
        });
  }
}

代码示例来源:origin: SquidDev-CC/plethora

@Nonnull
@Override
protected HoverEvent getHoverEvent() {
  NBTTagCompound tag = new NBTTagCompound();
  Entity owner = getOwner();
  if (owner != null) {
    tag.setString("id", owner.getCachedUniqueIdString());
    tag.setString("name", owner.getName());
    ResourceLocation type = EntityList.getKey(owner);
    if (type != null) tag.setString("type", type.toString());
  } else {
    tag.setString("id", getCachedUniqueIdString());
    tag.setString("name", getName());
  }
  return new HoverEvent(HoverEvent.Action.SHOW_ENTITY, new TextComponentString(tag.toString()));
}

代码示例来源:origin: Funwayguy/BetterQuesting

private String getButtonTitle(NBTTagCompound tag)
  {
    if(JsonHelper.isItem(tag))
    {
      BigItemStack stack = JsonHelper.JsonToItemStack(tag);
      return QuestTranslation.translate("betterquesting.btn.item") + ": " + stack.getBaseStack().getDisplayName();
    } else if(JsonHelper.isFluid(tag))
    {
      FluidStack fluid = JsonHelper.JsonToFluidStack(tag);
      return QuestTranslation.translate("betterquesting.btn.fluid") + ": " + fluid.getLocalizedName();
    } else if(JsonHelper.isEntity(tag))
    {
      Entity entity = JsonHelper.JsonToEntity(tag, this.mc.world);
      return QuestTranslation.translate("betterquesting.btn.entity") + ": " + entity.getName();
    }
    
    return "Object...";
  }
}

相关文章

微信公众号

最新文章

更多

Entity类方法