I forgot about sponge
This commit is contained in:
parent
8a40320a64
commit
dc3ab46803
@ -77,11 +77,13 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
|
|||||||
protected static Field fieldBiomes2;
|
protected static Field fieldBiomes2;
|
||||||
protected static Field fieldGenLayer1;
|
protected static Field fieldGenLayer1;
|
||||||
protected static Field fieldGenLayer2;
|
protected static Field fieldGenLayer2;
|
||||||
|
protected static ExtendedBlockStorage emptySection;
|
||||||
|
|
||||||
private static MutableGenLayer genLayer;
|
private static MutableGenLayer genLayer;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
|
emptySection = new ExtendedBlockStorage(0, false);
|
||||||
Class<?> converter = Class.forName("com.sk89q.worldedit.sponge.nms.NBTConverter");
|
Class<?> converter = Class.forName("com.sk89q.worldedit.sponge.nms.NBTConverter");
|
||||||
methodFromNative = converter.getDeclaredMethod("toNative", Tag.class);
|
methodFromNative = converter.getDeclaredMethod("toNative", Tag.class);
|
||||||
methodToNative = converter.getDeclaredMethod("fromNative", NBTBase.class);
|
methodToNative = converter.getDeclaredMethod("fromNative", NBTBase.class);
|
||||||
@ -441,10 +443,15 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshChunk(FaweChunk fc) {
|
public void sendChunk(int x, int z, int bitMask) {
|
||||||
SpongeChunk_1_11 fs = (SpongeChunk_1_11) fc;
|
if (!isChunkLoaded(x, z)) {
|
||||||
ensureChunkLoaded(fc.getX(), fc.getZ());
|
return;
|
||||||
Chunk nmsChunk = fs.getChunk();
|
}
|
||||||
|
Chunk chunk = getChunk(getImpWorld(), x, z);
|
||||||
|
sendChunk(chunk, bitMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendChunk(Chunk nmsChunk, int mask) {
|
||||||
if (!nmsChunk.isLoaded()) {
|
if (!nmsChunk.isLoaded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -463,7 +470,14 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
|
|||||||
players.add(input);
|
players.add(input);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
int mask = fc.getBitMask();
|
boolean empty = false;
|
||||||
|
ExtendedBlockStorage[] sections = nmsChunk.getBlockStorageArray();
|
||||||
|
for (int i = 0; i < sections.length; i++) {
|
||||||
|
if (sections[i] == null) {
|
||||||
|
sections[i] = emptySection;
|
||||||
|
empty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||||
SPacketChunkData packet = new SPacketChunkData(nmsChunk, 65280);
|
SPacketChunkData packet = new SPacketChunkData(nmsChunk, 65280);
|
||||||
for (EntityPlayerMP player : players) {
|
for (EntityPlayerMP player : players) {
|
||||||
@ -475,11 +489,26 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue<World, net.minecraft.wo
|
|||||||
for (EntityPlayerMP player : players) {
|
for (EntityPlayerMP player : players) {
|
||||||
player.connection.sendPacket(packet);
|
player.connection.sendPacket(packet);
|
||||||
}
|
}
|
||||||
|
if (empty) {
|
||||||
|
for (int i = 0; i < sections.length; i++) {
|
||||||
|
if (sections[i] == emptySection) {
|
||||||
|
sections[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
MainUtil.handleError(e);
|
MainUtil.handleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user