Hi, I'm a little new on modding. Actually this its my first mod and everything was going fine until I got stuck on this problem.
I have a block that when it breaks is replaced and the player get posion and I wanted to spawn an AreaEffectCloud if is breaked with an explosion.
So I did that:
@Override
public void onBlockDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) {
replaceRegen(world, pos);
EntityAreaEffectCloud cloud = new EntityAreaEffectCloud(world, pos.getX(),pos.getY(),pos.getZ());
cloud.setOwner(explosion.getExplosivePlacedBy());
cloud.setRadius(2.5F);
cloud.setRadiusOnUse(-0.5F);
cloud.setWaitTime(10);
cloud.setDuration(260);
cloud.addEffect(new PotionEffect(MobEffects.POISON,800,3));
world.spawnEntity(cloud);
}
where "replaceRegen" is the function to replace the block and the rest is how I spawn the effect cloud.
But for some reason, this code summon 2 clouds and the second one doesn't despawn.
This is how it looks a normal cloud:
https://i.imgur.com/U0l0kYO.png
And this is how it look the one that my code summon
https://i.imgur.com/lZ6Islu.png
Not really sure if there's 2 clouds or one with 2 hitbox. It looks like 2 diferent entities and the first one despawn.
But the second one remains and drop particles on the center, it looks like a bug, only disappears if I go back to menu and load the world again.
https://i.imgur.com/jOdK4pU.png
Someone know why this happen and how can I fix it?
I checked with diferent versions about how to spawn and all are almost the same and the same error happens.