What is the new CollisionType.PLAYERS ?

  • Trying to identify that a player is looking at another Player or NPC and then act upon information from the result. I used player raycast(CollisionType.PLAYERS, I cant seem to find the Replacement in the new API?

  • The Javadoc contains an example about that ;)


    Basically you need to provide a bitmask of the Layers you want to include in the raycast. Do not use the layers directly, instead create a bitmask with the Layer.getBitmask() method. Other players have the Layer "REMOTEPLAYER", so getting the bitmask or performing the raycast would look like this:

    Java
    //Get collision bitmask
    int bitmask = Layer.getBitmask(Layer.REMOTEPLAYER);
    //Perform raycast
    player.raycast(bitmask, (RaycastResult result) -> {
    //...
    });
  • The Javadoc contains an example about that ;)


    Basically you need to provide a bitmask of the Layers you want to include in the raycast. Do not use the layers directly, instead create a bitmask with the Layer.getBitmask() method. Other players have the Layer "REMOTEPLAYER", so getting the bitmask or performing the raycast would look like this:

    Java
    //Get collision bitmask
    int bitmask = Layer.getBitmask(Layer.REMOTEPLAYER);
    //Perform raycast
    player.raycast(bitmask, (RaycastResult result) -> {
    //...
    });

    Ok thanks, I read the JAVDOC but it appeared I would have had to go through several layers of looking, getting the Id (which I was not sure of for another player), getting the name and identifying it that way. The .RemotePlayer seems more like the old .Players. Thanks again.


    and for the readers dont forget to;


    import net.risingworld.api.utils.Layer;

    Edited once, last by angriff: added api utils comment for clarity of others reading ().

Participate now!

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