Posted December 16, 20177 yr 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 December 16, 20177 yr by MSpace-Dev Changed font
December 16, 20177 yr You need to check if you are on the server or on the client Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
December 16, 20177 yr Author (Debug mode wasn't on) Re-added if(worldIn.isRemote) {} Edited December 16, 20177 yr by MSpace-Dev Added solution
December 16, 20177 yr Author 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.
December 16, 20177 yr What exactly is a blockcrack ID? Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
December 16, 20177 yr Author 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 December 16, 20177 yr by MSpace-Dev
December 16, 20177 yr What version are you using? Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
December 16, 20177 yr Author Finally figured it out, after trawling through the MC code worldIn.spawnParticle(EnumParticleTypes.BLOCK_CRACK, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, 1.0, 1.0, 1.0, Block.getIdFromBlock(worldIn.getBlockState(pos).getBlock()));
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.