net.minecraft.block.Block.getSoundType()方法的使用及代码示例

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

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

Block.getSoundType介绍

暂无

代码示例

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

public BlockLivingSlab(boolean full, IBlockState state) {
  super(full, state.getMaterial(), state.getBlock().getTranslationKey().replaceAll("tile.", "") + state.getBlock().getMetaFromState(state) + "Slab" + (full ? "Full" : ""));
  setSoundType(state.getBlock().getSoundType());
  sourceState = state;
}

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

private boolean placeBlock(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xOffset, float yOffset, float zOffset) {
  IBlockState iblockstate = world.getBlockState(pos);
  Block block = iblockstate.getBlock();
  if(!block.isReplaceable(world, pos)) {
    pos = pos.offset(side);
  }
  if(itemstack.isEmpty()) {
    return false;
  } else if(!player.canPlayerEdit(pos, side, itemstack)) {
    return false;
  } else if(world.mayPlace(Blocks.MOB_SPAWNER, pos, false, side, null)) {
    int meta = this.getMetadata(itemstack.getMetadata());
    IBlockState iblockstate1 = Blocks.MOB_SPAWNER.getStateForPlacement(world, pos, side, xOffset, yOffset, zOffset, meta, player);
    if (placeBlockAt(itemstack, player, world, pos, side, xOffset, yOffset, zOffset, iblockstate1)) {
      world.playSound(null, pos, Blocks.MOB_SPAWNER.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (Blocks.MOB_SPAWNER.getSoundType().getVolume() + 1.0F) / 2.0F, Blocks.MOB_SPAWNER.getSoundType().getPitch() * 0.8F);
      player.renderBrokenItemStack(itemstack);
      itemstack.shrink(1);
      for(int i = 0; i < 100; i++)
        Botania.proxy.sparkleFX(pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6);
    }
    return true;
  } else {
    return false;
  }
}

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

block1 = Blocks.FARMLAND;
world.playSound(null, pos, block1.getSoundType().getStepSound(), SoundCategory.BLOCKS, (block1.getSoundType().getVolume() + 1.0F) / 2.0F, block1.getSoundType().getPitch() * 0.8F);

代码示例来源:origin: TerraFirmaCraft/TerraFirmaCraft

@SuppressWarnings("deprecation")
@Override
public SoundType getSoundType()
{
  return modelBlock.getSoundType();
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

.playSound( new PositionedSoundRecord( block.getSoundType()
    .getBreakSound(), SoundCategory.BLOCKS, ( block.getSoundType().getVolume() + 1.0F ) / 2.0F, block.getSoundType()
        .getPitch() * 0.8F, (float) this.x + 0.5F, (float) this.y + 0.5F, (float) this.z + 0.5F ) );

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

event.getEntityPlayer().swingArm(event.getHand());
else {
  event.getWorld().playSound(null, event.getPos(), block.getSoundType().getBreakSound(), SoundCategory.BLOCKS, block.getSoundType().getVolume() * 0.4F, block.getSoundType().getPitch() + (float) (Math.random() * 0.2 - 0.1));

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

@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  // Copy of ItemBlock.onItemUse
  IBlockState iblockstate = world.getBlockState(pos);
  Block block = iblockstate.getBlock();
  if (!block.isReplaceable(world, pos))
  {
    pos = pos.offset(facing);
  }
  ItemStack stack = player.getHeldItem(hand);
  if (!stack.isEmpty() && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(ModBlocks.buriedPetals, pos, false, facing, null))
  {
    int i = this.getMetadata(stack.getMetadata());
    IBlockState iblockstate1 = ModBlocks.buriedPetals.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player);
    if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1))
    {
      SoundType soundtype = ModBlocks.buriedPetals.getSoundType();
      world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
      stack.shrink(1);
    }
    return EnumActionResult.SUCCESS;
  }
  else
  {
    return EnumActionResult.FAIL;
  }
}

代码示例来源:origin: SleepyTrousers/EnderIO

@SuppressWarnings("deprecation")
@Override
@Nonnull
public SoundType getSoundType(@Nonnull IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nullable Entity entity) {
 IConduitBundle te = getTileEntitySafe(world, pos);
 if (te != null && te.hasFacade()) {
  return te.getPaintSourceNN().getBlock().getSoundType();
 }
 return super.getSoundType(state, world, pos, entity);
}

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

@SuppressWarnings("deprecation")
public static void playPlaceSound(World world, BlockPos pos) {
  Block block = BlockCable.getInstance();
  world.playSound((double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY() + 0.5F), (double) ((float) pos.getZ() + 0.5F),
      block.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (block.getSoundType().getVolume() + 1.0F) / 2.0F, block.getSoundType().getPitch() * 0.8F, false);
}

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

@Override
@SideOnly(Side.CLIENT)
public void actionClient(World world, EntityPlayer player) {
  Block block = Block.getBlockById(blockID);
  world.playSound(x, y, z, block.getSoundType().getBreakSound(), SoundCategory.BLOCKS, 0.1F + world.rand.nextFloat() * 0.5F,
      0.9F + world.rand.nextFloat() * 0.1F, false);
  ParticleBloodSplash.spawnParticles(world, new BlockPos((int) x, (int) y + 1, (int) z), 3 + world.rand.nextInt(2), 1 + world.rand.nextInt(2));
}

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

public BlockWallErebus(IBlockState state) {
  super(state.getMaterial());
  setSoundType(state.getBlock().getSoundType());
  setHardness(2.0F);
  this.setDefaultState(this.blockState.getBaseState().withProperty(UP, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)) .withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
  setCreativeTab(ModTabs.BLOCKS);
  baseBlockState = state;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

final SoundType ss = multiPartBlock.getSoundType( state, world, pos, player );

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

public BlockWoodFence(IBlockState state) {
  super(state.getMaterial(), state.getMaterial().getMaterialMapColor());
  setSoundType(state.getBlock().getSoundType());
  setHardness(2.0F);
  setDefaultState(this.blockState.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
  setCreativeTab(ModTabs.BLOCKS);
}

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

public BlockWoodFenceGate(IBlockState state) {
  super(state.getMaterial(), state.getMaterial().getMaterialMapColor());
  setSoundType(state.getBlock().getSoundType());
  setHardness(2.0F);
  this.setDefaultState(this.blockState.getBaseState().withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false)));
  this.setCreativeTab(ModTabs.BLOCKS);
}

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

public BlockQuarkWall(String name, IBlockState state) {
  super(name, state.getMaterial());
  setHardness(state.getBlockHardness(null, new BlockPos(0, 0, 0)));
  setResistance(state.getBlock().getExplosionResistance(null) * 5F / 3F);
  setSoundType(state.getBlock().getSoundType());
  setDefaultState(blockState.getBaseState().withProperty(UP, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
  setCreativeTab(CreativeTabs.DECORATIONS);
}

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

private void playBlockSound(World world, RayTraceResult hit, IBlockState state) {
  SoundType sound = state.getBlock().getSoundType(state, world, hit.getBlockPos(), null);
  if (sound != null) {
    world.playSound(null, hit.getBlockPos(), sound.getPlaceSound(), SoundCategory.BLOCKS, sound.getVolume() * 0.5F, sound.getPitch() * 0.8F);
  }
}

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

@SuppressWarnings("deprecation")
public BlockSlabErebus(IBlockState state, String harvestType, int harvestLevel) {
  super(state.getMaterial(), harvestType, harvestLevel);
  setSoundType(state.getBlock().getSoundType());
  setDefaultState(blockState.getBaseState().withProperty(HALF, EnumBlockHalf.BOTTOM));
  setHardness(2.0F);
  setLightOpacity(0);
  setCreativeTab(ModTabs.BLOCKS);
}

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

public BlockVanillaSlab(String name, IBlockState state, boolean doubleSlab) {
  super(name, state.getMaterial(), doubleSlab);
  setHardness(state.getBlockHardness(null, new BlockPos(0, 0, 0)));
  setResistance(state.getBlock().getExplosionResistance(null) * 5F / 3F);
  setSoundType(state.getBlock().getSoundType());
  setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
}

代码示例来源:origin: Ellpeck/ActuallyAdditions

@SuppressWarnings("deprecation")
public BlockWallAA(String name, Block blocc){
  super(blocc.getDefaultState().getMaterial(), name);
  this.setHardness(1.5F);
  this.setResistance(10F);
  this.setSoundType(blocc.getSoundType());
  this.setDefaultState(this.blockState.getBaseState().withProperty(BlockWall.UP, false).withProperty(BlockWall.NORTH, false).withProperty(BlockWall.EAST, false).withProperty(BlockWall.SOUTH, false).withProperty(BlockWall.WEST, false));
}

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

@SubscribeEvent
public void leftClick(PlayerInteractEvent.LeftClickBlock event) {
  if(event.getEntityPlayer().getHeldItemMainhand().isEmpty()) {
    IBlockState state = event.getWorld().getBlockState(event.getPos());
    Block block = state.getBlock();
    if(block instanceof BlockDoor && state.getMaterial() == Material.WOOD)
      event.getWorld().playSound(null, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), block.getSoundType().getPlaceSound(), SoundCategory.PLAYERS, 1F, 1F);
  }
}

相关文章

Block类方法