Re-add the forge/sponge modules

This commit is contained in:
Jesse Boyd 2017-02-06 13:09:44 +11:00
parent 81dcf26a2a
commit 0427771b7e
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
15 changed files with 298 additions and 450 deletions

View File

@ -157,7 +157,6 @@ public class BukkitQueue_1_11 extends BukkitQueue_0<net.minecraft.server.v1_11_R
@Override @Override
public net.minecraft.server.v1_11_R1.Chunk loadChunk(World world, int x, int z, boolean generate) { public net.minecraft.server.v1_11_R1.Chunk loadChunk(World world, int x, int z, boolean generate) {
net.minecraft.server.v1_11_R1.Chunk chunk;
net.minecraft.server.v1_11_R1.ChunkProviderServer provider = ((org.bukkit.craftbukkit.v1_11_R1.CraftWorld) world).getHandle().getChunkProviderServer(); net.minecraft.server.v1_11_R1.ChunkProviderServer provider = ((org.bukkit.craftbukkit.v1_11_R1.CraftWorld) world).getHandle().getChunkProviderServer();
if (generate) { if (generate) {
return provider.getOrLoadChunkAt(x, z); return provider.getOrLoadChunkAt(x, z);

View File

@ -156,8 +156,6 @@ public class ClipboardCommands {
} }
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId()); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
clipboard.setOrigin(session.getPlacementPosition(player)); clipboard.setOrigin(session.getPlacementPosition(player));
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint()); ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
Mask sourceMask = editSession.getSourceMask(); Mask sourceMask = editSession.getSourceMask();

View File

@ -329,19 +329,11 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + nonEmptyBlockCount, section); getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + nonEmptyBlockCount, section);
} }
// Set biomes // Set biomes
int[][] biomes = this.biomes; if (this.biomes != null) {
if (biomes != null) { byte[] currentBiomes = nmsChunk.getBiomeArray();
for (int x = 0; x < 16; x++) { for (int i = 0 ; i < this.biomes.length; i++) {
int[] array = biomes[x]; if (this.biomes[i] != 0) {
if (array == null) { currentBiomes[i] = this.biomes[i];
continue;
}
for (int z = 0; z < 16; z++) {
int biome = array[z];
if (biome == 0) {
continue;
}
nmsChunk.getBiomeArray()[((z & 0xF) << 4 | x & 0xF)] = (byte) biome;
} }
} }
} }
@ -367,22 +359,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} catch (Throwable e) { } catch (Throwable e) {
MainUtil.handleError(e); MainUtil.handleError(e);
} }
int[][] biomes = this.biomes;
if (biomes != null) {
for (int x = 0; x < 16; x++) {
int[] array = biomes[x];
if (array == null) {
continue;
}
for (int z = 0; z < 16; z++) {
int biome = array[z];
if (biome == 0) {
continue;
}
nmsChunk.getBiomeArray()[((z & 0xF) << 4 | x & 0xF)] = (byte) biome;
}
}
}
return this; return this;
} }
} }

View File

@ -106,6 +106,45 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
} }
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
return chunk.getBlockStorageArray();
}
@Override
public int getBiome(Chunk chunk, int x, int z) {
return chunk.getBiomeArray()[((z & 15) << 4) + (x & 15)];
}
@Override
public Chunk loadChunk(World world, int x, int z, boolean generate) {
ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider();
if (generate) {
return provider.provideChunk(x, z);
} else {
return provider.loadChunk(x, z);
}
}
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
Chunk chunk = world.getChunkProvider().getLoadedChunk(cx, cz);
if (chunk != null) {
return chunk.getBlockStorageArray();
}
return null;
}
@Override
public Chunk getCachedChunk(World world, int cx, int cz) {
return world.getChunkProvider().getLoadedChunk(cx, cz);
}
@Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] ExtendedBlockStorages, int cy) {
return ExtendedBlockStorages[cy];
}
@Override @Override
public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) { public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
for (Map.Entry<Long, Map<Short, Character>> chunkEntry : blockMap.entrySet()) { for (Map.Entry<Long, Map<Short, Character>> chunkEntry : blockMap.entrySet()) {
@ -156,20 +195,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
} }
@Override
public Chunk getChunk(World world, int x, int z) {
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
if (chunk != null && !chunk.isLoaded()) {
chunk.onChunkLoad();
}
return chunk;
}
@Override
public boolean isChunkLoaded(int x, int z) {
return getWorld().getChunkProvider().getLoadedChunk(x, z) != null;
}
@Override @Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) { public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
IChunkProvider provider = world.getChunkProvider(); IChunkProvider provider = world.getChunkProvider();
@ -227,25 +252,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
} }
@Override
public boolean loadChunk(World world, int x, int z, boolean generate) {
return getCachedSections(world, x, z) != null;
}
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int x, int z) {
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
if (chunk != null && !chunk.isLoaded()) {
chunk.onChunkLoad();
}
return chunk == null ? null : chunk.getBlockStorageArray();
}
@Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] chunk, int cy) {
return chunk[cy];
}
@Override @Override
public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) { public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) {
IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15); IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15);
@ -258,11 +264,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
} }
@Override
public boolean isChunkLoaded(World world, int x, int z) {
return world.getChunkProvider().getLoadedChunk(x, z) != null;
}
public int getNonEmptyBlockCount(ExtendedBlockStorage section) throws IllegalAccessException { public int getNonEmptyBlockCount(ExtendedBlockStorage section) throws IllegalAccessException {
return (int) fieldNonEmptyBlockCount.get(section); return (int) fieldNonEmptyBlockCount.get(section);
} }
@ -358,20 +359,18 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override @Override
public void sendChunk(int x, int z, int bitMask) { public void sendChunk(int x, int z, int bitMask) {
if (!isChunkLoaded(x, z)) { Chunk chunk = getCachedChunk(getWorld(), x, z);
return; if (chunk != null) {
sendChunk(chunk, bitMask);
} }
sendChunk(getChunk(getImpWorld(), x, z), bitMask);
} }
@Override @Override
public void refreshChunk(FaweChunk fc) { public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc; Chunk chunk = getCachedChunk(getWorld(), fc.getX(), fc.getZ());
if (!isChunkLoaded(fc.getX(), fc.getZ())) { if (chunk != null) {
return; sendChunk(chunk, fc.getBitMask());
} }
Chunk chunk = fs.getChunk();
sendChunk(chunk, fs.getBitMask());
} }
public void sendChunk(Chunk nmsChunk, int mask) { public void sendChunk(Chunk nmsChunk, int mask) {

View File

@ -348,19 +348,11 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + nonEmptyBlockCount, section); getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + nonEmptyBlockCount, section);
} }
// Set biomes // Set biomes
int[][] biomes = this.biomes; if (this.biomes != null) {
if (biomes != null) { byte[] currentBiomes = nmsChunk.getBiomeArray();
for (int x = 0; x < 16; x++) { for (int i = 0 ; i < this.biomes.length; i++) {
int[] array = biomes[x]; if (this.biomes[i] != 0) {
if (array == null) { currentBiomes[i] = this.biomes[i];
continue;
}
for (int z = 0; z < 16; z++) {
int biome = array[z];
if (biome == 0) {
continue;
}
nmsChunk.getBiomeArray()[((z & 0xF) << 4 | x & 0xF)] = (byte) biome;
} }
} }
} }
@ -386,22 +378,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} catch (Throwable e) { } catch (Throwable e) {
MainUtil.handleError(e); MainUtil.handleError(e);
} }
int[][] biomes = this.biomes;
if (biomes != null) {
for (int x = 0; x < 16; x++) {
int[] array = biomes[x];
if (array == null) {
continue;
}
for (int z = 0; z < 16; z++) {
int biome = array[z];
if (biome == 0) {
continue;
}
nmsChunk.getBiomeArray()[((z & 0xF) << 4 | x & 0xF)] = (byte) biome;
}
}
}
return this; return this;
} }
} }

View File

@ -121,6 +121,46 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
getImpWorld(); getImpWorld();
} }
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
return chunk.getBlockStorageArray();
}
@Override
public int getBiome(Chunk chunk, int x, int z) {
return chunk.getBiomeArray()[((z & 15) << 4) + (x & 15)];
}
@Override
public Chunk loadChunk(World world, int x, int z, boolean generate) {
ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider();
if (generate) {
return provider.provideChunk(x, z);
} else {
return provider.loadChunk(x, z);
}
}
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
Chunk chunk = world.getChunkProvider().getLoadedChunk(cx, cz);
if (chunk != null) {
return chunk.getBlockStorageArray();
}
return null;
}
@Override
public Chunk getCachedChunk(World world, int cx, int cz) {
return world.getChunkProvider().getLoadedChunk(cx, cz);
}
@Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] ExtendedBlockStorages, int cy) {
return ExtendedBlockStorages[cy];
}
@Override @Override
public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) { public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
for (Map.Entry<Long, Map<Short, Character>> chunkEntry : blockMap.entrySet()) { for (Map.Entry<Long, Map<Short, Character>> chunkEntry : blockMap.entrySet()) {
@ -186,20 +226,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
} }
@Override
public Chunk getChunk(World world, int x, int z) {
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
if (chunk != null && !chunk.isLoaded()) {
chunk.onChunkLoad();
}
return chunk;
}
@Override
public boolean isChunkLoaded(int x, int z) {
return getWorld().getChunkProvider().getLoadedChunk(x, z) != null;
}
@Override @Override
public boolean regenerateChunk(net.minecraft.world.World world, int x, int z, BaseBiome biome, Long seed) { public boolean regenerateChunk(net.minecraft.world.World world, int x, int z, BaseBiome biome, Long seed) {
if (biome != null) { if (biome != null) {
@ -303,25 +329,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
} }
@Override
public boolean loadChunk(World world, int x, int z, boolean generate) {
return getCachedSections(world, x, z) != null;
}
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int x, int z) {
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
if (chunk != null && !chunk.isLoaded()) {
chunk.onChunkLoad();
}
return chunk == null ? null : chunk.getBlockStorageArray();
}
@Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] chunk, int cy) {
return chunk[cy];
}
@Override @Override
public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) { public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) {
IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15); IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15);
@ -334,11 +341,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
} }
@Override
public boolean isChunkLoaded(World world, int x, int z) {
return world.getChunkProvider().getLoadedChunk(x, z) != null;
}
public int getNonEmptyBlockCount(ExtendedBlockStorage section) throws IllegalAccessException { public int getNonEmptyBlockCount(ExtendedBlockStorage section) throws IllegalAccessException {
return (int) fieldNonEmptyBlockCount.get(section); return (int) fieldNonEmptyBlockCount.get(section);
} }
@ -434,20 +436,18 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override @Override
public void sendChunk(int x, int z, int bitMask) { public void sendChunk(int x, int z, int bitMask) {
if (!isChunkLoaded(x, z)) { Chunk chunk = getCachedChunk(getWorld(), x, z);
return; if (chunk != null) {
sendChunk(chunk, bitMask);
} }
sendChunk(getChunk(getImpWorld(), x, z), bitMask);
} }
@Override @Override
public void refreshChunk(FaweChunk fc) { public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc; Chunk chunk = getCachedChunk(getWorld(), fc.getX(), fc.getZ());
if (!isChunkLoaded(fc.getX(), fc.getZ())) { if (chunk != null) {
return; sendChunk(chunk, fc.getBitMask());
} }
Chunk chunk = fs.getChunk();
sendChunk(chunk, fs.getBitMask());
} }
public void sendChunk(Chunk nmsChunk, int mask) { public void sendChunk(Chunk nmsChunk, int mask) {

View File

@ -297,19 +297,11 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} }
// Set biomes // Set biomes
int[][] biomes = this.biomes; if (this.biomes != null) {
if (biomes != null) { byte[] currentBiomes = nmsChunk.getBiomeArray();
for (int x = 0; x < 16; x++) { for (int i = 0 ; i < this.biomes.length; i++) {
int[] array = biomes[x]; if (this.biomes[i] != 0) {
if (array == null) { currentBiomes[i] = this.biomes[i];
continue;
}
for (int z = 0; z < 16; z++) {
int biome = array[z];
if (biome == 0) {
continue;
}
nmsChunk.getBiomeArray()[((z & 0xF) << 4 | x & 0xF)] = (byte) biome;
} }
} }
} }
@ -336,22 +328,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} catch (Throwable e) { } catch (Throwable e) {
MainUtil.handleError(e); MainUtil.handleError(e);
} }
int[][] biomes = this.biomes;
if (biomes != null) {
for (int x = 0; x < 16; x++) {
int[] array = biomes[x];
if (array == null) {
continue;
}
for (int z = 0; z < 16; z++) {
int biome = array[z];
if (biome == 0) {
continue;
}
nmsChunk.getBiomeArray()[((z & 0xF) << 4 | x & 0xF)] = (byte) biome;
}
}
}
return this; return this;
} }

View File

@ -116,31 +116,42 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
@Override @Override
public Chunk getChunk(World world, int x, int z) { public ExtendedBlockStorage[] getSections(Chunk chunk) {
Chunk chunk = world.getChunkProvider().provideChunk(x, z); return chunk.getBlockStorageArray();
if (chunk != null && !chunk.isChunkLoaded) {
chunk.onChunkLoad();
}
return chunk;
} }
@Override @Override
public boolean loadChunk(World world, int x, int z, boolean generate) { public int getBiome(Chunk chunk, int x, int z) {
return getCachedSections(world, x, z) != null; return chunk.getBiomeArray()[((z & 15) << 4) + (x & 15)];
}
@Override
public Chunk loadChunk(World world, int x, int z, boolean generate) {
ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider();
if (generate) {
return provider.provideChunk(x, z);
} else {
return provider.loadChunk(x, z);
}
} }
@Override @Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) { public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
Chunk chunk = world.getChunkProvider().provideChunk(cx, cz); Chunk chunk = (Chunk) ((ChunkProviderServer)world.getChunkProvider()).loadedChunkHashMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(cx, cz));
if (chunk != null && !chunk.isChunkLoaded) { if (chunk != null) {
chunk.onChunkLoad(); return chunk.getBlockStorageArray();
} }
return chunk != null ? chunk.getBlockStorageArray() : null; return null;
} }
@Override @Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] extendedBlockStorages, int cy) { public Chunk getCachedChunk(World world, int cx, int cz) {
return extendedBlockStorages[cy]; return (Chunk) ((ChunkProviderServer)world.getChunkProvider()).loadedChunkHashMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(cx, cz));
}
@Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] ExtendedBlockStorages, int cy) {
return ExtendedBlockStorages[cy];
} }
@Override @Override
@ -152,11 +163,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
return combined; return combined;
} }
@Override
public boolean isChunkLoaded(World world, int x, int z) {
return world.getChunkProvider().chunkExists(x, z);
}
@Override @Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) { public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
try { try {
@ -237,20 +243,18 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override @Override
public void sendChunk(int x, int z, int bitMask) { public void sendChunk(int x, int z, int bitMask) {
if (!isChunkLoaded(x, z)) { Chunk chunk = getCachedChunk(getWorld(), x, z);
return; if (chunk != null) {
sendChunk(chunk, bitMask);
} }
sendChunk(getChunk(getImpWorld(), x, z), bitMask);
} }
@Override @Override
public void refreshChunk(FaweChunk fc) { public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc; Chunk chunk = getCachedChunk(getWorld(), fc.getX(), fc.getZ());
if (!isChunkLoaded(fc.getX(), fc.getZ())) { if (chunk != null) {
return; sendChunk(chunk, fc.getBitMask());
} }
Chunk chunk = fs.getChunk();
sendChunk(chunk, fs.getBitMask());
} }
public void sendChunk(Chunk nmsChunk, int mask) { public void sendChunk(Chunk nmsChunk, int mask) {

View File

@ -245,19 +245,11 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} }
// Set biomes // Set biomes
int[][] biomes = this.biomes; if (this.biomes != null) {
if (biomes != null) { byte[] currentBiomes = nmsChunk.getBiomeArray();
for (int x = 0; x < 16; x++) { for (int i = 0 ; i < this.biomes.length; i++) {
int[] array = biomes[x]; if (this.biomes[i] != 0) {
if (array == null) { currentBiomes[i] = this.biomes[i];
continue;
}
for (int z = 0; z < 16; z++) {
int biome = array[z];
if (biome == 0) {
continue;
}
nmsChunk.getBiomeArray()[((z & 0xF) << 4 | x & 0xF)] = (byte) biome;
} }
} }
} }
@ -282,22 +274,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} catch (Throwable e) { } catch (Throwable e) {
MainUtil.handleError(e); MainUtil.handleError(e);
} }
int[][] biomes = this.biomes;
if (biomes != null) {
for (int x = 0; x < 16; x++) {
int[] array = biomes[x];
if (array == null) {
continue;
}
for (int z = 0; z < 16; z++) {
int biome = array[z];
if (biome == 0) {
continue;
}
nmsChunk.getBiomeArray()[((z & 0xF) << 4 | x & 0xF)] = (byte) biome;
}
}
}
return this; return this;
} }
} }

View File

@ -84,6 +84,45 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
getImpWorld(); getImpWorld();
} }
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
return chunk.getBlockStorageArray();
}
@Override
public int getBiome(Chunk chunk, int x, int z) {
return chunk.getBiomeArray()[((z & 15) << 4) + (x & 15)];
}
@Override
public Chunk loadChunk(World world, int x, int z, boolean generate) {
ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider();
if (generate) {
return provider.provideChunk(x, z);
} else {
return provider.loadChunk(x, z);
}
}
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
Chunk chunk = ((ChunkProviderServer)world.getChunkProvider()).id2ChunkMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(cx, cz));
if (chunk != null) {
return chunk.getBlockStorageArray();
}
return null;
}
@Override
public Chunk getCachedChunk(World world, int cx, int cz) {
return ((ChunkProviderServer)world.getChunkProvider()).id2ChunkMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(cx, cz));
}
@Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] ExtendedBlockStorages, int cy) {
return ExtendedBlockStorages[cy];
}
@Override @Override
public void setHeightMap(FaweChunk chunk, byte[] heightMap) { public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
Chunk forgeChunk = (Chunk) chunk.getChunk(); Chunk forgeChunk = (Chunk) chunk.getChunk();
@ -120,20 +159,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
} }
@Override
public Chunk getChunk(World world, int x, int z) {
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
if (chunk != null && !chunk.isLoaded()) {
chunk.onChunkLoad();
}
return chunk;
}
@Override
public boolean isChunkLoaded(int x, int z) {
return getWorld().getChunkProvider().chunkExists(x, z);
}
@Override @Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) { public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
IChunkProvider provider = world.getChunkProvider(); IChunkProvider provider = world.getChunkProvider();
@ -168,35 +193,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
return true; return true;
} }
@Override
public boolean loadChunk(World world, int x, int z, boolean generate) {
return getCachedSections(world, x, z) != null;
}
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int x, int z) {
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
if (chunk != null && !chunk.isLoaded()) {
chunk.onChunkLoad();
}
return chunk == null ? null : chunk.getBlockStorageArray();
}
@Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] chunk, int cy) {
return chunk[cy];
}
@Override
public int getCombinedId4Data(ExtendedBlockStorage ls, int x, int y, int z) {
return ls.getData()[FaweCache.CACHE_J[y][z & 15][x & 15]];
}
@Override
public boolean isChunkLoaded(World world, int x, int z) {
return world.getChunkProvider().chunkExists(x, z);
}
public void setCount(int tickingBlockCount, int nonEmptyBlockCount, ExtendedBlockStorage section) throws NoSuchFieldException, IllegalAccessException { public void setCount(int tickingBlockCount, int nonEmptyBlockCount, ExtendedBlockStorage section) throws NoSuchFieldException, IllegalAccessException {
fieldTickingBlockCount.set(section, tickingBlockCount); fieldTickingBlockCount.set(section, tickingBlockCount);
fieldNonEmptyBlockCount.set(section, nonEmptyBlockCount); fieldNonEmptyBlockCount.set(section, nonEmptyBlockCount);
@ -299,20 +295,18 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override @Override
public void sendChunk(int x, int z, int bitMask) { public void sendChunk(int x, int z, int bitMask) {
if (!isChunkLoaded(x, z)) { Chunk chunk = getCachedChunk(getWorld(), x, z);
return; if (chunk != null) {
sendChunk(chunk, bitMask);
} }
sendChunk(getChunk(getImpWorld(), x, z), bitMask);
} }
@Override @Override
public void refreshChunk(FaweChunk fc) { public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc; Chunk chunk = getCachedChunk(getWorld(), fc.getX(), fc.getZ());
if (!isChunkLoaded(fc.getX(), fc.getZ())) { if (chunk != null) {
return; sendChunk(chunk, fc.getBitMask());
} }
Chunk chunk = fs.getChunk();
sendChunk(chunk, fs.getBitMask());
} }
public void sendChunk(Chunk nmsChunk, int mask) { public void sendChunk(Chunk nmsChunk, int mask) {
@ -386,6 +380,11 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
return new ForgeChunk_All(this, x, z); return new ForgeChunk_All(this, x, z);
} }
@Override
public int getCombinedId4Data(ExtendedBlockStorage ls, int x, int y, int z) {
return ls.getData()[FaweCache.CACHE_J[y][z & 15][x & 15]];
}
public int getId(ExtendedBlockStorage[] sections, int x, int y, int z) { public int getId(ExtendedBlockStorage[] sections, int x, int y, int z) {
if (x < 0 || x > 15 || z < 0 || z > 15) { if (x < 0 || x > 15 || z < 0 || z > 15) {
return 1; return 1;

View File

@ -327,19 +327,11 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + nonEmptyBlockCount, section); getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + nonEmptyBlockCount, section);
} }
// Set biomes // Set biomes
int[][] biomes = this.biomes; if (this.biomes != null) {
if (biomes != null) { byte[] currentBiomes = nmsChunk.getBiomeArray();
for (int x = 0; x < 16; x++) { for (int i = 0 ; i < this.biomes.length; i++) {
int[] array = biomes[x]; if (this.biomes[i] != 0) {
if (array == null) { currentBiomes[i] = this.biomes[i];
continue;
}
for (int z = 0; z < 16; z++) {
int biome = array[z];
if (biome == 0) {
continue;
}
nmsChunk.getBiomeArray()[((z & 0xF) << 4 | x & 0xF)] = (byte) biome;
} }
} }
} }
@ -365,22 +357,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} catch (Throwable e) { } catch (Throwable e) {
MainUtil.handleError(e); MainUtil.handleError(e);
} }
int[][] biomes = this.biomes;
if (biomes != null) {
for (int x = 0; x < 16; x++) {
int[] array = biomes[x];
if (array == null) {
continue;
}
for (int z = 0; z < 16; z++) {
int biome = array[z];
if (biome == 0) {
continue;
}
nmsChunk.getBiomeArray()[((z & 0xF) << 4 | x & 0xF)] = (byte) biome;
}
}
}
return this; return this;
} }
} }

View File

@ -91,6 +91,45 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
getImpWorld(); getImpWorld();
} }
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
return chunk.getBlockStorageArray();
}
@Override
public int getBiome(Chunk chunk, int x, int z) {
return chunk.getBiomeArray()[((z & 15) << 4) + (x & 15)];
}
@Override
public Chunk loadChunk(World world, int x, int z, boolean generate) {
ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider();
if (generate) {
return provider.provideChunk(x, z);
} else {
return provider.loadChunk(x, z);
}
}
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
Chunk chunk = world.getChunkProvider().getLoadedChunk(cx, cz);
if (chunk != null) {
return chunk.getBlockStorageArray();
}
return null;
}
@Override
public Chunk getCachedChunk(World world, int cx, int cz) {
return world.getChunkProvider().getLoadedChunk(cx, cz);
}
@Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] ExtendedBlockStorages, int cy) {
return ExtendedBlockStorages[cy];
}
@Override @Override
public void setHeightMap(FaweChunk chunk, byte[] heightMap) { public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
Chunk forgeChunk = (Chunk) chunk.getChunk(); Chunk forgeChunk = (Chunk) chunk.getChunk();
@ -128,20 +167,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
} }
@Override
public Chunk getChunk(World world, int x, int z) {
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
if (chunk != null && !chunk.isLoaded()) {
chunk.onChunkLoad();
}
return chunk;
}
@Override
public boolean isChunkLoaded(int x, int z) {
return getWorld().getChunkProvider().getLoadedChunk(x, z) != null;
}
@Override @Override
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) { public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
IChunkProvider provider = world.getChunkProvider(); IChunkProvider provider = world.getChunkProvider();
@ -197,25 +222,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
} }
@Override
public boolean loadChunk(World world, int x, int z, boolean generate) {
return getCachedSections(world, x, z) != null;
}
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int x, int z) {
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
if (chunk != null && !chunk.isLoaded()) {
chunk.onChunkLoad();
}
return chunk == null ? null : chunk.getBlockStorageArray();
}
@Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] chunk, int cy) {
return chunk[cy];
}
@Override @Override
public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) { public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) {
IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15); IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15);
@ -228,11 +234,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
} }
} }
@Override
public boolean isChunkLoaded(World world, int x, int z) {
return world.getChunkProvider().getLoadedChunk(x, z) != null;
}
public int getNonEmptyBlockCount(ExtendedBlockStorage section) throws IllegalAccessException { public int getNonEmptyBlockCount(ExtendedBlockStorage section) throws IllegalAccessException {
return (int) fieldNonEmptyBlockCount.get(section); return (int) fieldNonEmptyBlockCount.get(section);
} }
@ -348,28 +349,20 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
protected final static IBlockState air = Blocks.AIR.getDefaultState(); protected final static IBlockState air = Blocks.AIR.getDefaultState();
public void setPalette(ExtendedBlockStorage section, BlockStateContainer palette) throws NoSuchFieldException, IllegalAccessException {
Field fieldSection = ExtendedBlockStorage.class.getDeclaredField("data");
fieldSection.setAccessible(true);
fieldSection.set(section, palette);
}
@Override @Override
public void sendChunk(int x, int z, int bitMask) { public void sendChunk(int x, int z, int bitMask) {
if (!isChunkLoaded(x, z)) { Chunk chunk = getCachedChunk(getWorld(), x, z);
return; if (chunk != null) {
sendChunk(chunk, bitMask);
} }
sendChunk(getChunk(getImpWorld(), x, z), bitMask);
} }
@Override @Override
public void refreshChunk(FaweChunk fc) { public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc; Chunk chunk = getCachedChunk(getWorld(), fc.getX(), fc.getZ());
if (!isChunkLoaded(fc.getX(), fc.getZ())) { if (chunk != null) {
return; sendChunk(chunk, fc.getBitMask());
} }
Chunk chunk = fs.getChunk();
sendChunk(chunk, fs.getBitMask());
} }
public void sendChunk(Chunk nmsChunk, int mask) { public void sendChunk(Chunk nmsChunk, int mask) {

View File

@ -1,3 +1,3 @@
rootProject.name = 'FastAsyncWorldEdit' rootProject.name = 'FastAsyncWorldEdit'
include 'core', 'bukkit', 'favs', 'nukkit'//, 'sponge', 'forge1710', 'forge189', 'forge194', 'forge110', 'forge111' include 'core', 'bukkit', 'favs', 'nukkit', 'sponge', 'forge1710', 'forge189', 'forge194', 'forge110', 'forge111'

View File

@ -363,19 +363,11 @@ public class SpongeChunk_1_11 extends CharFaweChunk<Chunk, SpongeQueue_1_11> {
getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + nonEmptyBlockCount, section); getParent().setCount(0, getParent().getNonEmptyBlockCount(section) + nonEmptyBlockCount, section);
} }
// Set biomes // Set biomes
int[][] biomes = this.biomes; if (this.biomes != null) {
if (biomes != null) { byte[] currentBiomes = nmsChunk.getBiomeArray();
for (int x = 0; x < 16; x++) { for (int i = 0 ; i < this.biomes.length; i++) {
int[] array = biomes[x]; if (this.biomes[i] != 0) {
if (array == null) { currentBiomes[i] = this.biomes[i];
continue;
}
for (int z = 0; z < 16; z++) {
int biome = array[z];
if (biome == 0) {
continue;
}
nmsChunk.getBiomeArray()[((z & 0xF) << 4 | x & 0xF)] = (byte) biome;
} }
} }
} }
@ -401,22 +393,6 @@ public class SpongeChunk_1_11 extends CharFaweChunk<Chunk, SpongeQueue_1_11> {
} catch (Throwable e) { } catch (Throwable e) {
MainUtil.handleError(e); MainUtil.handleError(e);
} }
int[][] biomes = this.biomes;
if (biomes != null) {
for (int x = 0; x < 16; x++) {
int[] array = biomes[x];
if (array == null) {
continue;
}
for (int z = 0; z < 16; z++) {
int biome = array[z];
if (biome == 0) {
continue;
}
nmsChunk.getBiomeArray()[((z & 0xF) << 4 | x & 0xF)] = (byte) biome;
}
}
}
return this; return this;
} }
} }

View File

@ -155,6 +155,45 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
} }
} }
@Override
public ExtendedBlockStorage[] getSections(Chunk chunk) {
return chunk.getBlockStorageArray();
}
@Override
public int getBiome(Chunk chunk, int x, int z) {
return chunk.getBiomeArray()[((z & 15) << 4) + (x & 15)];
}
@Override
public Chunk loadChunk(World world, int x, int z, boolean generate) {
ChunkProviderServer provider = (ChunkProviderServer) world.getChunkProvider();
if (generate) {
return provider.provideChunk(x, z);
} else {
return provider.loadChunk(x, z);
}
}
@Override
public ExtendedBlockStorage[] getCachedSections(World world, int cx, int cz) {
Chunk chunk = world.getChunkProvider().getLoadedChunk(cx, cz);
if (chunk != null) {
return chunk.getBlockStorageArray();
}
return null;
}
@Override
public Chunk getCachedChunk(World world, int cx, int cz) {
return world.getChunkProvider().getLoadedChunk(cx, cz);
}
@Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] ExtendedBlockStorages, int cy) {
return ExtendedBlockStorages[cy];
}
@Override @Override
public void setHeightMap(FaweChunk chunk, byte[] heightMap) { public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
Chunk forgeChunk = (Chunk) chunk.getChunk(); Chunk forgeChunk = (Chunk) chunk.getChunk();
@ -192,20 +231,6 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
} }
} }
@Override
public Chunk getChunk(net.minecraft.world.World world, int x, int z) {
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
if (chunk != null && !chunk.isLoaded()) {
chunk.onChunkLoad();
}
return chunk;
}
@Override
public boolean isChunkLoaded(int x, int z) {
return getWorld().getChunkProvider().getLoadedChunk(x, z) != null;
}
public boolean regenerateChunk(net.minecraft.world.World world, int x, int z) { public boolean regenerateChunk(net.minecraft.world.World world, int x, int z) {
IChunkProvider provider = world.getChunkProvider(); IChunkProvider provider = world.getChunkProvider();
if (!(provider instanceof ChunkProviderServer)) { if (!(provider instanceof ChunkProviderServer)) {
@ -312,25 +337,6 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
return regenerateChunk(world, x, z); return regenerateChunk(world, x, z);
} }
@Override
public boolean loadChunk(net.minecraft.world.World world, int x, int z, boolean generate) {
return getCachedSections(world, x, z) != null;
}
@Override
public ExtendedBlockStorage[] getCachedSections(net.minecraft.world.World world, int x, int z) {
Chunk chunk = world.getChunkProvider().provideChunk(x, z);
if (chunk != null && !chunk.isLoaded()) {
chunk.onChunkLoad();
}
return chunk == null ? null : chunk.getBlockStorageArray();
}
@Override
public ExtendedBlockStorage getCachedSection(ExtendedBlockStorage[] chunk, int cy) {
return chunk[cy];
}
@Override @Override
public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) { public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) {
IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15); IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15);
@ -343,11 +349,6 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
} }
} }
@Override
public boolean isChunkLoaded(net.minecraft.world.World world, int x, int z) {
return world.getChunkProvider().getLoadedChunk(x, z) != null;
}
public int getNonEmptyBlockCount(ExtendedBlockStorage section) throws IllegalAccessException { public int getNonEmptyBlockCount(ExtendedBlockStorage section) throws IllegalAccessException {
return (int) fieldNonEmptyBlockCount.get(section); return (int) fieldNonEmptyBlockCount.get(section);
} }
@ -444,11 +445,18 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
@Override @Override
public void sendChunk(int x, int z, int bitMask) { public void sendChunk(int x, int z, int bitMask) {
if (!isChunkLoaded(x, z)) { Chunk chunk = getCachedChunk(getWorld(), x, z);
return; if (chunk != null) {
sendChunk(chunk, bitMask);
}
}
@Override
public void refreshChunk(FaweChunk fc) {
Chunk chunk = getCachedChunk(getWorld(), fc.getX(), fc.getZ());
if (chunk != null) {
sendChunk(chunk, fc.getBitMask());
} }
Chunk chunk = getChunk(getImpWorld(), x, z);
sendChunk(chunk, bitMask);
} }
public void sendChunk(Chunk nmsChunk, int mask) { public void sendChunk(Chunk nmsChunk, int mask) {
@ -501,14 +509,6 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
} }
} }
@Override
public void refreshChunk(FaweChunk fc) {
SpongeChunk_1_11 fs = (SpongeChunk_1_11) fc;
ensureChunkLoaded(fc.getX(), fc.getZ());
Chunk nmsChunk = fs.getChunk();
sendChunk(nmsChunk, fc.getBitMask());
}
public boolean hasEntities(Chunk nmsChunk) { public boolean hasEntities(Chunk nmsChunk) {
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists(); ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
for (int i = 0; i < entities.length; i++) { for (int i = 0; i < entities.length; i++) {