Jump to content

[1.10] playSound() and spawnParticle() not working!


MSpace-Dev

Recommended Posts

Hey everyone,

 

So, I am trying to make a block look like it gets broken when you right click it, without destroying the actual block. I am using playSound() and spawnParticle() to achieve this. But, for some reason, these are not working. I have never used these methods before, so I can't really figure out the reason why they're not working. I know for a fact that they are running because the line, infused_log.carveAmount++ , is working. Here is the method:

 

@Override
    public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
        if(worldIn.getTileEntity(pos) != null) {
            if (worldIn.getTileEntity(pos) instanceof TileEntityInfusedLog) {
                TileEntityInfusedLog infused_log = (TileEntityInfusedLog) worldIn.getTileEntity(pos);
              
                worldIn.playSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.BLOCK_WOOD_BREAK, SoundCategory.BLOCKS, 1000.0f, 1.0f, false);
                worldIn.spawnParticle(EnumParticleTypes.CLOUD, pos.getX(), pos.getY() + 1.0D, pos.getX(), 0.0, 0.0, 0.0, new int[0]);
                infused_log.carveAmount++;
            }
        }
        return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
    }

 

Thanks!

Edited by MSpace-Dev
Changed font
Link to comment
Share on other sites

Oh, wow. I am such an idiot. I was under the impression that I was running my game on debug mode! All changes  I made weren't actually going through. It's working now =p

 

Anyways, new problem. What params do I use in the spawnParticle to change the blockcrack ID? I know in commands, you type a specific number, but I'm not sure where to put that number in the spawnParticle() method.

Link to comment
Share on other sites

You work it out like this:

blockId + (metaData * 4096)

 

For example:

 

412 + (0 * 4096) = 412

therefore, the blockcrack ID will be 412.

 

So, my question is how do I get the number ID of my block? There is no like ".getBlockID" type thing

Edited by MSpace-Dev
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.