Bukkit/CraftBukkit — pull request #1343 by Brokkonaut (2014-02-20 01:37:16+00:00)
Title: Removing broken chunk caching from net.minecraft.server.World. Fixes BUKKIT-5425

**The Issue:**

Chunk caching in the World class is broken because it does not know about outdated cache values. This caused various problems when accessing previously unloaded chunks. BUKKIT-5425 is just one example of a bug caused by this problem, another one is the "stripes of air" appearing when using long range world modification tools (for example WorldEdit). There are probably many more problems caused by this bug.

**Justification for this PR:**

This PR addresses the issue by removing the caching. The cache did not offer significant performance increase so it can be removed.

The synchronization in the World's getChunkAt is removed, because this method may only be called by the main thread and thus it was not necessary. It is also not synchronized in vanilla Minecraft.

**PR Breakdown:**

The caching in net.minecraft.server.World is simply removed and changed back to the original NMS code.

**Testing Results and Materials:**

I tested the modified version with my own plugin that uncovered the bug (sorry not open source), the bug does not appear anymore.

I also tested it with WorldEdit by selecting a large plane outside of the loaded chunks and set this plane to stone. No more "air stripes" appeared. Reproducing: Use the WorldGuard plugin to select a large plane (for example 200x200) outside of the loaded chunks. Set this plane to stone. Without this patch there are stripes of air in it. With this patch it is a solid plane of stone.

A performance test plugin is available here, that updates 25600 Blocks in a single chunk for 100 times. This plugin does show, that the cache did not improve the performance, but it was slightly decreased by the unnecessary synchronization.
http://www5.zippyshare.com/v/5271139/file.html (Source included)

```
With caching/synchronization:
[01:16:45 INFO]: Block time: 15332366µs
[01:17:20 INFO]: Block time: 15238158µs
[01:17:58 INFO]: Block time: 15215652µs

Without caching/synchronization:
[01:18:32 INFO]: Block time: 10544803µs
[01:19:05 INFO]: Block time: 10398937µs
[01:19:40 INFO]: Block time: 10847860µs
```

**JIRA Ticket:**

BUKKIT-5425 - https://bukkit.atlassian.net/browse/BUKKIT-5425