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
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();
if (generate) {
return provider.getOrLoadChunkAt(x, z);

View File

@ -156,8 +156,6 @@ public class ClipboardCommands {
}
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId());
clipboard.setOrigin(session.getPlacementPosition(player));
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
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);
}
// Set biomes
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;
if (this.biomes != null) {
byte[] currentBiomes = nmsChunk.getBiomeArray();
for (int i = 0 ; i < this.biomes.length; i++) {
if (this.biomes[i] != 0) {
currentBiomes[i] = this.biomes[i];
}
}
}
@ -367,22 +359,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} catch (Throwable 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;
}
}

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
public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
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
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
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
public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) {
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 {
return (int) fieldNonEmptyBlockCount.get(section);
}
@ -358,20 +359,18 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public void sendChunk(int x, int z, int bitMask) {
if (!isChunkLoaded(x, z)) {
return;
Chunk chunk = getCachedChunk(getWorld(), x, z);
if (chunk != null) {
sendChunk(chunk, bitMask);
}
sendChunk(getChunk(getImpWorld(), x, z), bitMask);
}
@Override
public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc;
if (!isChunkLoaded(fc.getX(), fc.getZ())) {
return;
Chunk chunk = getCachedChunk(getWorld(), fc.getX(), fc.getZ());
if (chunk != null) {
sendChunk(chunk, fc.getBitMask());
}
Chunk chunk = fs.getChunk();
sendChunk(chunk, fs.getBitMask());
}
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);
}
// Set biomes
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;
if (this.biomes != null) {
byte[] currentBiomes = nmsChunk.getBiomeArray();
for (int i = 0 ; i < this.biomes.length; i++) {
if (this.biomes[i] != 0) {
currentBiomes[i] = this.biomes[i];
}
}
}
@ -386,22 +378,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} catch (Throwable 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;
}
}

View File

@ -121,6 +121,46 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
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
public void sendBlockUpdate(Map<Long, Map<Short, Character>> blockMap, FawePlayer... players) {
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
public boolean regenerateChunk(net.minecraft.world.World world, int x, int z, BaseBiome biome, Long seed) {
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
public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) {
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 {
return (int) fieldNonEmptyBlockCount.get(section);
}
@ -434,20 +436,18 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public void sendChunk(int x, int z, int bitMask) {
if (!isChunkLoaded(x, z)) {
return;
Chunk chunk = getCachedChunk(getWorld(), x, z);
if (chunk != null) {
sendChunk(chunk, bitMask);
}
sendChunk(getChunk(getImpWorld(), x, z), bitMask);
}
@Override
public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc;
if (!isChunkLoaded(fc.getX(), fc.getZ())) {
return;
Chunk chunk = getCachedChunk(getWorld(), fc.getX(), fc.getZ());
if (chunk != null) {
sendChunk(chunk, fc.getBitMask());
}
Chunk chunk = fs.getChunk();
sendChunk(chunk, fs.getBitMask());
}
public void sendChunk(Chunk nmsChunk, int mask) {

View File

@ -297,19 +297,11 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
}
// Set biomes
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;
if (this.biomes != null) {
byte[] currentBiomes = nmsChunk.getBiomeArray();
for (int i = 0 ; i < this.biomes.length; i++) {
if (this.biomes[i] != 0) {
currentBiomes[i] = this.biomes[i];
}
}
}
@ -336,22 +328,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} catch (Throwable 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;
}

View File

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

View File

@ -245,19 +245,11 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
}
// Set biomes
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;
if (this.biomes != null) {
byte[] currentBiomes = nmsChunk.getBiomeArray();
for (int i = 0 ; i < this.biomes.length; i++) {
if (this.biomes[i] != 0) {
currentBiomes[i] = this.biomes[i];
}
}
}
@ -282,22 +274,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} catch (Throwable 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;
}
}

View File

@ -84,6 +84,45 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
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
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
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
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
IChunkProvider provider = world.getChunkProvider();
@ -168,35 +193,6 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
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 {
fieldTickingBlockCount.set(section, tickingBlockCount);
fieldNonEmptyBlockCount.set(section, nonEmptyBlockCount);
@ -299,20 +295,18 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public void sendChunk(int x, int z, int bitMask) {
if (!isChunkLoaded(x, z)) {
return;
Chunk chunk = getCachedChunk(getWorld(), x, z);
if (chunk != null) {
sendChunk(chunk, bitMask);
}
sendChunk(getChunk(getImpWorld(), x, z), bitMask);
}
@Override
public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc;
if (!isChunkLoaded(fc.getX(), fc.getZ())) {
return;
Chunk chunk = getCachedChunk(getWorld(), fc.getX(), fc.getZ());
if (chunk != null) {
sendChunk(chunk, fc.getBitMask());
}
Chunk chunk = fs.getChunk();
sendChunk(chunk, fs.getBitMask());
}
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);
}
@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) {
if (x < 0 || x > 15 || z < 0 || z > 15) {
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);
}
// Set biomes
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;
if (this.biomes != null) {
byte[] currentBiomes = nmsChunk.getBiomeArray();
for (int i = 0 ; i < this.biomes.length; i++) {
if (this.biomes[i] != 0) {
currentBiomes[i] = this.biomes[i];
}
}
}
@ -365,22 +357,6 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk, ForgeQueue_All> {
} catch (Throwable 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;
}
}

View File

@ -91,6 +91,45 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
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
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
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
public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) {
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
public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) {
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 {
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();
public void setPalette(ExtendedBlockStorage section, BlockStateContainer palette) throws NoSuchFieldException, IllegalAccessException {
Field fieldSection = ExtendedBlockStorage.class.getDeclaredField("data");
fieldSection.setAccessible(true);
fieldSection.set(section, palette);
}
@Override
public void sendChunk(int x, int z, int bitMask) {
if (!isChunkLoaded(x, z)) {
return;
Chunk chunk = getCachedChunk(getWorld(), x, z);
if (chunk != null) {
sendChunk(chunk, bitMask);
}
sendChunk(getChunk(getImpWorld(), x, z), bitMask);
}
@Override
public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc;
if (!isChunkLoaded(fc.getX(), fc.getZ())) {
return;
Chunk chunk = getCachedChunk(getWorld(), fc.getX(), fc.getZ());
if (chunk != null) {
sendChunk(chunk, fc.getBitMask());
}
Chunk chunk = fs.getChunk();
sendChunk(chunk, fs.getBitMask());
}
public void sendChunk(Chunk nmsChunk, int mask) {

View File

@ -1,3 +1,3 @@
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);
}
// Set biomes
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;
if (this.biomes != null) {
byte[] currentBiomes = nmsChunk.getBiomeArray();
for (int i = 0 ; i < this.biomes.length; i++) {
if (this.biomes[i] != 0) {
currentBiomes[i] = this.biomes[i];
}
}
}
@ -401,22 +393,6 @@ public class SpongeChunk_1_11 extends CharFaweChunk<Chunk, SpongeQueue_1_11> {
} catch (Throwable 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;
}
}

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
public void setHeightMap(FaweChunk chunk, byte[] heightMap) {
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) {
IChunkProvider provider = world.getChunkProvider();
if (!(provider instanceof ChunkProviderServer)) {
@ -312,25 +337,6 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
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
public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) {
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 {
return (int) fieldNonEmptyBlockCount.get(section);
}
@ -444,11 +445,18 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
@Override
public void sendChunk(int x, int z, int bitMask) {
if (!isChunkLoaded(x, z)) {
return;
Chunk chunk = getCachedChunk(getWorld(), x, z);
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) {
@ -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) {
ClassInheritanceMultiMap<Entity>[] entities = nmsChunk.getEntityLists();
for (int i = 0; i < entities.length; i++) {