Jump to content

Detecting fire to open a portal


Arphahat

Recommended Posts

So, I think this is probably a pretty easy question, but I am still pretty new to messing around with MC modding.

 

I am trying to open a portal using fire like a traditional obsidian portal.  What do I need to detect?  I think I should be able to do a check in the tickUpdate function like was being done in this thread and just check to see if the portal frame block has fire on it every certain number of ticks, but I am wondering if there is a better way?

Link to comment
Share on other sites

OK, I figured it out.  I'll provide the details here for anyone else looking for this (most likely me from the future trying to remember how to do this. :P)

 

World.java has a routine called "notifyBlockOfNeighborChange".  It is called for a number of reasons, like when a block is placed.  One of these is when fire is next to a block.  This routine calls the block's "onNeighborBlockChange" routine.  So, in your block code, it is as easy as adding something like this:

 

	@Override
    public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
	if (par5 == Block.fire.blockID)
	{
		// check to see if the fire is on top of block
		if (this.fireOnBlock())
		{
			// check if this block is ignitable part of a portal frame.  There are two per portal.
			if (this.ignitablePortalBlock())
			{
				this.lightPoral();
			}
		}
	}		
}

Link to comment
Share on other sites

No problem! :)

 

Hey, if you come up with, or already have, an optimized routine for the "ignitablePortalBlock" part, I'd be interested.  The way it is right now, it only needs to check starting with assuming the block is one of the two in the base of the portal, but it still is going to take some thought to iterate through it properly.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

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