Jump to content

[1.7.10] Block updateTick Assistance [SOLVED]


Magthidon

Recommended Posts

So, I've created a block that runs its updateTick() every 20 ticks.  The issue that I'm having is that I'd like the world to update the block every time that happens, but can't seem to get anything to work.  This is what I have tried:

 

world.markBlockForUpdate

world.setBlockMetadataAndNotify (this one works if I change metadata, but I don't want that)

world.notifyBlockOfChange

world.notifyBlockOfNeighborChange

 

Any help you can give me would be very much appreciated.

Link to comment
Share on other sites

Digging into the code, I came with such conclusions:

 

1. markBlockForUpdate

(seen from World.class)

(member function of interface IWorldAccess)

IWorldAccess has so many thing to do with world access: Play sounds, spawn particles, Play Records etc.

This is said to be able to be called from wither side (Client and Server) to "re-render the target block" (unsure what it does)

 

2. (you said you understood it will be called when meta changes)

 

3. notifyBlockOfNeighborChange and notifyBlocksOfNeighborChange

These functions are called so that (When will you use it?) target blocks are told to update and do stuff accordingly.

Such example would be the notorious sand/gravel-torch trap:

When the trap maker feels good, he punches the torch at the bottom, and the torch (generally, blocks, items, and TileEntities) is destroyed. The code tells it to call BlocksChange.

When Minecraft receives BlocksChange, it helpfully assists the torch by calling BlockChange on each direction, and thus saves labour.

In this trap case, it triggers sands to check its state. The Sand found itself hanging free mid-air, so it vanishes and summons a FallingSand. This triggers another BlocksChange, where origin is at the Sand.

So this finally triggers the whole chunk of sand/gravel to fall and suffocate the victim.

 

I hope these helped!!!

Link to comment
Share on other sites

If you want consistent tick rates, you should use a TileEntity.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

or use world#scheduleBlockUpdate(...)

 

You will need to call it at the end of your updateTick function (so each tick schedules the next) as well as on blockAddedToWorld

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

or use world#scheduleBlockUpdate(...)

 

You will need to call it at the end of your updateTick function (so each tick schedules the next) as well as on blockAddedToWorld

That's what I already have going on.

 

If you want consistent tick rates, you should use a TileEntity.

A tileentity wouldn't work in my case as I would like there to be a large number of this block, thus the reason I'm using the updateTick.

 

Perhaps I should rephrase my question: How can I get a block to re-render without modifying its metadata?  None of the methods I have tried (listed in the original post) have seemed to have triggered the re-rendering of the block.  What I'm doing is changing the block's texture based on whether or not the player has a certain potion effect active, but I can't seem to trigger that block update.

Link to comment
Share on other sites

How can I get a block to re-render without modifying its metadata?  What I'm doing is changing the block's texture based on whether or not the player has a certain potion effect active

 

AH HA, thus we arrive at your actual problem.

 

I don't think you can do that without a TE involved, because blocks are rendered once, cached, and not updated unless something actually changes (and the player is irrelevant).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

How can I get a block to re-render without modifying its metadata?  What I'm doing is changing the block's texture based on whether or not the player has a certain potion effect active

 

AH HA, thus we arrive at your actual problem.

 

I don't think you can do that without a TE involved, because blocks are rendered once, cached, and not updated unless something actually changes (and the player is irrelevant).

 

All right.  That makes sense.  I'll have to rethink my approach, then and see if I can't come up with another solution.  Thanks!

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.



×
×
  • Create New...

Important Information

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