Solved No portal created when portaling through to another world.

Discussion in 'Plugin Development' started by CorrieKay, Jul 1, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    CorrieKay

    I'm designing a small multiworld module for my plugin. Each "universe" can have one of each type of world, but does not need to (though overworld is required). For the worlds that have a nether world, I would like to link the nether portals between the worlds. Now, I know that by default neither NMS or OBC code does this after you've loaded the worlds, as the linkage is not something that is recognized inherently.

    So, I've created a listener method to check for when a player enters a portal, and specifies the target world that theyre going to (the method works for transporting players from nether > overworld as well) However, what is very strange, is that when portaling, it will ignore nearby portals, and just teleport you somewhere.

    Based on the craftbukkit code, it should be using the findOrCreate portal method, as described here, but when travelling to the nether, no portal is ever created. I think I may be missing something.

    Code:java
    1. public void portal(PlayerPortalEvent event) {
    2. SimpleWorld fromWorld = SimpleWorld.getWorld(event.getPlayer().getWorld().getName());
    3. SimpleWorld toWorld;
    4. double ratio = 0;
    5. if (fromWorld.isOverworld()) {
    6. ratio = 0.125;
    7. if (!fromWorld.hasNether()) {
    8. return;
    9. } else {
    10. toWorld = fromWorld.getNether();
    11. }
    12. } else if (fromWorld.isNether()) {
    13. ratio = 8.0;
    14. toWorld = fromWorld.getOverworld();
    15. } else { //Going to the end. Implement later
    16. return;
    17. }
    18. Location from = event.getFrom();
    19. Location finalLocation = new Location(toWorld.getWorld(), from.getX() * ratio, from.getY() * ratio, from.getX() * ratio);
    20. event.setTo(finalLocation);
    21. if (!event.getPortalTravelAgent().getCanCreatePortal()) {
    22. System.out.println("Portal travel agent not allowed to create portals. Forcing to allow");
    23. event.getPortalTravelAgent().setCanCreatePortal(true);
    24. }
    25. }


    Does anybody have any idea what I'm missing, or something that I should be doing?
     
  2. Offline

    xTigerRebornx

  3. Offline

    CorrieKay

    I just doublechecked that, and yes, the travel agent is being used. Additionally, i do see that I'm using x instead of z, and while i've fixed that, the issue still persists.
     
  4. Offline

    Skye

    You could call findOrCreate from your listener:
    Code:
    event.getPortalTravelAgent().findOrCreate(event.getTo())
     
  5. Offline

    CorrieKay

    Hmm. It looks like i had forgotten to clean my project before exporting, and it didnt compile the manual activation of the travel agent. Looks like the portaling is working now :]

    Thanks guys.
     
Thread Status:
Not open for further replies.

Share This Page