Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loading of chunks #2041

Open
Dymeth opened this issue Feb 6, 2020 · 3 comments
Open

Infinite loading of chunks #2041

Dymeth opened this issue Feb 6, 2020 · 3 comments

Comments

@Dymeth
Copy link

@Dymeth Dymeth commented Feb 6, 2020

Some chunks are loaded due to Citizens and are unloaded the next tick. Thus, the same chunk is loaded 10 times per second. I have 3 similar chunks on my server.

Chunks loading stack: https://pastebin.com/raw/amTT8SK1
Chunks unloading stack: https://pastebin.com/raw/gkpdfrVL

version
This server is running Paper version git-Paper-90 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)
Checking version, please wait...
Previous version: git-Paper-88 (MC: 1.15.2)
You are running the latest version

version Citizens
Citizens version 2.0.26-SNAPSHOT (build 1815)
Website: http://www.citizensnpcs.co
Author: fullwall

@mcmonkey4eva

This comment has been minimized.

Copy link
Member

@mcmonkey4eva mcmonkey4eva commented Feb 7, 2020

This seems much more likely to be an issue with Paper than with Citizens. A chunk being unloaded the very tick after it's read from is... not proper behavior, and I don't think Minecraft's native chunk handler would do something so messy - or at least I hope it wouldn't. Paper has a fairly customized chunk handler.

Can you replicate this issue at all on Spigot?

@Dymeth

This comment has been minimized.

Copy link
Author

@Dymeth Dymeth commented Feb 8, 2020

The problem is not with Paper, since Spigot has a same situation.

Chunks loading stack: https://pastebin.com/raw/XNTASQZp
Chunks unloading stack: https://pastebin.com/raw/kVjYETwu

Of course, the chunk should not be unloaded to the next tick after loading.
But there is another problem - the chunk should not load by Citizens.

It will take me some time to provide the minimum necessary set of information to reproduce the problem.
Working with Citizens is fully done by my plugin - perhaps the problem is in it. But even so - Citizens should prevent such incorrect actions.
Also, I do not exclude that this situation is connected with some features of the world on the server.
In any case, I will let know when it becomes possible to provide more information.

version
This server is running CraftBukkit version git-Spigot-c574e08-c985389 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)
Checking version, please wait...
You are running the latest version

version Citizens
Citizens version 2.0.26-SNAPSHOT (build 1815)
Website: http://www.citizensnpcs.co
Author: fullwall

@Dymeth

This comment has been minimized.

Copy link
Author

@Dymeth Dymeth commented Feb 8, 2020

I was able to find out that the problem occurs when try to apply the NPC skin, which is located on the block that adjoins the unloaded chunk.
I set skins using the SkinnableEntity.setSkinPersistent().
This code helped to avoid the original problem:

    private static boolean isSkinsAllowed(@Nonnull Location location) {
        int minBlockX = (location.getBlockX() >> 4) << 4;
        int minBlockZ = (location.getBlockZ() >> 4) << 4;
        int maxBlockX = minBlockX + 15;
        int maxBlockZ = minBlockZ + 15;
        World world = location.getWorld();
        if (isSkinsIgnored(world, location.getBlockX(), minBlockX, minBlockX - 1, location.getBlockZ())) return false;
        if (isSkinsIgnored(world, location.getBlockX(), maxBlockX, maxBlockX + 1, location.getBlockZ())) return false;
        if (isSkinsIgnored(world, location.getBlockZ(), minBlockZ, location.getBlockX(), minBlockZ - 1)) return false;
        if (isSkinsIgnored(world, location.getBlockZ(), maxBlockZ, location.getBlockX(), maxBlockZ + 1)) return false;
        return true;
    }

    private static boolean isSkinsIgnored(@Nonnull World world, int currentBlockPos, int borderBlockPos, int blockX, int blockZ) {
        return currentBlockPos == borderBlockPos && !world.isChunkLoaded(blockX >> 4, blockZ >> 4);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.