show Virtual area selection

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

    XING | LinkedIn
    Steam | Discord @ Omega Zirkel

    My Plugins:

    OZ Tools | OZ Discord Connect | OZ Global Intercom (unity version in progress) | OZ Land Claim (in testing) | OZ Currency (planned) | OZ GPS (rebuild from java, planned)

    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.

    XING | LinkedIn
    Steam | Discord @ Omega Zirkel

    My Plugins:

    OZ Tools | OZ Discord Connect | OZ Global Intercom (unity version in progress) | OZ Land Claim (in testing) | OZ Currency (planned) | OZ GPS (rebuild from java, planned)

    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



    XING | LinkedIn
    Steam | Discord @ Omega Zirkel

    My Plugins:

    OZ Tools | OZ Discord Connect | OZ Global Intercom (unity version in progress) | OZ Land Claim (in testing) | OZ Currency (planned) | OZ GPS (rebuild from java, planned)

  • 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

    XING | LinkedIn
    Steam | Discord @ Omega Zirkel

    My Plugins:

    OZ Tools | OZ Discord Connect | OZ Global Intercom (unity version in progress) | OZ Land Claim (in testing) | OZ Currency (planned) | OZ GPS (rebuild from java, planned)

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


  • yes it seems so, i did it too, marked it as workaround in the comments. For now its ok to work with.

    BTW this is my method to create the area:



    And i call it like this:


    XING | LinkedIn
    Steam | Discord @ Omega Zirkel

    My Plugins:

    OZ Tools | OZ Discord Connect | OZ Global Intercom (unity version in progress) | OZ Land Claim (in testing) | OZ Currency (planned) | OZ GPS (rebuild from java, planned)

  • ok, good to know but for my LC plugin the player usually is in the zone that is released=destroyed. Maybe thats the same reason why set and the other methods are not working and throwing that exception. I'll try to get a workaround for that, thanks for the hint james.✅

    XING | LinkedIn
    Steam | Discord @ Omega Zirkel

    My Plugins:

    OZ Tools | OZ Discord Connect | OZ Global Intercom (unity version in progress) | OZ Land Claim (in testing) | OZ Currency (planned) | OZ GPS (rebuild from java, planned)

Participate now!

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