Jump to content

Updating Chest contents repeatedly server-side


Recommended Posts

I am making a server side mod in which I want to allow the player to open a chest (vanilla) and have several of the contents moving around. How do I make the contents update their location while the player has the chest GUI open?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

I would use

// To do get the instance if the container that the player has open
// Grab which block the player is looking at using MovingObjectPosition and the players look vectors.


I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

If I recall correctly, the Container should have a reference to the Inventory, which should have a reference to the TileEntity in use, which should have a reference to the BlockPos.


But if that's not the case, then yes, you'd have to resort to a raytrace to fetch the current block, but that's not totally reliable in this case - what if another player or mob interposes itself between the player and the open chest while they are perusing, for example? Container will still be open, but now the MovingObjectPosition will probably contain the mob. Or a player might place blocks between them. Rare, certainly, but it may happen.

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.

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.