Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Request] Way to access Tile Entities/Containers/Guis if you're too far away.

Featured Replies

Posted

I'm pretty sure this could be done by adding a simple boolean to the player, named canPlayerAccessAllGuis or something like that, which would, by default, be set to false. It could be set to true in a tick handler, if certain conditions are met.

Every tick, a check is run to see if the player has a Gui open and if the player can interact with the Gui's container. A check to see if canPlayerAccessAllGuis is true could be added in here. If it's true, then it should skip closing the currently open Gui, but otherwise, the Gui will be closed as normal.

 

I require this to get a feature I have had planned for a while now working, and It could be useful for other modders wanting to access Guis from a distance as well. Thoughts?

  • Author

You know how Guis close automatically if the user is too far away from their corresponding Block? I need a way to prevent this from happening if certain conditions are met.

 

I'm proposing a way to prevent this from happening if a boolean value in the player is set to true, which could be done via tick handler.

Seems potentially intensive, unless it's just running client side, but then the server might throw a fit.

Usage scenario? I can't think of a way the player would be able to be out of range of a block and still activate it, or move out of range while using it.

 

As for doing it, first of all I'd say go through the code and see what causes the GUI to be closed in the first place.

 

Edit:

Found it. It's not even called when the container is opened. It's just under the update method for EntityPlayer. Strictly client side, and the GUI just closes if the container isn't in range.

  • Author

Yeah. It's around line 330 of EntityPlayer.

Usage Scenario: Item that saves a Block's location in it's NBT data and then, upon being activated, calls the OnActivated() method inside the block at that location.  Used to remotely access chests, machines, levers, and such.

I've got such an item working ingame. All I need is a way to get past that one check, and this item is ready for use,

(Yes, I know how incredibly overpowered this is. It's going to be expensive)

I tried doing that once, and this explains why it never worked. :P

 

Since it is just using the onUpdate method, then your simple boolean idea should work. I still don't know how the server would handle it though.

Actually, that may not work so well. Containers are managed by the server and correct me if I'm wrong, containers contain the check as to whether the player can interact or not.

  • Author

I got it working. Not seeing any server issues or anything of the sort. Only a few extra lines of code.

And yes, the containers are managed by the server, and they contain the usage check.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.