Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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. :)

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!)

  • Author

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.  :-\

  • Author

Guh, this is a really annoying bug, and it's holding me up. :(

 

The entity will catch file, but still won't take any damage... I'd honestly be happy if I just got the entity to die or something from being within range.

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)

  • Author

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. :(

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.

  • Author

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?

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
    }

 

 

  • Author

Thank you! That got it to work somewhat, though it only seems to work once when the block is placed, and doesn't work anymore after that. :(

  • Author

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.

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.

  • Author

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. :(

try adding a call to: scheduleBlockUpdateOnLoad or something like that, under world. It is my understanding that will schedule an update when the chunk loads(might also need to be rescheduled)

  • Author

Got it to work automatically by placing it into a few other methods. Thanks for all the help! :D

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.