本文整理汇总了Java中net.minecraft.init.SoundEvents类的典型用法代码示例。如果您正苦于以下问题:Java SoundEvents类的具体用法?Java SoundEvents怎么用?Java SoundEvents使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SoundEvents类属于net.minecraft.init包,在下文中一共展示了SoundEvents类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifySellingItem
import net.minecraft.init.SoundEvents; //导入依赖的package包/类
/**
* Notifies the merchant of a possible merchantrecipe being fulfilled or not. Usually, this is just a sound byte
* being played depending if the suggested itemstack is not null.
*/
public void verifySellingItem(ItemStack stack)
{
if (!this.worldObj.isRemote && this.livingSoundTime > -this.getTalkInterval() + 20)
{
this.livingSoundTime = -this.getTalkInterval();
if (stack != null)
{
this.playSound(SoundEvents.ENTITY_VILLAGER_YES, this.getSoundVolume(), this.getSoundPitch());
}
else
{
this.playSound(SoundEvents.ENTITY_VILLAGER_NO, this.getSoundVolume(), this.getSoundPitch());
}
}
}
示例2: processInteract
import net.minecraft.init.SoundEvents; //导入依赖的package包/类
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
ItemStack itemstack = player.getHeldItem(hand);
if (itemstack.getItem() == Items.BUCKET && !player.capabilities.isCreativeMode && !this.isChild())
{
player.playSound(SoundEvents.ENTITY_COW_MILK, 1.0F, 1.0F);
itemstack.func_190918_g(1);
if (itemstack.func_190926_b())
{
player.setHeldItem(hand, new ItemStack(Items.MILK_BUCKET));
}
else if (!player.inventory.addItemStackToInventory(new ItemStack(Items.MILK_BUCKET)))
{
player.dropItem(new ItemStack(Items.MILK_BUCKET), false);
}
return true;
}
else
{
return super.processInteract(player, hand);
}
}
示例3: recipeDropLogic
import net.minecraft.init.SoundEvents; //导入依赖的package包/类
public boolean recipeDropLogic(ItemStack dropped) {
if (mode == Mode.NORMAL && changeMode(dropped.getItem())) {
play(SoundEvents.ENTITY_FIREWORK_TWINKLE, 0.2F, 1F);
dropped.setCount(0);
return true;
}
switch (mode) {
case NORMAL:
return processingLogic(dropped) || (inv.hasFluid(FluidRegistry.WATER) && acceptIngredient(dropped));
case POTION:
return acceptIngredient(dropped);
case CUSTOM:
return acceptIngredient(dropped);
default:
}
return false;
}
示例4: damageShield
import net.minecraft.init.SoundEvents; //导入依赖的package包/类
/** Fixed vanilla code */
private void damageShield(EntityPlayer owner, float damage) {
int i = 1 + MathHelper.floor(damage);
owner.getActiveItemStack().damageItem(i, owner);
if (owner.getActiveItemStack().getCount() <= 0) {
EnumHand enumhand = owner.getActiveHand();
ForgeEventFactory.onPlayerDestroyItem(owner, owner.getActiveItemStack(), enumhand);
if(enumhand == EnumHand.MAIN_HAND) {
owner.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
} else {
owner.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY);
}
owner.resetActiveHand();
owner.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + owner.world.rand.nextFloat() * 0.4F);
}
}
示例5: attackEntityFrom
import net.minecraft.init.SoundEvents; //导入依赖的package包/类
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource source, float amount)
{
if (this.isEntityInvulnerable(source))
{
return false;
}
else if (!source.isExplosion() && this.getDisplayedItem() != null)
{
if (!this.worldObj.isRemote)
{
this.dropItemOrSelf(source.getEntity(), false);
this.playSound(SoundEvents.ENTITY_ITEMFRAME_REMOVE_ITEM, 1.0F, 1.0F);
this.setDisplayedItem((ItemStack)null);
}
return true;
}
else
{
return super.attackEntityFrom(source, amount);
}
}
示例6: openInventory
import net.minecraft.init.SoundEvents; //导入依赖的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);
}
}
}
示例7: onInventoryChanged
import net.minecraft.init.SoundEvents; //导入依赖的package包/类
/**
* Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
*/
public void onInventoryChanged(InventoryBasic invBasic)
{
HorseArmorType horsearmortype = this.getHorseArmorType();
boolean flag = this.isHorseSaddled();
this.updateHorseSlots();
if (this.ticksExisted > 20)
{
if (horsearmortype == HorseArmorType.NONE && horsearmortype != this.getHorseArmorType())
{
this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F);
}
else if (horsearmortype != this.getHorseArmorType())
{
this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F);
}
if (!flag && this.isHorseSaddled())
{
this.playSound(SoundEvents.ENTITY_HORSE_SADDLE, 0.5F, 1.0F);
}
}
}
示例8: handleCollectItem
import net.minecraft.init.SoundEvents; //导入依赖的package包/类
public void handleCollectItem(SPacketCollectItem packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getCollectedItemEntityID());
EntityLivingBase entitylivingbase = (EntityLivingBase)this.clientWorldController.getEntityByID(packetIn.getEntityID());
if (entitylivingbase == null)
{
entitylivingbase = this.gameController.thePlayer;
}
if (entity != null)
{
if (entity instanceof EntityXPOrb)
{
this.clientWorldController.playSound(entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F, false);
}
else
{
this.clientWorldController.playSound(entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F, false);
}
this.gameController.effectRenderer.addEffect(new ParticleItemPickup(this.clientWorldController, entity, entitylivingbase, 0.5F));
this.clientWorldController.removeEntityFromWorld(packetIn.getCollectedItemEntityID());
}
}
示例9: updateArmorModifier
import net.minecraft.init.SoundEvents; //导入依赖的package包/类
/**
* Applies or removes armor modifier
*/
public void updateArmorModifier(int p_184691_1_)
{
if (!this.world.isRemote)
{
this.getEntityAttribute(SharedMonsterAttributes.ARMOR).removeModifier(COVERED_ARMOR_BONUS_MODIFIER);
if (p_184691_1_ == 0)
{
this.getEntityAttribute(SharedMonsterAttributes.ARMOR).applyModifier(COVERED_ARMOR_BONUS_MODIFIER);
this.playSound(SoundEvents.ENTITY_SHULKER_CLOSE, 1.0F, 1.0F);
}
else
{
this.playSound(SoundEvents.ENTITY_SHULKER_OPEN, 1.0F, 1.0F);
}
}
this.dataManager.set(PEEK_TICK, Byte.valueOf((byte)p_184691_1_));
}
示例10: onLivingUpdate
import net.minecraft.init.SoundEvents; //导入依赖的package包/类
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
if (!this.onGround && this.motionY < 0.0D)
{
this.motionY *= 0.6D;
}
if (this.worldObj.isRemote)
{
if (this.rand.nextInt(24) == 0 && !this.isSilent())
{
this.worldObj.playSound(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, SoundEvents.ENTITY_BLAZE_BURN, this.getSoundCategory(), 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F, false);
}
for (int i = 0; i < 2; ++i)
{
this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
super.onLivingUpdate();
}
示例11: damageShield
import net.minecraft.init.SoundEvents; //导入依赖的package包/类
protected void damageShield(float damage)
{
if (damage >= 3.0F && this.activeItemStack.getItem() == Items.SHIELD)
{
int i = 1 + MathHelper.floor(damage);
this.activeItemStack.damageItem(i, this);
if (this.activeItemStack.func_190926_b())
{
EnumHand enumhand = this.getActiveHand();
if (enumhand == EnumHand.MAIN_HAND)
{
this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.field_190927_a);
}
else
{
this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.field_190927_a);
}
this.activeItemStack = ItemStack.field_190927_a;
this.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + this.world.rand.nextFloat() * 0.4F);
}
}
}
示例12: onItemRightClick
import net.minecraft.init.SoundEvents; //导入依赖的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);
}
示例13: cmdSave
import net.minecraft.init.SoundEvents; //导入依赖的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();
}
示例14: onBlockActivated
import net.minecraft.init.SoundEvents; //导入依赖的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;
}
}
示例15: litCandle
import net.minecraft.init.SoundEvents; //导入依赖的package包/类
public void litCandle() {
world.playSound(null, getPos(), SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1F, 1F);
this.lit = true;
world.profiler.startSection("checkLight");
world.checkLight(pos);
world.profiler.endSection();
}