Jump to content

[SOLVED] Difference in setBlock breaking my mod. Help?


Arphahat

Recommended Posts

I am trying to update my mod to work in 1.5.  Much of it was trivial or little changes, but a core mechanic I was relying on seems different and I'm not sure what it is doing or how to adjust.

 

I was relying on setBlock to in World to call notifyBlockChange with the id of the block, in this case, the fire block (id 51).  Before, it worked great.  Now, however, instead of just passing the block id (par4), it passes k1 which is "k1 = chunk.getBlockID(par1 & 15, par2, par3 & 15);"  Why is it ANDing the coordinates of the block with 15? 

 

Tracing it through that area, it seems to find 51 again, but then decides to return 0.  It then uses this 0 instead of passing the 51 in par4 into notifyBlockChange.  Grrrr!!!

 

Anyhow, my important question is this: I need to know when a block is next to a fire block.  I was previously overriding the "onNeighborBlockChange" and checking to see if the id was fire.  Now the id is always 0.  Is there another way I can do this?

Link to comment
Share on other sites

I am trying to update my mod to work in 1.5.  Much of it was trivial or little changes, but a core mechanic I was relying on seems different and I'm not sure what it is doing or how to adjust.

 

I was relying on setBlock to in World to call notifyBlockChange with the id of the block, in this case, the fire block (id 51).  Before, it worked great.  Now, however, instead of just passing the block id (par4), it passes k1 which is "k1 = chunk.getBlockID(par1 & 15, par2, par3 & 15);"  Why is it ANDing the coordinates of the block with 15? 

 

Tracing it through that area, it seems to find 51 again, but then decides to return 0.  It then uses this 0 instead of passing the 51 in par4 into notifyBlockChange.  Grrrr!!!

 

Anyhow, my important question is this: I need to know when a block is next to a fire block.  I was previously overriding the "onNeighborBlockChange" and checking to see if the id was fire.  Now the id is always 0.  Is there another way I can do this?

Link to comment
Share on other sites

OK, I experimented a little bit and it seems that the logic is reversed from how it used to behave.  The block id that is used in the notify neighbor is of the block that was there before the update.  So, if you are placing fire in a spot that was just air, it will be a 0, but if you knock down a block, it will give the id of the block. 

 

So, to look for fire, I just have to let it check for 0 and then check the status of the block as it is now.  It will call the check more frequently, since it will also be 0 whenever any block is placed, but it won't call it abusively nor generate lag, so it is tolerable.

Link to comment
Share on other sites

OK, I experimented a little bit and it seems that the logic is reversed from how it used to behave.  The block id that is used in the notify neighbor is of the block that was there before the update.  So, if you are placing fire in a spot that was just air, it will be a 0, but if you knock down a block, it will give the id of the block. 

 

So, to look for fire, I just have to let it check for 0 and then check the status of the block as it is now.  It will call the check more frequently, since it will also be 0 whenever any block is placed, but it won't call it abusively nor generate lag, so it is tolerable.

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.