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

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

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

Entity.playSound介绍

暂无

代码示例

代码示例来源:origin: CoFH/CoFHCore

public static boolean teleportEntityTo(Entity entity, double x, double y, double z) {
  if (entity instanceof EntityLivingBase) {
    return teleportEntityTo((EntityLivingBase) entity, x, y, z);
  } else {
    entity.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);
    entity.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
  }
  return true;
}

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

@SubscribeEvent
public void entityUpdate(LivingUpdateEvent event) {
  Entity e = event.getEntity();
  if(e instanceof EntityParrot) {
    int time = e.getEntityData().getInteger(TAG_EGG_TIMER);
    if(time > 0) {
      if(time == 1) {
        e.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (e.world.rand.nextFloat() - e.world.rand.nextFloat()) * 0.2F + 1.0F);
        e.entityDropItem(new ItemStack(parrot_egg, 1, getResultingEggColor((EntityParrot) e)), 0);
      }
      e.getEntityData().setInteger(TAG_EGG_TIMER, time - 1);
    }
  }
}

代码示例来源:origin: CoFH/ThermalFoundation

@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
  if (!effect || ServerHelper.isClientWorld(world)) {
    return;
  }
  if (world.getTotalWorldTime() % 4 == 0) {
    if (MathHelper.RANDOM.nextInt(100) != 0) {
      return;
    }
    BlockPos randPos = pos.add(8 + world.rand.nextInt(17), world.rand.nextInt(8), 8 + world.rand.nextInt(17));
    if (!world.getBlockState(randPos).getMaterial().isSolid()) {
      if (entity instanceof EntityLivingBase) {
        CoreUtils.teleportEntityTo(entity, randPos);
      } else {
        entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
        entity.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
      }
    }
  }
}

代码示例来源:origin: CoFH/ThermalFoundation

@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
  if (!effect || ServerHelper.isClientWorld(world)) {
    return;
  }
  if (world.getTotalWorldTime() % 8 == 0) {
    BlockPos randPos = pos.add(-8 + world.rand.nextInt(17), world.rand.nextInt(8), -8 + world.rand.nextInt(17));
    if (!world.getBlockState(randPos).getMaterial().isSolid()) {
      if (entity instanceof EntityLivingBase) {
        CoreUtils.teleportEntityTo(entity, randPos);
      } else {
        entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
        entity.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
      }
    }
  }
}

代码示例来源:origin: Mine-and-blade-admin/Battlegear2

if (dam > 0) {
  entityHit.attackEntityFrom(DamageSource.causeThornsDamage(this.player), dam);
  entityHit.playSound(SoundEvents.ENCHANT_THORNS_HIT, 0.5F, 1.0F);

代码示例来源:origin: Alex-the-666/Ice_and_Fire

if (pointedEntity instanceof EntityLiving || pointedEntity instanceof EntityPlayer) {
  if (pointedEntity instanceof EntityPlayer) {
    pointedEntity.playSound(ModSounds.GORGON_TURN_STONE, 1, 1);
    pointedEntity.attackEntityFrom(IceAndFire.gorgon, Integer.MAX_VALUE);
    EntityStoneStatue statue = new EntityStoneStatue(worldIn);

代码示例来源:origin: ValkyrienWarfare/Valkyrien-Warfare-Revamped

entity.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
} else if (!block.getDefaultState().getMaterial().isLiquid()) {
  entity.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());

相关文章

Entity类方法