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.

Featured Replies

Posted

Hi!

 

I'm having two linked blocks in different dimensions. Each of these blocks is a connector which tries to behave on some of its sides like a tile which is adjacent to its partner's opposite side. For performance reasons, I'm caching those tiles being represented by partners by reference.

Here's the question goes. How can I detect that some instance of TileEntity object is invalid in the sense that some chunk was unloaded, then loaded, and so I need to reacquire TE reference.

The problem is, TE in question and connector might reside in different chunks. So I cannot rely on connector's onChunkUnload.

I cannot also rely on isInvalid, since TE isn't invalidated on unload.

Maybe there's some way to detect chunk unload of adjacent tile?

 

Thanks.

 

Hi

 

I'm not sure why TileEntity.onChunkUnload() doesn't work for you. 

 

If you have two linked blocks, A and B, then when B is unloaded, in b.onChunkUnload(), you need to call a.unlink(b);

 

-TGG

 

 

 

 

  • Author

The case is, I'm interested not in linked blocks themselves, but in their immediate neighbors. So I can't rely on my linkers' onChunkUnload, because their neighbor blocks might reside in different chunk.

 

Anyway, I've already devised a not so bad logic, with ChunkEvent.Unload and a custom chunk watcher. This allowed me to watch for tiles of interest right from the linker on the other side.

  • Author

@rypofalem Thanks for your interest. Though I can't call my solution very elegant.

 

Code is here https://github.com/target-san/Gateway

The main problem is - it's Scala, and not very clean.

The classes of interest are TileSatellite, ChunkWatcher and EventHandler.

 

The main idea:

1. Satellite TE (the watcher) asks ChunkWatcher to register itself as a watcher for specific block. In fact, a whole chunk is added to its internal multimap.

2. EventHandler catches ChunkEvent.Unload, then calls ChunkWatcher.onChunkUnload. The latter finds set of watcher 4D coordinates by their chunk coordinate key, then calls onWatchedChunkUnload for those which are loaded at the moment.

 

Please note that there's a bug in my code elsewhere, so you won't be able to run the whole mod from master now.

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.