Jump to content

Spawning lightning and big explosions


muddyfish

Recommended Posts

I have a block that ticks randomly and would like it so it creates lightning and explosions.

I have seen several variations of spawn lightning but none of them draw the lightning, only fire appears.

Explosions on the other hand, don't happen at all (I only want cosmetic ones)

 

    public void updateTick(World world, int x, int y, int z, Random rand)
    {
        log.info("Update @ "+x+" "+y+" "+z);
    	if (rand.nextBoolean()) {
        	log.info("Lightning!");
    		EntityLightningBolt lightning = new EntityLightningBolt(world, x, y+1, z);
    		world.addWeatherEffect(lightning);
    	}
    	else {
        	log.info("Explosion!");
            world.spawnParticle("largeexplode", x, y, z, 0.0D, 0.0D, 0.0D);
    	}
    }

 

The text is being displayed but nothing appears

Link to comment
Share on other sites

I have never used addWeatherEffect, but I have spawned lightining using a different line.

 

instead try:

EntityLightningBolt lightning = new EntityLightningBolt(world, x, y+1, z);
    		world.spawnEntityInWorld(lightning);

 

As for the explosions:

world.createExplosion(lightning, lightning.posX, lightning.posY, lightning.posZ, <Explosion Strength, Go With A # Around 4>, false);

Creator Of Weapons+ Mod & Sword Art Online HUD Mod

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.