Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.5] Adding arguments to DeferredRegister and RegistryObject

Recommended Posts

I got the new way of registering things working. I want to send the tile entity through my container so I have access to the BlockPos in the container (for sending packets). I'm just not sure how, if I add the tile to the constructor of the container how do I add the tile to the register?



Link to post
Share on other sites

On the server you create your container in INamedContainerProvider, so there you can just pass the TE in normally.

You then need to send whatever data is necessary to the client using the extraData argument of NetworkHooks.openGui. This data then shows up in your IContainerFactory as the data parameter.

Link to post
Share on other sites
11 minutes ago, BeardlessBrady said:

What do you mean by "On the server you create your container in INamedContainerProvider"?

Here: https://github.com/Beardlessbrady/Currency-Mod/blob/master-1.16/src/main/java/com/beardlessbrady/gocurrency/blocks/vending/VendingTile.java#L79-L83

This is then called from NetworkHooks.openGui (you give it the TE as the INamedContainerProvider, because you use ContainerBlock#getContainer, which returns the TE).

Link to post
Share on other sites
9 hours ago, BeardlessBrady said:

What format do I include data into the packetBuffer for the client?

It's just a PacketBuffer, you can put data in whatever format you want (it's just a byte array essentially). You just have to make sure you read and write it in the same way.


9 hours ago, BeardlessBrady said:

For instance if I want to include the BlockPos?

PacketBuffer#writeBlockPos, PacketBuffer#readBlockPos.

Link to post
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.

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 Privacy Policy.