Jump to content

Execute Code on Block Update


Onmar

Recommended Posts

Hello Guys

 

I'm currently developing a mod for forge, and I would like to execute some code whenever a block gets changed in the world (blockBreak, blockPlace, but also TileEntityChange etc.)

 

I have found out that there is a packet sent to the client if there is a blockUpdate.

(net.minecraft.network.packet.Packet53BlockChange.java)

 

Can I use/make a hook that executes my code when the packet is sent, or is there a better way to do this?

Also, will it execute if a TileEntity changes (e.g. the player takes something out of a chest)?

 

It would also be very nice, if this could be done server-side. (My code won't render anything)

Link to comment
Share on other sites

Thanks for your reply.

 

Hooking into the breakBlock and setBlock event is a good idea, but I would also like to fire the event if a Tile Entity changes.

I think of it as a "blockChangeEvent" or "ID/Metadata/TileEntity-ChangeEvent".

 

All the data I need is the xyz-coordinate of the block.

Also, I want it to always fire, not only if a player does something.

Link to comment
Share on other sites

There is no way you can detect if anything in any of those changes.

in theorie you could catch some changes by hooking markBlockForUpdate serverside, since modders have to call this to propagate the changes to the clients BUT it could also be called for no reason (and no change)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

True words. But it would be unstable because you'd never know.

yeah, but in theory you could catch those, obviously you wouldn't be able to cancel those or get any relevent information out of it because it's different between every TE, but you could catch the "update" part

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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.