Fix chunk loading for sponge

This commit is contained in:
Jesse Boyd 2016-05-21 01:28:36 +10:00
parent ba2f9159b6
commit cf3dd6eb31
2 changed files with 28 additions and 9 deletions

View File

@ -45,7 +45,6 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraft.world.gen.ChunkProviderServer;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.world.Chunk;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
@ -136,8 +135,9 @@ public class SpongeQueue_1_8 extends NMSMappedFaweQueue<World, net.minecraft.wor
@Override
public boolean isChunkLoaded(World world, int x, int z) {
Chunk chunk = world.getChunk(x << 4, 0, z << 4).orElse(null);
return chunk != null && chunk.isLoaded();
net.minecraft.world.World nmsWorld = (net.minecraft.world.World) world;
IChunkProvider provider = nmsWorld.getChunkProvider();
return provider.chunkExists(x, z);
}
@Override
@ -603,8 +603,16 @@ public class SpongeQueue_1_8 extends NMSMappedFaweQueue<World, net.minecraft.wor
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
Chunk chunk = world.loadChunk(cx, 0, cz, true).orElse(null);
return ((net.minecraft.world.chunk.Chunk) chunk).getBlockStorageArray();
net.minecraft.world.World nmsWorld = (net.minecraft.world.World) world;
IChunkProvider provider = nmsWorld.getChunkProvider();
net.minecraft.world.chunk.Chunk chunk = provider.provideChunk(cx, cz);
if (chunk == null) {
return null;
}
if (!chunk.isLoaded()) {
chunk.onChunkLoad();
}
return chunk.getBlockStorageArray();
}
@Override

View File

@ -126,10 +126,12 @@ public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.wor
@Override
public boolean isChunkLoaded(World world, int x, int z) {
Chunk chunk = world.getChunk(x << 4, 0, z << 4).orElse(null);
return chunk != null && chunk.isLoaded();
net.minecraft.world.World nmsWorld = (net.minecraft.world.World) world;
IChunkProvider provider = nmsWorld.getChunkProvider();
return provider.chunkExists(x, z);
}
@Override
public boolean regenerateChunk(World world, int x, int z) {
try {
@ -377,9 +379,18 @@ public class SpongeQueue_ALL extends NMSMappedFaweQueue<World, net.minecraft.wor
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
Chunk chunk = world.loadChunk(cx, 0, cz, true).orElse(null);
return ((net.minecraft.world.chunk.Chunk) chunk).getBlockStorageArray();
net.minecraft.world.World nmsWorld = (net.minecraft.world.World) world;
IChunkProvider provider = nmsWorld.getChunkProvider();
net.minecraft.world.chunk.Chunk chunk = provider.provideChunk(cx, cz);
if (chunk == null) {
return null;
}
if (!chunk.isLoaded()) {
chunk.onChunkLoad();
}
return chunk.getBlockStorageArray();
}
@Override
public int getCombinedId4Data(char[] chars, int x, int y, int z) {