Skip to content

Commit

Permalink
Merge pull request #93 from DevotedMC/master
Browse files Browse the repository at this point in the history
Fix for 'Extra Data for a Block Sometimes Will Lost' and 'Animals are…
  • Loading branch information
ProgrammerDan committed May 11, 2016
2 parents 1b4e7b3 + e3e871c commit d66a917
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.lishid</groupId>
<artifactId>orebfuscator</artifactId>
<version>4.0.11-SNAPSHOT</version>
<version>4.0.12-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Orebfuscator4</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.WeakHashMap;
import java.util.concurrent.atomic.AtomicBoolean;

import net.minecraft.server.v1_9_R1.PacketPlayOutMapChunk;
import net.minecraft.server.v1_9_R1.PlayerChunk;
import net.minecraft.server.v1_9_R1.PlayerChunkMap;
import net.minecraft.server.v1_9_R1.WorldServer;
Expand Down Expand Up @@ -124,32 +123,45 @@ public void run() {
}

private static void reloadChunks(
World world,
final World world,
HashSet<ChunkCoord> chunksForReloadForWorld,
ArrayList<ChunkCoord> reloadedChunks
)
{
WorldServer worldServer = ((CraftWorld)world).getHandle();
PlayerChunkMap chunkMap = worldServer.getPlayerChunkMap();
File cacheFolder = new File(OrebfuscatorConfig.getCacheFolder(), world.getName());
File cacheFolder = new File(OrebfuscatorConfig.getCacheFolder(), world.getName());
final ArrayList<ChunkCoord> scheduledChunksForReload = new ArrayList<ChunkCoord>();

for(ChunkCoord chunk : chunksForReloadForWorld) {
if(!chunkMap.isChunkInUse(chunk.x, chunk.z)) continue;

PlayerChunk playerChunk = chunkMap.b(chunk.x, chunk.z);
if(playerChunk == null || playerChunk.chunk == null || !playerChunk.chunk.isReady()) continue;

reloadedChunks.add(chunk);

if(OrebfuscatorConfig.UseCache) {
ObfuscatedCachedChunk cache = new ObfuscatedCachedChunk(cacheFolder, chunk.x, chunk.z);
if(cache.getHash() != 0) continue;
}

//Orebfuscator.log("Force chunk x = " + chunk.x + ", z = " + chunk.z + " reload for players");/*debug*/
scheduledChunksForReload.add(chunk);

playerChunk.a(new PacketPlayOutMapChunk(playerChunk.chunk, true, 0xffff));//Reload chunks for players loaded it
//Orebfuscator.log("Add chunk x = " + chunk.x + ", z = " + chunk.z + " to schedule for reload for players");/*debug*/
}

Orebfuscator.instance.runTask(new Runnable() {
@Override
public void run() {
//Reload chunk for players
for(ChunkCoord chunk : scheduledChunksForReload) {
world.refreshChunk(chunk.x, chunk.z);

//Orebfuscator.log("Force chunk x = " + chunk.x + ", z = " + chunk.z + " to reload for players");/*debug*/
}
}
});
}

private static void restart() {
Expand Down

0 comments on commit d66a917

Please sign in to comment.