show Virtual area selection

A new update is now available, introducing "Points of interest" and many more changes!
Latest hotfix: 0.9 (2025-11-05)
  • Hey i currently try to show a virtual area but its not what i like it should be....

    Ok first i tried

    player.enableAreaSelectionTool(false);

    player.setAreaSelectionData(area);

    but i dont want to have the selection tool activated, just show the area. If i then call


    player.disableAreaSelectionTool();

    the selection is invisible again... i tried many things but could not get it as i like it.

    Only once it closely behaved like i wanted it, but that was after many plugin reloads and gm switches.
    After relog it was not behaving like i wanted it again.

    UPDATE:

    I've managed to to a trick to get it working like i want it to:

                        if (!player.hasAttribute("selectionToolHack")) {
                            player.setAttribute("selectionToolHack", true);
                            player.enableAreaSelectionTool(false);
                            player.enableAreaSelectionTool(false);
                            player.disableAreaSelectionTool();
    }

    If i call enable twice and disable afterwards the visibility seems to stay but the selectiontool stays disabled. This is not as elegant as i was looking for but still its working for now. I only need to do this hack once a session so i added a player attribute.

    Gamer aus Leidenschaft
    (Web) Entwickler aus Leidenschaft
    <3 Vater aus Leidenschaft <3
    (prio in aufsteigender Sortierung ;) )


    ~~~~~~~~~~~~~~~~~
    1. Entweder man macht etwas richtig oder lässt es bleiben!
    2. Egal wie lange etwas dauert, Hauptsache es wird fertig (irgendwann)
    ------------------------
    Discord: devidian

    Edited once, last by Devidian ().

  • What exactly are you trying to do? if i understand you want to show the selected area after the tool is disabled? if so use Area3D.


    Java
    //assuming you already the the Area data(start/end positions)
    Area3D area3d = new Area3D(area);
    area3d.setAlwaysVisible(true);
    player.addGameObject(area3d);
  • Its for my current plugin im working on Land Claim - (i started it for the Java version but never finished it before the unity news).

    Its an option to turn on borders of the current chunk, if the player moves to another chunk with active option the virtual border is updated to the chunk he enters.

    The player does not need to set any area, its calculated from the chunk he enters, so in theory the tool is not even needed but if i do not activate it, the area is not shown.

    Your way is good to know but i think i would have to (re)move it somehow if the player moves or disables this feature.

    edit: Ii just walked through the javadoc, maybe i can use setAttribute to store a ref to the area3d too, so i can update it on change or remove it precisely.

    Gamer aus Leidenschaft
    (Web) Entwickler aus Leidenschaft
    <3 Vater aus Leidenschaft <3
    (prio in aufsteigender Sortierung ;) )


    ~~~~~~~~~~~~~~~~~
    1. Entweder man macht etwas richtig oder lässt es bleiben!
    2. Egal wie lange etwas dauert, Hauptsache es wird fertig (irgendwann)
    ------------------------
    Discord: devidian

    Edited once, last by Devidian ().

  • Post by james1bow ().

    This post was deleted by the author themselves ().
  • The docs say addGameObject should not be called so often, so i tried to update the Area3D object but it seems not to update it actually :D



  • Some exceptions i got while testing:


    Code
    java.lang.NullPointerException: Cannot read field "handle" because "net.risingworld.api.objects.Area.INFINITE" is null
    at net.risingworld.api.objects.Area.destroy(Area.java:393)
    java.lang.NullPointerException: Cannot read field "handle" because "net.risingworld.api.objects.Area.INFINITE" is null
    at net.risingworld.api.objects.Area.setStartPosition(Area.java:307)
    java.lang.NullPointerException: Cannot read field "handle" because "net.risingworld.api.objects.Area.INFINITE" is null
    at net.risingworld.api.objects.Area.set(Area.java:328)

    Im not sure (joking) but a public static final field should not be NULL ? red51

  • it looks like the methods to update the area3d position do not work. not sure of the impact on performance but removing them is the only way i could get it to work.


Participate now!

Don’t have an account yet? Create a new account now and be part of our community!