bergerkiller / NoLagg

Prevents common lag causes on your server
27 stars 14 forks source link

Multiverse-NetherPortals issue #11

Closed tomikcz closed 12 years ago

tomikcz commented 12 years ago

I have issue with multiverse nether portals (mvnp) with nolagg mvnp sometimes port players to the_end instead nether when player go to nether portal. there are mvnp messages from serverlog. The nether portal is the same in both cases.

Portal working properly, sending me to the nether:

... 02:13:22 [INFO] Location{world=CraftWorld{name=worldp},x=-910.2279994794009,y=35.0,z=-488.30000001192093,pitch=27.599977,yaw=-121.3545} => PORTAL ...

Same portal not working properly, sending me to the end:

... 02:15:01 [INFO] Location{world=CraftWorld{name=worldp},x=-910.1673466115603,y=35.0,z=-488.30000001192093,pitch=29.849974,yaw=-202.20436} => AIR ...

there is part of mvnp source which is executed when player go to portal:

... public void onPlayerPortal(PlayerPortalEvent event) { Location currentLocation = event.getFrom().clone(); String currentWorld = currentLocation.getWorld().getName();

    PortalType type = PortalType.END;
    System.out.println(event.getFrom() + " => " + event.getFrom().getBlock().getType());
    if (event.getFrom().getBlock().getType() == Material.PORTAL) {
        type = PortalType.NETHER;
    }

    String linkedWorld = this.plugin.getWorldLink(currentWorld, type);

....

It seems that noLagg sends bad blocktype to MVNP because when is nolagg disabled, everything work properly. I have this issue with all builds dev-cb 1.1 and also for 1.1 recomended build.

bergerkiller commented 12 years ago

Are you using any type of scheduled task in MultiVerse? Because when a player leaves, the chunks he was in unload and are re-allocated somewhere else; the block data of the old chunk no longer matches.

If possible, clone the block data of the chunk you need to know, or re-load the chunk (getChunk) in the task.

Would be easier if I could tell all Block objects to regenerate the internal chunk object, unfortunately I can't :/

EDIT

I recommend you set a small chunk unload delay (2000 ms?) so the chunk is not instantly unloaded, or disable the buffered chunk loader.

bergerkiller commented 12 years ago

Note: When using MultiVerse or MyWorlds, don't disable the chunk unload delay: use a delay of around 2-5 seconds. This is needed so the chunk is not unloaded (and re-used) while said plugins are using it.

Added this note on the (Dev)Bukkit main pages so people will see it.

bergerkiller commented 12 years ago

Also, I'll add proper bukkit chunk unload coding when it is dereferenced. :)

tomikcz commented 12 years ago

I had tested it with chunk unload delay 2000, 4000, 5000, 10000 and 15000 values and in all cases it failed. This issue is only when player porting from normal world to nether... it never happens when go trough portal from nether to narmal world. Tested on NoLagg v1.58.8 (CB#1818 MC 1.1)

tomikcz commented 12 years ago

I'd tested it now with latest MVNP 2.3 and all is the same. There is source of player listener:

https://github.com/Multiverse/Multiverse-NetherPortals/blob/master/src/main/java/com/onarandombox/MultiverseNetherPortals/listeners/MVNPPlayerListener.java

I'm not an java developer, but me and my friend try to make some work arround ...

@EventHandler(priority = EventPriority.HIGH)
public void onPlayerPortal(PlayerPortalEvent event) {
    event.getFrom().getChunk().load();
    Location currentLocation = event.getFrom().clone();
    String currentWorld = currentLocation.getWorld().getName();

    PortalType type = PortalType.END;
 // if (currentLocation.getBlock().getType() == Material.PORTAL) {
    if (currentLocation.getWorld().getBlockAt(currentLocation).getType() == Material.PORTAL) {
        type = PortalType.NETHER;
    }

... but with no positive results. With NoLagg dissabled everything works properly. Have you any idea how to solve this issue?

bergerkiller commented 12 years ago

I know what is going on and I know how to fix this. Right now I am having some 'disposed chunk getting added back' issues; the chunk should be unloaded, saved and set free. Instead it somehow ends up in the chunk provider again, very bad as that causes the chunk to be semi-corrupted.

Use the latest build (1.58.8) to see exactly if and how this happens. That one sets all chunk fields to null and any plugin that tries to access it afterwards receives an exception - at least makes it clear what happened.

tomikcz commented 12 years ago

Today I tested 1.58.8 and 1.58.9. All was the same. But I find a new fault. After fault with portal to the end (alfter few correct pass trough to the nether) the source chunk had weird behaviour. When I punched to the wall, the couple of block appears arround. Looks like chunk semi-corrupted. Also warps arround at underground warp me to the surface after this fault with MVNP. I will wait, for the new versions and will inform you what's new. Could be fine have a choice to disable in config all chunk operations, and let only buffering droped items in beta versions. Please excuse my bad English, but I hope you understand what I write/mean.

bergerkiller commented 12 years ago

You can disable the buffered chunk loader in the configuration to get rid of this bug, it's a hard one to fix.

bergerkiller commented 12 years ago

As the buffered chunk loader is 100% removed now due to it's failureness, I am closing this.