本文整理汇总了Java中net.minecraft.block.Block.getSoundType方法的典型用法代码示例。如果您正苦于以下问题:Java Block.getSoundType方法的具体用法?Java Block.getSoundType怎么用?Java Block.getSoundType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.block.Block
的用法示例。
在下文中一共展示了Block.getSoundType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockActivated
import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
boolean isBlock = stack.getItem() instanceof ItemBlock && stack.getItem() != ModItems.ANGSTROM;
if(!world.isRemote && isBlock) {
//Replace
ItemBlock item = (ItemBlock) stack.getItem();
Block block = Block.getBlockFromItem(item);
int meta = item.getMetadata(stack);
IBlockState inState = block.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, player, hand);
world.setBlockState(pos, inState);
block.onBlockPlacedBy(world, pos, inState, player, stack);
SoundType sound = block.getSoundType(inState, world, pos, player);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), sound.getPlaceSound(), SoundCategory.BLOCKS, 0.75F, 0.8F);
//Exchange
ItemStack drop = new ItemStack(Item.getItemFromBlock(this));
ItemHandlerHelper.giveItemToPlayer(player, drop);
if(!player.capabilities.isCreativeMode) {
stack.shrink(1);
}
}
return isBlock;
}
示例2: doBlockInteraction
import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
protected boolean doBlockInteraction(BlockPos pos, double distToBlock) {
if (drone.getPathNavigator().hasNoPath()) {
EnumFacing side = ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides());
for (int i = 0; i < drone.getInv().getSlots(); i++) {
ItemStack droneStack = drone.getInv().getStackInSlot(i);
if (droneStack.getItem() instanceof ItemBlock && ((ItemBlock) droneStack.getItem()).getBlock().canPlaceBlockOnSide(drone.world(), pos, ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides()))) {
if (widget.isItemValidForFilters(droneStack)) {
ItemBlock itemBlock = (ItemBlock) droneStack.getItem();
Block block = itemBlock.getBlock();
if (drone.world().mayPlace(block, pos, false, side, drone instanceof EntityDrone ? (EntityDrone) drone : null)) {
int newMeta = itemBlock.getMetadata(droneStack.getMetadata());
setFakePlayerAccordingToDir();
IBlockState iblockstate1 = block.getStateForPlacement(drone.world(), pos, side, side.getFrontOffsetX(), side.getFrontOffsetY(), side.getFrontOffsetZ(), newMeta, drone.getFakePlayer(), EnumHand.MAIN_HAND);
if (itemBlock.placeBlockAt(droneStack, drone.getFakePlayer(), drone.world(), pos, side, side.getFrontOffsetX(), side.getFrontOffsetY(), side.getFrontOffsetZ(), iblockstate1)) {
drone.addAir(null, -PneumaticValues.DRONE_USAGE_PLACE);
SoundType soundType = block.getSoundType(iblockstate1, drone.world(), pos, drone.getFakePlayer());
drone.world().playSound(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F, false);
droneStack.shrink(1);
if (droneStack.getCount() <= 0) {
drone.getInv().setStackInSlot(i, ItemStack.EMPTY);
}
}
return false;
}
}
}
}
return false;
} else {
return true;
}
}
示例3: grabChest
import net.minecraft.block.Block; //导入方法依赖的package包/类
private void grabChest(TransportableChest chest, ItemStack stack, EntityPlayer player, World world, BlockPos pos)
{
TileEntity tile = world.getTileEntity(pos);
if (tile != null)
{
IBlockState iblockstate = world.getBlockState(pos);
Block chestBlock = iblockstate.getBlock();
getTagCompound(stack).setString("ChestName", chest.getRegistryName().toString());
if (chest.copyTileEntity())
{
NBTTagCompound nbt = new NBTTagCompound();
tile.writeToNBT(nbt);
getTagCompound(stack).setTag("ChestTile", nbt);
world.removeTileEntity(pos);
} else
{
IInventory inv = (IInventory) tile;
moveItemsIntoStack(inv, stack);
}
chest.preRemoveChest(world, pos, player, stack);
world.setBlockToAir(pos);
SoundType soundType = chestBlock.getSoundType();
world.playSound(player, pos, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F);
}
}
示例4: getBlockReflectivity
import net.minecraft.block.Block; //导入方法依赖的package包/类
private static float getBlockReflectivity(Int3 blockPos)
{
Block block = mc.theWorld.getBlockState(new BlockPos(blockPos.x, blockPos.y, blockPos.z)).getBlock();
SoundType soundType = block.getSoundType();
float reflectivity = 0.5f;
if (soundType == SoundType.STONE)
reflectivity = SoundPhysicsCore.Config.stoneReflectivity;
else if (soundType == SoundType.WOOD)
reflectivity = SoundPhysicsCore.Config.woodReflectivity;
else if (soundType == SoundType.GROUND)
reflectivity = SoundPhysicsCore.Config.groundReflectivity;
else if (soundType == SoundType.PLANT)
reflectivity = SoundPhysicsCore.Config.plantReflectivity;
else if (soundType == SoundType.METAL)
reflectivity = SoundPhysicsCore.Config.metalReflectivity;
else if (soundType == SoundType.GLASS)
reflectivity = SoundPhysicsCore.Config.glassReflectivity;
else if (soundType == SoundType.CLOTH)
reflectivity = SoundPhysicsCore.Config.clothReflectivity;
else if (soundType == SoundType.SAND)
reflectivity = SoundPhysicsCore.Config.sandReflectivity;
else if (soundType == SoundType.SNOW)
reflectivity = SoundPhysicsCore.Config.snowReflectivity;
else if (soundType == SoundType.LADDER)
reflectivity = SoundPhysicsCore.Config.woodReflectivity;
else if (soundType == SoundType.ANVIL)
reflectivity = SoundPhysicsCore.Config.metalReflectivity;
reflectivity *= SoundPhysicsCore.Config.globalBlockReflectance;
return reflectivity;
}
示例5: playStepSound
import net.minecraft.block.Block; //导入方法依赖的package包/类
protected void playStepSound(BlockPos pos, Block blockIn)
{
SoundType soundtype = blockIn.getSoundType();
if (this.world.getBlockState(pos.up()).getBlock() == Blocks.SNOW_LAYER)
{
soundtype = Blocks.SNOW_LAYER.getSoundType();
this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
else if (!blockIn.getDefaultState().getMaterial().isLiquid())
{
this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
}
示例6: fall
import net.minecraft.block.Block; //导入方法依赖的package包/类
public void fall(float distance, float damageMultiplier)
{
int i = MathHelper.ceil((distance * 0.5F - 3.0F) * damageMultiplier);
if (i > 0)
{
if (distance >= 6.0F)
{
this.attackEntityFrom(DamageSource.fall, (float)i);
if (this.isBeingRidden())
{
for (Entity entity : this.getRecursivePassengers())
{
entity.attackEntityFrom(DamageSource.fall, (float)i);
}
}
}
IBlockState iblockstate = this.world.getBlockState(new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ));
Block block = iblockstate.getBlock();
if (iblockstate.getMaterial() != Material.AIR && !this.isSilent())
{
SoundType soundtype = block.getSoundType();
this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, soundtype.getStepSound(), this.getSoundCategory(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F);
}
}
}
示例7: fall
import net.minecraft.block.Block; //导入方法依赖的package包/类
public void fall(float distance, float damageMultiplier)
{
if (distance > 1.0F)
{
this.playSound(SoundEvents.ENTITY_HORSE_LAND, 0.4F, 1.0F);
}
int i = MathHelper.ceil((distance * 0.5F - 3.0F) * damageMultiplier);
if (i > 0)
{
this.attackEntityFrom(DamageSource.fall, (float)i);
if (this.isBeingRidden())
{
for (Entity entity : this.getRecursivePassengers())
{
entity.attackEntityFrom(DamageSource.fall, (float)i);
}
}
IBlockState iblockstate = this.world.getBlockState(new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ));
Block block = iblockstate.getBlock();
if (iblockstate.getMaterial() != Material.AIR && !this.isSilent())
{
SoundType soundtype = block.getSoundType();
this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, soundtype.getStepSound(), this.getSoundCategory(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F);
}
}
}
示例8: playStepSound
import net.minecraft.block.Block; //导入方法依赖的package包/类
protected void playStepSound(BlockPos pos, Block blockIn)
{
if (!blockIn.getDefaultState().getMaterial().isLiquid())
{
SoundType soundtype = blockIn.getSoundType();
if (this.world.getBlockState(pos.up()).getBlock() == Blocks.SNOW_LAYER)
{
soundtype = Blocks.SNOW_LAYER.getSoundType();
}
if (this.isBeingRidden() && this.field_190688_bE)
{
++this.gallopTime;
if (this.gallopTime > 5 && this.gallopTime % 3 == 0)
{
this.func_190680_a(soundtype);
}
else if (this.gallopTime <= 5)
{
this.playSound(SoundEvents.ENTITY_HORSE_STEP_WOOD, soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
}
else if (soundtype == SoundType.WOOD)
{
this.playSound(SoundEvents.ENTITY_HORSE_STEP_WOOD, soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
else
{
this.playSound(SoundEvents.ENTITY_HORSE_STEP, soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
}
}
示例9: playStepSound
import net.minecraft.block.Block; //导入方法依赖的package包/类
protected void playStepSound(BlockPos pos, Block blockIn)
{
SoundType soundtype = blockIn.getSoundType(worldObj.getBlockState(pos), worldObj, pos, this);
if (this.worldObj.getBlockState(pos.up()).getBlock() == Blocks.SNOW_LAYER)
{
soundtype = Blocks.SNOW_LAYER.getSoundType();
this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
else if (!blockIn.getDefaultState().getMaterial().isLiquid())
{
this.playSound(soundtype.getStepSound(), soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
}
示例10: fall
import net.minecraft.block.Block; //导入方法依赖的package包/类
public void fall(float distance, float damageMultiplier)
{
if (distance > 1.0F)
{
this.playSound(SoundEvents.ENTITY_HORSE_LAND, 0.4F, 1.0F);
}
int i = MathHelper.ceiling_float_int((distance * 0.5F - 3.0F) * damageMultiplier);
if (i > 0)
{
this.attackEntityFrom(DamageSource.fall, (float)i);
if (this.isBeingRidden())
{
for (Entity entity : this.getRecursivePassengers())
{
entity.attackEntityFrom(DamageSource.fall, (float)i);
}
}
IBlockState iblockstate = this.worldObj.getBlockState(new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ));
Block block = iblockstate.getBlock();
if (iblockstate.getMaterial() != Material.AIR && !this.isSilent())
{
SoundType soundtype = block.getSoundType(iblockstate, worldObj, new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ), this);
this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, soundtype.getStepSound(), this.getSoundCategory(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F);
}
}
}
示例11: onPlayerDamageBlock
import net.minecraft.block.Block; //导入方法依赖的package包/类
public boolean onPlayerDamageBlock(BlockPos posBlock, EnumFacing directionFacing)
{
this.syncCurrentPlayItem();
if (this.blockHitDelay > 0)
{
--this.blockHitDelay;
return true;
}
else if (this.currentGameType.isCreative() && this.mc.world.getWorldBorder().contains(posBlock))
{
this.blockHitDelay = 5;
this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, posBlock, directionFacing));
clickBlockCreative(this.mc, this, posBlock, directionFacing);
return true;
}
else if (this.isHittingPosition(posBlock))
{
IBlockState iblockstate = this.mc.world.getBlockState(posBlock);
Block block = iblockstate.getBlock();
if (iblockstate.getMaterial() == Material.AIR)
{
this.isHittingBlock = false;
return false;
}
else
{
this.curBlockDamageMP += iblockstate.getPlayerRelativeBlockHardness(this.mc.player, this.mc.player.world, posBlock);
if (this.stepSoundTickCounter % 4.0F == 0.0F)
{
SoundType soundtype = block.getSoundType();
this.mc.getSoundHandler().playSound(new PositionedSoundRecord(soundtype.getHitSound(), SoundCategory.NEUTRAL, (soundtype.getVolume() + 1.0F) / 8.0F, soundtype.getPitch() * 0.5F, posBlock));
}
++this.stepSoundTickCounter;
if (this.curBlockDamageMP >= 1.0F)
{
this.isHittingBlock = false;
this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, posBlock, directionFacing));
this.onPlayerDestroyBlock(posBlock);
this.curBlockDamageMP = 0.0F;
this.stepSoundTickCounter = 0.0F;
this.blockHitDelay = 5;
}
this.mc.world.sendBlockBreakProgress(this.mc.player.getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
return true;
}
}
else
{
return this.clickBlock(posBlock, directionFacing);
}
}
示例12: playStepSound
import net.minecraft.block.Block; //导入方法依赖的package包/类
protected void playStepSound(BlockPos pos, Block blockIn)
{
SoundType soundtype = blockIn.getSoundType(worldObj.getBlockState(pos), worldObj, pos, this);
if (this.worldObj.getBlockState(pos.up()).getBlock() == Blocks.SNOW_LAYER)
{
soundtype = Blocks.SNOW_LAYER.getSoundType();
}
if (!blockIn.getDefaultState().getMaterial().isLiquid())
{
HorseType horsetype = this.getType();
if (this.isBeingRidden() && !horsetype.hasMuleEars())
{
++this.gallopTime;
if (this.gallopTime > 5 && this.gallopTime % 3 == 0)
{
this.playSound(SoundEvents.ENTITY_HORSE_GALLOP, soundtype.getVolume() * 0.15F, soundtype.getPitch());
if (horsetype == HorseType.HORSE && this.rand.nextInt(10) == 0)
{
this.playSound(SoundEvents.ENTITY_HORSE_BREATHE, soundtype.getVolume() * 0.6F, soundtype.getPitch());
}
}
else if (this.gallopTime <= 5)
{
this.playSound(SoundEvents.ENTITY_HORSE_STEP_WOOD, soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
}
else if (soundtype == SoundType.WOOD)
{
this.playSound(SoundEvents.ENTITY_HORSE_STEP_WOOD, soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
else
{
this.playSound(SoundEvents.ENTITY_HORSE_STEP, soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
}
}
示例13: onPlayerDamageBlock
import net.minecraft.block.Block; //导入方法依赖的package包/类
public boolean onPlayerDamageBlock(BlockPos posBlock, EnumFacing directionFacing)
{
this.syncCurrentPlayItem();
if (this.blockHitDelay > 0)
{
--this.blockHitDelay;
return true;
}
else if (this.currentGameType.isCreative() && this.mc.theWorld.getWorldBorder().contains(posBlock))
{
this.blockHitDelay = 5;
this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, posBlock, directionFacing));
clickBlockCreative(this.mc, this, posBlock, directionFacing);
return true;
}
else if (this.isHittingPosition(posBlock))
{
IBlockState iblockstate = this.mc.theWorld.getBlockState(posBlock);
Block block = iblockstate.getBlock();
if (iblockstate.getMaterial() == Material.AIR)
{
this.isHittingBlock = false;
return false;
}
else
{
this.curBlockDamageMP += iblockstate.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, posBlock);
if (this.stepSoundTickCounter % 4.0F == 0.0F)
{
SoundType soundtype = block.getSoundType(iblockstate, mc.theWorld, posBlock, mc.thePlayer);
this.mc.getSoundHandler().playSound(new PositionedSoundRecord(soundtype.getHitSound(), SoundCategory.NEUTRAL, (soundtype.getVolume() + 1.0F) / 8.0F, soundtype.getPitch() * 0.5F, posBlock));
}
++this.stepSoundTickCounter;
if (this.curBlockDamageMP >= 1.0F)
{
this.isHittingBlock = false;
this.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, posBlock, directionFacing));
this.onPlayerDestroyBlock(posBlock);
this.curBlockDamageMP = 0.0F;
this.stepSoundTickCounter = 0.0F;
this.blockHitDelay = 5;
}
this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.currentBlock, (int)(this.curBlockDamageMP * 10.0F) - 1);
return true;
}
}
else
{
return this.clickBlock(posBlock, directionFacing);
}
}