本文整理了Java中net.minecraft.entity.Entity.getCustomNameTag()
方法的一些代码示例,展示了Entity.getCustomNameTag()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getCustomNameTag()
方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:getCustomNameTag
暂无
代码示例来源: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: PrinceOfAmber/Cyclic
@SubscribeEvent
public void onLivingDropsEvent(LivingDropsEvent event) {
Entity entity = event.getEntity();
World world = entity.getEntityWorld();
if (nameTagDeath) {
if (entity.getCustomNameTag() != null && entity.getCustomNameTag() != "") {
// item stack NBT needs the name enchanted onto it
if (world.isRemote == false) {
ItemStack nameTag = UtilNBT.buildEnchantedNametag(entity.getCustomNameTag());
UtilItemStack.dropItemStackInWorld(world, entity.getPosition(), nameTag);
}
}
}
if (endermanDrop && entity instanceof EntityEnderman) {
EntityEnderman mob = (EntityEnderman) entity;
IBlockState bs = mob.getHeldBlockState();
if (bs != null && bs.getBlock() != null && world.isRemote == false) {
UtilItemStack.dropItemStackInWorld(world, mob.getPosition(), bs.getBlock());
}
}
}
代码示例来源:origin: Vazkii/Quark
@SubscribeEvent
public void onDrops(LivingDropsEvent event) {
Entity e = event.getEntity();
if(e.hasCustomName() && e instanceof EntitySnowman && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityWitch) {
EntitySnowman snowman = (EntitySnowman) e;
if(snowman.isPumpkinEquipped()) {
ItemStack stack = new ItemStack(Items.SKULL, 1, 3);
ItemNBTHelper.setString(stack, "SkullOwner", e.getCustomNameTag());
event.getDrops().add(new EntityItem(e.getEntityWorld(), e.posX, e.posY, e.posZ, stack));
}
}
}
代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition
@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event) {
if (event.getEntity() instanceof EntityVillager && ((EntityVillager) event.getEntity()).getProfessionForge().equals(MatterOverdriveEntities.MAD_SCIENTIST_PROFESSION) && !event.getEntity().getClass().equals(EntityVillagerMadScientist.class)) {
event.setCanceled(true);
EntityVillagerMadScientist villager = new EntityVillagerMadScientist(event.getWorld());
villager.onInitialSpawn(event.getWorld().getDifficultyForLocation(((EntityVillager) event.getEntity()).getPos()), null);
villager.setGrowingAge(-24000);
villager.setLocationAndAngles(event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, 0.0F, 0.0F);
event.getWorld().spawnEntity(villager);
if (event.getEntity().hasCustomName()) {
villager.setCustomNameTag(event.getEntity().getCustomNameTag());
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!