Jump to content

[1.12] World.destroyBlock renders particles on player not block


xaedblade
 Share

Recommended Posts

Ok so I've been racking my brain on this one for some time.  I have a block that takes damage and is destroyed by mobs. This all works fine. But my problem is that when a mob breaks the block the particles happen on the player and not the block. Any help would be much appreciated.

 

I know that I could use the setBlockAir but I'd rather get the particles... it's so odd because the pos works for the block to update it's state but not to add particles...

 

Code below

public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
    {
    	if (!worldIn.isRemote) {
	        entityIn.setInWeb();
	        
	        if(!(entityIn instanceof EntityItem))
	        {
	        	entityIn.attackEntityFrom(DamageSource.CACTUS, 1.0F);
		        int currentDamage = worldIn.getBlockState(pos).getValue(DAMAGE_VALUE);
		        Random randNum = new Random();
		        
		        if((currentDamage+1) < 5 && randNum.nextInt(100) == 34)
		        {
		        	System.out.println(currentDamage);
		        	worldIn.setBlockState(pos, this.getDefaultState().withProperty(DAMAGE_VALUE, currentDamage+1));
		        	worldIn.playSound(null, pos, SoundEvents.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, SoundCategory.BLOCKS, 1.0F, 2.0F);;
		        }
		        else if((currentDamage+1) >= 5)
		        {
		        	worldIn.playSound(null, pos, SoundEvents.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, SoundCategory.BLOCKS, 1.0F, 2.0F);        	
		        	worldIn.destroyBlock(pos, false);
		        	
		        }
	        }
    	}
        
    }

 

Edited by xaedblade
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
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.

 Share



×
×
  • Create New...

Important Information

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