Jump to content

Recommended Posts

Posted

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?

Posted

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();
			}
		}
	}		
}

Posted

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.

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.