本文整理匯總了Java中net.minecraft.util.SoundCategory類的典型用法代碼示例。如果您正苦於以下問題:Java SoundCategory類的具體用法?Java SoundCategory怎麽用?Java SoundCategory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SoundCategory類屬於net.minecraft.util包,在下文中一共展示了SoundCategory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onItemRightClick
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
ItemStack itemstack1 = worldIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_SPLASH_POTION_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!itemStackIn.isRemote)
{
EntityPotion entitypotion = new EntityPotion(itemStackIn, worldIn, itemstack1);
entitypotion.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, -20.0F, 0.5F, 1.0F);
itemStackIn.spawnEntityInWorld(entitypotion);
}
worldIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
示例2: playMoodSoundAndCheckLight
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
protected void playMoodSoundAndCheckLight(int p_147467_1_, int p_147467_2_, Chunk chunkIn)
{
super.playMoodSoundAndCheckLight(p_147467_1_, p_147467_2_, chunkIn);
if (this.ambienceTicks == 0)
{
this.updateLCG = this.updateLCG * 3 + 1013904223;
int i = this.updateLCG >> 2;
int j = i & 15;
int k = i >> 8 & 15;
int l = i >> 16 & 255;
BlockPos blockpos = new BlockPos(j + p_147467_1_, l, k + p_147467_2_);
IBlockState iblockstate = chunkIn.getBlockState(blockpos);
j = j + p_147467_1_;
k = k + p_147467_2_;
if (iblockstate.getMaterial() == Material.AIR && this.getLight(blockpos) <= this.rand.nextInt(8) && this.getLightFor(EnumSkyBlock.SKY, blockpos) <= 0 && this.mc.thePlayer != null && this.mc.thePlayer.getDistanceSq((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D) > 4.0D)
{
this.playSound((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D, SoundEvents.AMBIENT_CAVE, SoundCategory.AMBIENT, 0.7F, 0.8F + this.rand.nextFloat() * 0.2F, false);
this.ambienceTicks = this.rand.nextInt(12000) + 6000;
}
}
}
示例3: updateTick
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
BlockPos blockpos = pos.up();
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock() == Blocks.WATER || iblockstate.getBlock() == Blocks.FLOWING_WATER)
{
worldIn.setBlockToAir(blockpos);
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
if (worldIn instanceof WorldServer)
{
((WorldServer)worldIn).spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.25D, (double)blockpos.getZ() + 0.5D, 8, 0.5D, 0.25D, 0.5D, 0.0D, new int[0]);
}
}
}
示例4: onItemRightClick
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer playerIn, EnumHand handIn) {
ItemStack iStack = playerIn.getHeldItem(handIn);
if (iStack.getItemDamage() < iStack.getMaxDamage()) {
double factor = 0.2D * getPressure(iStack);
world.playSound(playerIn.posX, playerIn.posY, playerIn.posZ, Sounds.CANNON_SOUND, SoundCategory.PLAYERS, 1.0F, 0.7F + (float) factor * 0.2F, false);
EntityVortex vortex = new EntityVortex(world, playerIn);
Vec3d directionVec = playerIn.getLookVec().normalize();
vortex.posX += directionVec.x;
vortex.posY += directionVec.y;
vortex.posZ += directionVec.z;
vortex.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 0.0F);
vortex.motionX *= factor;
vortex.motionY *= factor;
vortex.motionZ *= factor;
if (!world.isRemote) world.spawnEntity(vortex);
iStack.setItemDamage(iStack.getItemDamage() + PneumaticValues.USAGE_VORTEX_CANNON);
if (iStack.getItemDamage() > iStack.getMaxDamage()) {
iStack.setItemDamage(iStack.getMaxDamage());
}
}
return ActionResult.newResult(EnumActionResult.SUCCESS, iStack);
}
示例5: tryPlace
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
private boolean tryPlace(EntityPlayer player, ItemStack stack, World worldIn, BlockPos pos, int subtype)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.singleSlab)
{
int subtype1 = singleSlabCS.getSubtype(iblockstate);
if (subtype1 == subtype)
{
IBlockState stateDouble = this.makeState(subtype1);
AxisAlignedBB axisalignedbb = stateDouble == null ? Block.NULL_AABB : stateDouble.getCollisionBoundingBox(worldIn, pos);
if (stateDouble != null && axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, stateDouble, 11))
{
SoundType soundtype = stateDouble.getBlock().getSoundType(stateDouble, worldIn, pos, player);
worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
stack.shrink(1);
}
return true;
}
}
return false;
}
示例6: tryPlace
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
private boolean tryPlace(EntityPlayer player, ItemStack stack, World worldIn, BlockPos pos, Object itemSlabType)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this.singleSlab)
{
Comparable<?> comparable = iblockstate.getValue(this.singleSlab.getVariantProperty());
if (comparable == itemSlabType)
{
IBlockState iblockstate1 = this.makeState(this.singleSlab.getVariantProperty(), comparable);
AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, pos);
if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, iblockstate1, 11))
{
SoundType soundtype = this.doubleSlab.getSoundType(iblockstate1, worldIn, pos, player);
worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
--stack.stackSize;
}
return true;
}
}
return false;
}
示例7: onItemRightClick
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
if (!worldIn.capabilities.isCreativeMode)
{
itemstack.func_190918_g(1);
}
itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!itemStackIn.isRemote)
{
EntitySnowball entitysnowball = new EntitySnowball(itemStackIn, worldIn);
entitysnowball.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, 0.0F, 1.5F, 1.0F);
itemStackIn.spawnEntityInWorld(entitysnowball);
}
worldIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
示例8: onItemRightClick
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_LINGERINGPOTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
EntityPotion entitypotion = new EntityPotion(worldIn, playerIn, itemStackIn);
entitypotion.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
worldIn.spawnEntityInWorld(entitypotion);
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
示例9: onItemUseFinish
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
/**
* Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
* the Item before the action is complete.
*/
@Nullable
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
--stack.stackSize;
if (entityLiving instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)entityLiving;
entityplayer.getFoodStats().addStats(this, stack);
worldIn.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
this.onFoodEaten(stack, worldIn, entityplayer);
entityplayer.addStat(StatList.getObjectUseStats(this));
}
return stack;
}
示例10: onBlockActivated
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
if (!playerIn.capabilities.allowEdit)
{
return false;
}
else
{
state = state.cycleProperty(MODE);
float f = state.getValue(MODE) == BlockRedstoneComparator.Mode.SUBTRACT ? 0.55F : 0.5F;
worldIn.playSound(playerIn, pos, SoundEvents.BLOCK_COMPARATOR_CLICK, SoundCategory.BLOCKS, 0.3F, f);
worldIn.setBlockState(pos, state, 2);
this.onStateChange(worldIn, pos, state);
return true;
}
}
示例11: onItemUse
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack heldItem = playerIn.getHeldItem(hand);
if (heldItem.isEmpty()) {
return super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
System.out.println(this.getSaplingState());
if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, heldItem) && worldIn.isAirBlock(pos.up()) && worldIn.getBlockState(pos).getBlock().canSustainPlant(worldIn.getBlockState(pos), worldIn, pos, facing, (IPlantable) this.getSaplingState().getBlock())) {
worldIn.setBlockState(pos.up(), this.getSaplingState());
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 1F, 1F);
heldItem.shrink(1);
return EnumActionResult.SUCCESS;
} else {
if (playerIn.canPlayerEdit(pos.offset(facing), facing, heldItem) && worldIn.isAirBlock(pos.up()) && worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos)) {
worldIn.setBlockState(pos, this.getSaplingState());
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 1F, 1F);
heldItem.shrink(1);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
}
}
示例12: openInventory
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
public void openInventory(EntityPlayer player)
{
if (!player.isSpectator())
{
if (this.field_190598_h < 0)
{
this.field_190598_h = 0;
}
++this.field_190598_h;
this.world.addBlockEvent(this.pos, this.getBlockType(), 1, this.field_190598_h);
if (this.field_190598_h == 1)
{
this.world.playSound((EntityPlayer)null, this.pos, SoundEvents.field_191262_fB, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
}
}
}
示例13: slotClick
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
@Nullable
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player)
{
if(inventorySlots.get(slotId) != null)
{
if(!inventorySlots.get(slotId).getStack().isEmpty())
{
if(!player.world.isRemote)
{
InventoryHelper.spawnItemStack(player.world, inventory.getPos().getX() + 0.5D, inventory.getPos().getY() + 1D, inventory.getPos().getZ() + 0.5D, inventorySlots.get(slotId).getStack());
}
player.world.playSound(null, inventory.getPos().getX() + 0.5D, inventory.getPos().getY() + 1D, inventory.getPos().getZ() + 0.5D, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((player.world.rand.nextFloat() - player.world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
inventorySlots.get(slotId).putStack(ItemStack.EMPTY);
inventory.setInventorySlotContents(slotId, ItemStack.EMPTY);
inventory.markDirty();
}
}
return super.slotClick(slotId, dragType, clickTypeIn, player);
}
示例14: cmdSave
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
/**
* Save schematic
* @param world Target world
* @param name Structure name
* @param posX X starting position
* @param posY Y starting position
* @param posZ Z starting position
* @param width X axis size
* @param height Y axis size
* @param length Z axis size
* @return Execution status
*/
private static String cmdSave(UWorld world,
String name,
int posX, int posY, int posZ,
int width, int height, int length) {
Report report = new Report()
.post("WORLD FRAGMENT", name)
.post("POS", "[X=" + posX + ";Y=" + posY + ";Z=" + posZ + "]")
.post("SIZE", "[W=" + width + ";H=" + height + ";L=" + length + "]");
try {
Blueprint blueprint = new Blueprint(world, new UBlockPos(posX, posY, posZ), new Volume(width, height, length));
File file = new File(Configurator.getSchematicsSavesFolder(), name + ".schematic");
blueprint.saveSchematic(file);
Structures.load(file);
report.post("SAVED", file.getPath());
} catch (IOException ioe) {
report.post("NOT SAVED", ioe.getMessage());
}
report.print();
world.sound(new UBlockPos(posX, posY, posZ), SoundEvents.BLOCK_ENDERCHEST_CLOSE, SoundCategory.BLOCKS, 0.5f);
return report.toString();
}
示例15: onBlockActivated
import net.minecraft.util.SoundCategory; //導入依賴的package包/類
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
if (worldIn.isRemote)
{
return true;
}
else
{
state = state.cycleProperty(POWERED);
worldIn.setBlockState(pos, state, 3);
float f = ((Boolean)state.getValue(POWERED)).booleanValue() ? 0.6F : 0.5F;
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.3F, f);
worldIn.notifyNeighborsOfStateChange(pos, this, false);
EnumFacing enumfacing = ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing();
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this, false);
return true;
}
}