Jump to content

Entity won't catch (or stay) on fire...


Tynarus

Recommended Posts

Hello! I'm currently making a block that will find all entities of a certain type within a 5 block radius and set them on fire.

 

...However the fire will not appear to stay on or take any damage... Here's my code from my block's class:

 

    private void findEntitiesToBurn(World world, int x, int y, int z) {
	float distance = 5.0F;
	List entityList = world.getEntitiesWithinAABB(EntityInfected.class, 
			AxisAlignedBB.getBoundingBox(x - distance, y - distance, z - distance, x + distance, y + distance, 
			z + distance));
	Entity entity;
	for(Iterator iterator = entityList.iterator(); iterator.hasNext(); burnEntity(entity)) {
		entity = (Entity)iterator.next();
	}
}
    
    private void burnEntity(Entity entity) {
    	if(!entity.isBurning()) {
    		theEntity.setFire(;
    	}
    }
    
    public void randomDisplayTick(World world, int x, int y, int z, Random random) {
    	findEntitiesToBurn(world, x, y, z);
    }

 

It sets the entity on fire... But the fire flickers and the entity won't take any damage... Can anyone help me with this?

 

Thanks. :)

Link to comment
Share on other sites

You're only setting fire to the entity for 8 ticks - 8/20ths of a second. 20 ticks = 1 second ;)

Protip: try and find answers yourself before asking on the forum.

It's pretty likely that there is an answer.

 

Was I helpful? Give me a thank you!

 

 

width=635 height=903http://bit.ly/HZ03zy[/img]

 

 

Tired of waiting for mods to port to bukkit?

use BukkitForge! (now with a working version of WorldEdit!)

Link to comment
Share on other sites

You're only setting fire to the entity for 8 ticks - 8/20ths of a second. 20 ticks = 1 second ;)

 

Certainly helpful (and I didn't know that, so thanks. :D), but it doesn't solve the main problem. :( The entity catches on fire just fine but... Doesn't take any damage from it? That's the real problem I'm having.  :-\

Link to comment
Share on other sites

I tested entity.setfire and it works fine, Are you sure the entity is getting set on fire server side and client side(client side is visual only, server side is damage only)

 

I'm getting the visual but not the damage. I haven't set anything telling it to be client only, though. :(

Link to comment
Share on other sites

I tested entity.setfire and it works fine, Are you sure the entity is getting set on fire server side and client side(client side is visual only, server side is damage only)

 

I'm getting the visual but not the damage. I haven't set anything telling it to be client only, though. :(

Your hook is random display tick, this is client only. You need to schedule a block update.

Link to comment
Share on other sites

I tested entity.setfire and it works fine, Are you sure the entity is getting set on fire server side and client side(client side is visual only, server side is damage only)

 

I'm getting the visual but not the damage. I haven't set anything telling it to be client only, though. :(

Your hook is random display tick, this is client only. You need to schedule a block update.

 

Ahh, I figured it would be something like that when you mentioned client only. Bummer, I wasted a lot of time there. xD How would I go about making the block update?

Link to comment
Share on other sites

like this:

public void onBlockAdded(World par1World, int par2, int par3, int par4) {
        super.onBlockAdded(par1World, par2, par3, par4);
        par1World.scheduleBlockUpdate(par2, par3, par4, blockID, tickRate);
    }

this gets called when it ticks:

public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
        super.updateTick(par1World, par2, par3, par4, par5Random);
        //Do your stuff here
    }

 

 

Link to comment
Share on other sites

You have to reschedule it after doing your action, sorry I forgot to meantion that.

 

Ohhh, thanks again! What do you think would be a good number for the tick rate for this sort of thing? I've not really messed with ticks on MC yet, not sure on how they work.

Link to comment
Share on other sites

You have to reschedule it after doing your action, sorry I forgot to meantion that.

 

Ohhh, thanks again! What do you think would be a good number for the tick rate for this sort of thing? I've not really messed with ticks on MC yet, not sure on how they work.

20 world ticks per second, a setting of 4 would tick 5 times a second. It depends on how responsive you want the effect to be.

Link to comment
Share on other sites

You have to reschedule it after doing your action, sorry I forgot to meantion that.

 

Ohhh, thanks again! What do you think would be a good number for the tick rate for this sort of thing? I've not really messed with ticks on MC yet, not sure on how they work.

20 world ticks per second, a setting of 4 would tick 5 times a second. It depends on how responsive you want the effect to be.

 

Alright, seems to work for the most part. Thanks very much, helped with a ton of things. :)

 

EDIT:

 

The only problem now is that it only starts the updates when I place the block. When I log off and come back into the world it won't do it automatically if a block is already placed. :(

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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