Questions with Chunk

Discussion in 'Plugin Development' started by Ice Drake, Jul 18, 2020.

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

    Ice Drake

    I am trying to summon pets from one location to current location and returning them back. I run into two issues while testing my plugin on PaperMC v1.15.2.

    Scenario 1: I setup a location far away from the spawn point and I marked it home. I returned somewhere near the spawn point. I returned a pet near where I am at back home using the command code below. It said "That pet returns back home successfully!" I traveled to that location I marked home. The pet is right there back home. It works fine.

    Code:
    if (pet.getLocation().getChunk().isLoaded()) {
        boolean success = pet.teleport(plugin.getHome(player));
        if (success)
            sender.sendMessage(ChatColor.GREEN + "That pet returns back home successfully!");
        else
            sender.sendMessage(ChatColor.YELLOW + "That pet fails to return home for some reason!");
    }
    else {
        sender.sendMessage(ChatColor.YELLOW + "Sorry, that pet got lost.");
    }
    Scenario 2: Then I went back to nearby the spawn point and I summoned it to me using the command code below. It said "That pet was summoned successfully!" Yet, I can't find my pet anywhere. I traveled to that location I marked home. It is still right there. Why?

    Code:
    if (pet.getLocation().getChunk().isLoaded()) {
        boolean success = pet.teleport(player.getLocation()));
        if (success)
            sender.sendMessage(ChatColor.GREEN + "That pet was summoned successfully!");
        else
            sender.sendMessage(ChatColor.YELLOW + "That pet failed to be summoned for some reason!");
    }
    else {
        sender.sendMessage(ChatColor.YELLOW + "Sorry, that pet got lost.");
    }
    Scenario 3: Whenever I traveled back to the place I marked home, ChunkLoadEvent gets fired, which is correct. So the chunk the pet is at must not be loaded. Then why chunk.isLoaded() returns true?

    Scenario 4: I marked home near the spawn point. Summoning and returning pet home works fine.

    Questions:
    1. Why chunk.isLoaded() is true when it supposed to be false? Note that this question has been asked in the past topic, but since I can no longer reply to it, I am creating a new topic here.

    2. Why pet.teleport() returns true for Scenario 2?

    3. Why all chunks within certain distance near the spawn point are always stay loaded?
     
Thread Status:
Not open for further replies.

Share This Page