Skip to content

Add sublevel.getForces()#9

Open
Sascha-T wants to merge 6 commits into
TechTastic:masterfrom
Sascha-T:master
Open

Add sublevel.getForces()#9
Sascha-T wants to merge 6 commits into
TechTastic:masterfrom
Sascha-T:master

Conversation

@Sascha-T
Copy link
Copy Markdown

Closes #7

Adds sublevel.getForces()
Format:

{
  "sable:force_name": {
    {
      "position": --[ vector ]--,
      "force": --[ vector ]--
    }
  }
}

or just straight up null if something goes horribly wrong.

The cody is a bit funky but it should be fine, works on my machine! :p
(I didn't increment any versions)

Comment thread README.md
@TechTastic TechTastic added the enhancement New feature or request label May 16, 2026
@TechTastic TechTastic self-assigned this May 16, 2026
* Track "force requests" for sublevels because Sable be like "waaah no you cant request forces mid-tick"
*/
public class Physicker {
private static Map<ResourceLocation, Object> LOCKS = new HashMap();
Copy link
Copy Markdown
Owner

@TechTastic TechTastic May 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a ConcurrentHashMap and thus locks and syncronization do not need to be explicitly handled by this class

Copy link
Copy Markdown
Author

@Sascha-T Sascha-T May 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make it a ConcurrentHashMap but getLock is synchronized to prevent an evil style "race condition" where you can potentially create 2 seperate locks, but only one is stored in the Map, leaving a computer to wait for the (currently 2 ticks) lock timeout. (and from my understanding, a ConcurrentHashMap wouldn't change that?)

Or I just straight up don't understand where you want to go with this, please elaborate 🥺

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I see the vision

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took a minute but I think I found somewhat decent way to outsource concurrency back to Java, what do you think?

@Sascha-T
Copy link
Copy Markdown
Author

Sascha-T commented May 16, 2026

I've been informed that getForces apparently behaves erratically (occasionally returns nil for no reason) so it appears there's still some more work to be done

Correction: not nil. But the other forces disappear, which may as well be a nil...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function requests

2 participants