本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.playSound方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.playSound方法的具体用法?Java EntityPlayer.playSound怎么用?Java EntityPlayer.playSound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.playSound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
ItemStack glove = playerIn.getHeldItem(handIn);
if (handIn == EnumHand.OFF_HAND)
{
ItemStack shard = playerIn.getHeldItem(EnumHand.MAIN_HAND);
if (shard.getItem() == ItemRegistry.crystal_shard)
{
int shrink = playerIn.isSneaking() ? shard.getCount() : 1;
playerIn.playSound(SoundRegistry.GLASS, 1, 1);
if (ItemSipAmulet.checkForAmulet(playerIn))
{
ItemStack amulet = ItemUtils.getBauble(playerIn, BaubleType.AMULET.getValidSlots()[0]);
amulet.getCapability(CapabilityRegistry.SIP_STORE_CAP, null).add(SipUtils.getSipInStack(shard), shrink);
ItemUtils.setBauble(playerIn, BaubleType.AMULET.getValidSlots()[0], amulet);
}
playerIn.getHeldItem(EnumHand.MAIN_HAND).shrink(shrink);
return new ActionResult<>(EnumActionResult.SUCCESS, glove);
}
}
return new ActionResult<>(EnumActionResult.PASS, glove);
}
示例2: processInteract
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的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: processInteract
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack)
{
if (stack != null && stack.getItem() == Items.BUCKET && !player.capabilities.isCreativeMode && !this.isChild())
{
player.playSound(SoundEvents.ENTITY_COW_MILK, 1.0F, 1.0F);
if (--stack.stackSize == 0)
{
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, stack);
}
}
示例4: damageShield
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的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: handleClientSide
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void handleClientSide(PacketHackingEntityFinish message, EntityPlayer player) {
Entity entity = player.world.getEntityByID(message.entityId);
if (entity != null) {
IHackableEntity hackableEntity = HackableHandler.getHackableForEntity(entity, player);
if (hackableEntity != null) {
hackableEntity.onHackFinished(entity, player);
PneumaticCraftRepressurized.proxy.getHackTickHandler().trackEntity(entity, hackableEntity);
CommonHUDHandler.getHandlerForPlayer(player).setHackedEntity(null);
player.playSound(Sounds.HELMET_HACK_FINISH, 1.0F, 1.0F);
}
}
}
示例6: handleClientSide
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void handleClientSide(PacketHackingBlockFinish message, EntityPlayer player) {
IHackableBlock hackableBlock = HackableHandler.getHackableForCoord(player.world, message.pos, player);
if (hackableBlock != null) {
hackableBlock.onHackFinished(player.world, message.pos, player);
PneumaticCraftRepressurized.proxy.getHackTickHandler().trackBlock(new WorldAndCoord(player.world, message.pos), hackableBlock);
CommonHUDHandler.getHandlerForPlayer(player).setHackedBlock(null);
player.playSound(Sounds.HELMET_HACK_FINISH, 1.0F, 1.0F);
}
}
示例7: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
ItemStack itemstack = playerIn.getHeldItem(hand);
ItemStack copy = playerIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
playerIn.playSound(SoundEvents.ENTITY_LINGERINGPOTION_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote) {
EntityBrew brew = new EntityBrew(worldIn, playerIn, copy, EntityBrew.BrewDispersion.LINGER);
brew.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
worldIn.spawnEntity(brew);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
}
示例8: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
ItemStack itemstack = playerIn.getHeldItem(hand);
ItemStack copy = playerIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
playerIn.playSound(SoundEvents.ENTITY_SPLASH_POTION_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote) {
EntityBrew brew = new EntityBrew(worldIn, playerIn, copy, EntityBrew.BrewDispersion.SPLASH);
brew.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
worldIn.spawnEntity(brew);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
}
示例9: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn, EnumHand hand) {
init(stack);
if (getFluidStored(stack) >= FLUID_CAPACITY) {
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
}
RayTraceResult ray = rayTrace(worldIn, playerIn, true);
if (ray == null || ray.typeOfHit == null || hand == null) {
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
}
if (ray.typeOfHit == RayTraceResult.Type.BLOCK && hand == EnumHand.MAIN_HAND && !worldIn.isRemote) {
BlockPos blockpos = ray.getBlockPos();
IBlockState iblockstate = worldIn.getBlockState(blockpos);
Material material = iblockstate.getMaterial();
if (material == Material.WATER && iblockstate.getValue(BlockLiquid.LEVEL).intValue() == 0) {
worldIn.setBlockState(blockpos, Blocks.AIR.getDefaultState(), 11);
playerIn.addStat(StatList.getObjectUseStats(this));
playerIn.playSound(SoundEvents.ITEM_BUCKET_FILL, 1.0F, 1.0F);
addFluid(stack, 1000);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
else if (iblockstate.getBlock().hasTileEntity(iblockstate) && worldIn.getTileEntity(blockpos).hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, ray.sideHit)) {
IFluidHandler fluidHandler = worldIn.getTileEntity(blockpos).getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, ray.sideHit);
for (IFluidTankProperties property : fluidHandler.getTankProperties()) {
if (property.getContents().getFluid() == FluidRegistry.WATER && property.getContents().amount >= 1000 && property.canDrain()) {
fluidHandler.drain(new FluidStack(FluidRegistry.WATER, 1000), true);
addFluid(stack, 1000);
}
}
}
}
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
}
示例10: performRevivalCurse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Revival zombie curse - fill the player's inventory with poisionous potatoes
*/
private void performRevivalCurse()
{
EntityPlayer player = (EntityPlayer)this.victim;
ItemStack stack = new ItemStack(Items.POISONOUS_POTATO, 16 + this.rand.nextInt(17), 0);
EntityItem entityItem = new EntityItem(this.world, this.posX, this.posY, this.posZ, stack);
if (player.inventory.addItemStackToInventory(stack))
{
ForgeEventFactory.onItemPickup(entityItem, player);
player.playSound(SoundEvents.ENTITY_ZOMBIE_INFECT, 0.75F, (this.rand.nextFloat() * 0.2F) + 0.9F);
}
}
示例11: performLegacyCurse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Original KodaichiZero slime curse - fill the player's inventory with slime balls
*/
private void performLegacyCurse()
{
EntityPlayer player = (EntityPlayer)this.victim;
ItemStack stack = new ItemStack(Items.SLIME_BALL, 16 + this.rand.nextInt(17), 0);
EntityItem entityItem = new EntityItem(this.world, this.posX, this.posY, this.posZ, stack);
if (player.inventory.addItemStackToInventory(stack))
{
ForgeEventFactory.onItemPickup(entityItem, player);
player.playSound(SoundEvents.ENTITY_SLIME_ATTACK, 0.75F, (this.rand.nextFloat() * 0.2F) + 0.9F);
}
}
示例12: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn,
EnumHand hand) {
ItemStack itemStackIn = playerIn.getHeldItem(hand);
ItemStack backpack = getBackpack(playerIn);
if (!backpack.isEmpty() && (backpack.getTagCompound().getFloat("Rage") >= 1 || playerIn.isCreative())) {
playerIn.setActiveHand(hand);
if (TF2Util.getTeamForDisplay(playerIn) == 1)
playerIn.playSound(ItemFromData.getSound(backpack, PropertyType.HORN_BLU_SOUND), 0.8f, 1f);
else
playerIn.playSound(ItemFromData.getSound(backpack, PropertyType.HORN_RED_SOUND), 0.8f, 1f);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
}
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
示例13: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer living, EnumHand hand) {
ItemStack stack=living.getHeldItem(hand);
if (living.isInvisible() || (!isFeignDeath(stack, living) && stack.getItemDamage() < 528)) {
this.setCloak(!WeaponsCapability.get(living).isInvisible(), stack, living, world);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
else if(!living.isInvisible() && this.isFeignDeath(stack, living) && stack.getItemDamage() == 0) {
WeaponsCapability.get(living).setFeign(!WeaponsCapability.get(living).isFeign());
if(WeaponsCapability.get(living).isFeign())
living.playSound(getSound(stack, PropertyType.CHARGE_SOUND), 1.0f, 1.0f);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
示例14: tryFillContainer
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Fill a container from the given fluidSource.
*
* @param container The container to be filled. Will not be modified.
* @param fluidSource The fluid handler to be drained.
* @param maxAmount The largest amount of fluid that should be transferred.
* @param player The player to make the filling noise. Pass null for no noise.
* @param doFill true if the container should actually be filled, false if it should be simulated.
* @return The filled container or null if the liquid couldn't be taken from the tank.
*/
public static ItemStack tryFillContainer(ItemStack container, IFluidHandler fluidSource, int maxAmount, @Nullable EntityPlayer player, boolean doFill)
{
container = container.copy(); // do not modify the input
container.stackSize = 1;
IFluidHandler containerFluidHandler = getFluidHandler(container);
if (containerFluidHandler != null)
{
FluidStack simulatedTransfer = tryFluidTransfer(containerFluidHandler, fluidSource, maxAmount, false);
if (simulatedTransfer != null)
{
if (doFill)
{
tryFluidTransfer(containerFluidHandler, fluidSource, maxAmount, true);
if (player != null)
{
SoundEvent soundevent = simulatedTransfer.getFluid().getFillSound(simulatedTransfer);
player.playSound(soundevent, 1f, 1f);
}
}
else
{
containerFluidHandler.fill(simulatedTransfer, true);
}
return container;
}
}
return null;
}
示例15: tryEmptyContainer
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Takes a filled container and tries to empty it into the given tank.
*
* @param container The filled container. Will not be modified.
* @param fluidDestination The fluid handler to be filled by the container.
* @param maxAmount The largest amount of fluid that should be transferred.
* @param player Player for making the bucket drained sound. Pass null for no noise.
* @param doDrain true if the container should actually be drained, false if it should be simulated.
* @return The empty container if successful, null if the fluid handler couldn't be filled.
* NOTE The empty container will have a stackSize of 0 when a filled container is consumable,
* i.e. it has a "null" empty container but has successfully been emptied.
*/
@Nullable
public static ItemStack tryEmptyContainer(ItemStack container, IFluidHandler fluidDestination, int maxAmount, @Nullable EntityPlayer player, boolean doDrain)
{
container = container.copy(); // do not modify the input
container.stackSize = 1;
IFluidHandler containerFluidHandler = getFluidHandler(container);
if (containerFluidHandler != null)
{
FluidStack simulatedTransfer = tryFluidTransfer(fluidDestination, containerFluidHandler, maxAmount, false);
if (simulatedTransfer != null)
{
if (doDrain)
{
tryFluidTransfer(fluidDestination, containerFluidHandler, maxAmount, true);
if (player != null)
{
SoundEvent soundevent = simulatedTransfer.getFluid().getEmptySound(simulatedTransfer);
player.playSound(soundevent, 1f, 1f);
}
}
else
{
containerFluidHandler.drain(simulatedTransfer, true);
}
return container;
}
}
return null;
}