Java Code Examples for net.minecraft.entity.player.EntityPlayer#playSound()
The following examples show how to use
net.minecraft.entity.player.EntityPlayer#playSound() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemTofuSlimeRadar.java From TofuCraftReload with MIT License | 7 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { boolean flag = playerIn.capabilities.isCreativeMode; if (flag || playerIn.getHeldItem(handIn).getItemDamage() <= playerIn.getHeldItem(handIn).getMaxDamage()) { if (!worldIn.isRemote) { boolean isSpawnChunk = playerIn.dimension == TofuMain.TOFU_DIMENSION.getId() || EntityTofuSlime.isSpawnChunk(playerIn.world, playerIn.posX, playerIn.posZ); if(isSpawnChunk) playerIn.sendMessage(new TextComponentTranslation("tofucraft.radar.result.success", new Object())); else playerIn.sendMessage(new TextComponentTranslation("tofucraft.radar.result.failed", new Object())); } if (!playerIn.capabilities.isCreativeMode && playerIn.getHeldItem(handIn).isItemStackDamageable()) { playerIn.getHeldItem(handIn).damageItem(1, playerIn); } playerIn.playSound(SoundEvents.UI_BUTTON_CLICK, 0.5F, 1.0F); } return super.onItemRightClick(worldIn, playerIn, handIn); }
Example 2
Source File: ItemSheath.java From Sakura_mod with MIT License | 6 votes |
public void sheath_In(EntityPlayer player) { ItemStack item_l = player.getHeldItemMainhand(); ItemStack item_r = player.getHeldItemOffhand(); if(item_r.getItem()==ItemLoader.KATANA){ player.playSound(SoundEvents.BLOCK_ANVIL_HIT, 1F, 1F); player.setHeldItem(EnumHand.MAIN_HAND, ItemLoader.KATANA_SHEATH.setBlade(item_r)); player.setHeldItem(EnumHand.OFF_HAND, ItemStack.EMPTY); }else if(item_r.getItem()==ItemLoader.SAKURAKATANA){ player.playSound(SoundEvents.BLOCK_ANVIL_HIT, 1F, 1F); player.setHeldItem(EnumHand.MAIN_HAND, ItemLoader.SAKURAKATANA_SHEATH.setBlade(item_r)); player.setHeldItem(EnumHand.OFF_HAND, ItemStack.EMPTY); }else if(item_l.getItem()==ItemLoader.KATANA){ player.playSound(SoundEvents.BLOCK_ANVIL_HIT, 1F, 1F); player.setHeldItem(EnumHand.OFF_HAND, ItemLoader.KATANA_SHEATH.setBlade(item_l)); player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY); }else if(item_l.getItem()==ItemLoader.SAKURAKATANA){ player.playSound(SoundEvents.BLOCK_ANVIL_HIT, 1F, 1F); player.setHeldItem(EnumHand.OFF_HAND, ItemLoader.SAKURAKATANA_SHEATH.setBlade(item_l)); player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY); } }
Example 3
Source File: GTItemSprayCan.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer playerIn, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand handIn) { if (!playerIn.isSneaking() && handIn == EnumHand.MAIN_HAND) { ItemStack playerStack = playerIn.getHeldItemMainhand(); NBTTagCompound nbt = StackUtil.getNbtData(playerStack); if (nbt.hasKey(COLOR)) { EnumDyeColor dye = EnumDyeColor.byDyeDamage(nbt.getInteger(COLOR)); if (colorBlock(world.getBlockState(pos), world, pos, null, dye)) { if (playerStack.getItemDamage() < playerStack.getMaxDamage()) { playerStack.damageItem(1, playerIn); if (!IC2.platform.isSimulating()) { IC2.audioManager.playOnce(playerIn, Ic2Sounds.painterUse); } } else { playerIn.setHeldItem(handIn, GTMaterialGen.get(GTItems.sprayCanEmpty)); if (!IC2.platform.isSimulating()) { playerIn.playSound(SoundEvents.ENTITY_ITEM_BREAK, 1.0F, 1.0F); } } return EnumActionResult.SUCCESS; } } } return EnumActionResult.PASS; }
Example 4
Source File: ItemBugle.java From TofuCraftReload with MIT License | 5 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); playerIn.getCooldownTracker().setCooldown(stack.getItem(), 100); playerIn.playSound(TofuSounds.TOFUBUGLE, 20.0F, 1.0F); playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack); }
Example 5
Source File: PlungerBehaviour.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity == null) { return EnumActionResult.PASS; } IFluidHandler fluidHandler = tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); if (fluidHandler == null) { return EnumActionResult.PASS; } ItemStack toolStack = player.getHeldItem(hand); boolean isShiftClick = player.isSneaking(); IFluidHandler handlerToRemoveFrom = isShiftClick ? (fluidHandler instanceof FluidHandlerProxy ? ((FluidHandlerProxy) fluidHandler).input : null) : (fluidHandler instanceof FluidHandlerProxy ? ((FluidHandlerProxy) fluidHandler).output : fluidHandler); if (handlerToRemoveFrom != null && GTUtility.doDamageItem(toolStack, cost, false)) { if (!world.isRemote) { FluidStack drainStack = handlerToRemoveFrom.drain(1000, true); int amountOfFluid = drainStack == null ? 0 : drainStack.amount; if (amountOfFluid > 0) { player.playSound(SoundEvents.ENTITY_SLIME_SQUISH, 1.0f, amountOfFluid / 1000.0f); } } return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; }
Example 6
Source File: GTTileAESU.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onRightClick(EntityPlayer player, EnumHand hand, EnumFacing facing, Side side) { if (player.isSneaking() && player.getHeldItemMainhand().isEmpty()) { this.onNetworkEvent(player, 0); if (this.isSimulating()) { IC2.platform.messagePlayer(player, this.getRedstoneMode()); } player.playSound(SoundEvents.UI_BUTTON_CLICK, 1.0F, 1.0F); return true; } return false; }
Example 7
Source File: GTTileIDSU.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onRightClick(EntityPlayer player, EnumHand hand, EnumFacing facing, Side side) { if (player.isSneaking() && player.getHeldItemMainhand().isEmpty()) { this.onNetworkEvent(player, 0); if (this.isSimulating()) { IC2.platform.messagePlayer(player, this.getRedstoneMode()); } player.playSound(SoundEvents.UI_BUTTON_CLICK, 1.0F, 1.0F); return true; } return false; }
Example 8
Source File: GTTilePlayerDetector.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onRightClick(EntityPlayer player, EnumHand var2, EnumFacing var3, Side var4) { if (player.isSneaking() && player.getHeldItemMainhand().isEmpty() && this.canAccess(player.getUniqueID())) { this.advanceMode(); if (this.isSimulating()) { IC2.platform.messagePlayer(player, this.getModeName()); } player.playSound(SoundEvents.UI_BUTTON_CLICK, 1.0F, 1.0F); return true; } return false; }
Example 9
Source File: GTTileMultiLESU.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onRightClick(EntityPlayer player, EnumHand hand, EnumFacing facing, Side side) { if (player.isSneaking() && player.getHeldItemMainhand().isEmpty()) { this.onNetworkEvent(player, 0); if (this.isSimulating()) { IC2.platform.messagePlayer(player, this.getRedstoneMode()); } player.playSound(SoundEvents.UI_BUTTON_CLICK, 1.0F, 1.0F); return true; } return false; }
Example 10
Source File: GTTileLamp.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onRightClick(EntityPlayer player, EnumHand hand, EnumFacing enumFacing, Side side) { if (player.isSneaking() && player.getHeldItemMainhand().isEmpty()) { this.inverted = !this.inverted; this.shouldUpdate = true; if (this.isSimulating()) { String msg = this.inverted ? "Inverted" : "Not Inverted"; IC2.platform.messagePlayer(player, msg); } player.playSound(SoundEvents.UI_BUTTON_CLICK, 1.0F, 1.0F); return true; } return false; }
Example 11
Source File: GTItemSpringBoots.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { Potion jump = MobEffects.JUMP_BOOST; if (!player.isPotionActive(jump)) { player.addPotionEffect(new PotionEffect(jump, 10, 2, false, false)); } if (player.onGround && player.isSprinting()) { player.jump(); player.playSound(GTSounds.SPRING, 1.0F, 1.0F + world.rand.nextFloat()); if (world.rand.nextInt(2) == 0) { stack.damageItem(1, player); } } }
Example 12
Source File: GuiPearlSwap.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
public void update(int originalPearlCount, int newPearlCount, int index) { unlock(); EntityPlayer player = Minecraft.getMinecraft().player; if (originalPearlCount != newPearlCount) { if (originalPearlCount == 0) { dilateItems(); } else { contractItems(); if (newPearlCount != 0) ANIMATOR.add(new ScheduledEventAnimation(10, this::dilateItems)); } player.playSound(ModSounds.POP, 1f, 1f); } else if (newPearlCount != 0 && index != -1) { contractItem(index); ANIMATOR.add(new ScheduledEventAnimation(10, () -> dilateItem(index))); player.playSound(ModSounds.POP, 1f, 1f); } else { player.playSound(ModSounds.SPELL_FAIL, 1f, 1f); } double centerRad = newPearlCount == 0 ? getGuiHeight() : getGuiHeight() * 0.75; new BasicAnimation<>(this, "parasolGradientRadius").to(centerRad * 1.5).ease(Easing.easeOutQuart).duration(15).addTo(ANIMATOR); centerRadiusAnim = (BasicAnimation<ComponentVoid>) new BasicAnimation<>(componentCentralCircle, "size.x").to(centerRad).ease(Easing.easeOutQuint).duration(20).addTo(ANIMATOR); }