mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-30 22:53:31 +01:00
Fix modification and packet sending for 1.7.10
This commit is contained in:
parent
421b992b67
commit
26fc8b781c
@ -32,6 +32,11 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk> {
|
|||||||
return datas[i];
|
return datas[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlock(int x, int y, int z, int id) {
|
||||||
|
this.setBlock(x, y, z, id, 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlock(int x, int y, int z, int id, int data) {
|
public void setBlock(int x, int y, int z, int id, int data) {
|
||||||
int i = FaweCache.CACHE_I[y][z][x];
|
int i = FaweCache.CACHE_I[y][z][x];
|
||||||
@ -47,8 +52,7 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk> {
|
|||||||
this.count[i]++;
|
this.count[i]++;
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0:
|
case 0:
|
||||||
this.air[i]++;
|
vs[j] = 0;
|
||||||
vs[j] = -1;
|
|
||||||
vs2[j] = (char) 1;
|
vs2[j] = (char) 1;
|
||||||
return;
|
return;
|
||||||
case 11:
|
case 11:
|
||||||
@ -62,81 +66,19 @@ public class BukkitChunk_1_7 extends CharFaweChunk<Chunk> {
|
|||||||
case 138:
|
case 138:
|
||||||
case 169:
|
case 169:
|
||||||
case 213:
|
case 213:
|
||||||
this.relight[i]++;
|
|
||||||
case 2:
|
|
||||||
case 4:
|
|
||||||
case 13:
|
|
||||||
case 14:
|
|
||||||
case 15:
|
|
||||||
case 20:
|
|
||||||
case 21:
|
|
||||||
case 22:
|
|
||||||
case 30:
|
|
||||||
case 32:
|
|
||||||
case 37:
|
|
||||||
case 41:
|
|
||||||
case 42:
|
|
||||||
case 45:
|
|
||||||
case 46:
|
|
||||||
case 47:
|
|
||||||
case 48:
|
|
||||||
case 49:
|
|
||||||
case 55:
|
|
||||||
case 56:
|
|
||||||
case 57:
|
|
||||||
case 58:
|
|
||||||
case 60:
|
|
||||||
case 7:
|
|
||||||
case 73:
|
|
||||||
case 79:
|
|
||||||
case 80:
|
|
||||||
case 81:
|
|
||||||
case 82:
|
|
||||||
case 83:
|
|
||||||
case 85:
|
|
||||||
case 87:
|
|
||||||
case 88:
|
|
||||||
case 101:
|
|
||||||
case 102:
|
|
||||||
case 103:
|
|
||||||
case 110:
|
|
||||||
case 112:
|
|
||||||
case 113:
|
|
||||||
case 121:
|
|
||||||
case 129:
|
|
||||||
case 133:
|
|
||||||
case 165:
|
|
||||||
case 166:
|
|
||||||
case 170:
|
|
||||||
case 172:
|
|
||||||
case 173:
|
|
||||||
case 174:
|
|
||||||
case 188:
|
|
||||||
case 189:
|
|
||||||
case 190:
|
|
||||||
case 191:
|
|
||||||
case 192:
|
|
||||||
vs[j] = (byte) (id);
|
|
||||||
vs2[j] = (char) (id << 4);
|
|
||||||
return;
|
|
||||||
case 130:
|
case 130:
|
||||||
case 76:
|
case 76:
|
||||||
case 62:
|
case 62:
|
||||||
case 50:
|
case 50:
|
||||||
case 10:
|
case 10:
|
||||||
this.relight[i]++;
|
this.relight[i]++;
|
||||||
case 54:
|
|
||||||
case 146:
|
|
||||||
case 61:
|
|
||||||
case 65:
|
|
||||||
case 68: // removed
|
|
||||||
default:
|
default:
|
||||||
vs2[j] = (char) ((id << 4) + data);
|
vs2[j] = (char) ((id << 4) + data);
|
||||||
vs[j] = (byte) id;
|
vs[j] = (byte) id;
|
||||||
if (data != 0) {
|
if (data != 0) {
|
||||||
NibbleArray dataArray = datas[i];
|
NibbleArray dataArray = datas[i];
|
||||||
if (dataArray == null) {
|
if (dataArray == null) {
|
||||||
datas[i] = dataArray = new NibbleArray(4096, 4);
|
datas[i] = dataArray = new NibbleArray(new byte[2048], 4);
|
||||||
}
|
}
|
||||||
dataArray.a(x, y & 15, z, data);
|
dataArray.a(x, y & 15, z, data);
|
||||||
}
|
}
|
||||||
|
@ -65,9 +65,22 @@ import org.bukkit.generator.ChunkGenerator;
|
|||||||
|
|
||||||
public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSection> {
|
public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSection> {
|
||||||
|
|
||||||
|
private static Field fieldData;
|
||||||
|
private static Field fieldIds;
|
||||||
|
|
||||||
public BukkitQueue17(final String world) {
|
public BukkitQueue17(final String world) {
|
||||||
super(world);
|
super(world);
|
||||||
checkVersion("v1_7_R4");
|
checkVersion("v1_7_R4");
|
||||||
|
if (fieldData == null) {
|
||||||
|
try {
|
||||||
|
fieldData = ChunkSection.class.getDeclaredField("blockData");
|
||||||
|
fieldData.setAccessible(true);
|
||||||
|
fieldIds = ChunkSection.class.getDeclaredField("blockIds");
|
||||||
|
fieldIds.setAccessible(true);
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -358,24 +371,31 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
|||||||
if ((section == null) || (fs.getCount(j) >= 4096)) {
|
if ((section == null) || (fs.getCount(j) >= 4096)) {
|
||||||
sections[j] = section = new ChunkSection(j << 4, flag);
|
sections[j] = section = new ChunkSection(j << 4, flag);
|
||||||
section.setIdArray(newIdArray);
|
section.setIdArray(newIdArray);
|
||||||
|
if (newDataArray != null) {
|
||||||
section.setDataArray(newDataArray);
|
section.setDataArray(newDataArray);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
byte[] currentIdArray = section.getIdArray();
|
byte[] currentIdArray = (byte[]) fieldIds.get(section);
|
||||||
NibbleArray currentDataArray = section.getDataArray();
|
NibbleArray currentDataArray = (NibbleArray) fieldData.get(section);
|
||||||
boolean data = currentDataArray != null;
|
boolean data = currentDataArray != null;
|
||||||
if (!data) {
|
if (!data && newDataArray != null) {
|
||||||
section.setDataArray(newDataArray);
|
section.setDataArray(newDataArray);
|
||||||
}
|
}
|
||||||
|
if (currentIdArray == null) {
|
||||||
|
section.setIdArray(newIdArray);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
boolean fill = true;
|
boolean fill = true;
|
||||||
int solid = 0;
|
int solid = 0;
|
||||||
|
char[] charArray = fs.getIdArray(j);
|
||||||
for (int k = 0; k < newIdArray.length; k++) {
|
for (int k = 0; k < newIdArray.length; k++) {
|
||||||
byte n = newIdArray[k];
|
char combined = charArray[k];
|
||||||
switch (n) {
|
switch (combined) {
|
||||||
case 0:
|
case 0:
|
||||||
fill = false;
|
fill = false;
|
||||||
continue;
|
continue;
|
||||||
case -1:
|
case 1:
|
||||||
fill = false;
|
fill = false;
|
||||||
if (currentIdArray[k] != 0) {
|
if (currentIdArray[k] != 0) {
|
||||||
solid++;
|
solid++;
|
||||||
@ -384,17 +404,15 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
|||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
solid++;
|
solid++;
|
||||||
currentIdArray[k] = n;
|
currentIdArray[k] = newIdArray[k];
|
||||||
if (data) {
|
if (data) {
|
||||||
|
int dataByte = FaweCache.getData(combined);
|
||||||
int x = FaweCache.CACHE_X[0][k];
|
int x = FaweCache.CACHE_X[0][k];
|
||||||
int y = FaweCache.CACHE_Y[0][k];
|
int y = FaweCache.CACHE_Y[0][k];
|
||||||
int z = FaweCache.CACHE_Z[0][k];
|
int z = FaweCache.CACHE_Z[0][k];
|
||||||
int newData = newDataArray == null ? 0 : newDataArray.a(x, y, z);
|
int newData = newDataArray.a(x, y, z);
|
||||||
int currentData = currentDataArray == null ? 0 : currentDataArray.a(x, y, z);
|
|
||||||
if (newData != currentData) {
|
|
||||||
currentDataArray.a(x, y, z, newData);
|
currentDataArray.a(x, y, z, newData);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -489,13 +507,13 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
|
|||||||
// Send chunks
|
// Send chunks
|
||||||
int mask = fc.getBitMask();
|
int mask = fc.getBitMask();
|
||||||
if (mask == 65535 && hasEntities(nmsChunk)) {
|
if (mask == 65535 && hasEntities(nmsChunk)) {
|
||||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, false, 65280, 25);
|
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, false, 65280, 5);
|
||||||
for (EntityPlayer player : players) {
|
for (EntityPlayer player : players) {
|
||||||
player.playerConnection.sendPacket(packet);
|
player.playerConnection.sendPacket(packet);
|
||||||
}
|
}
|
||||||
mask = 255;
|
mask = 255;
|
||||||
}
|
}
|
||||||
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, false, mask, 25);
|
PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, false, mask, 5);
|
||||||
for (EntityPlayer player : players) {
|
for (EntityPlayer player : players) {
|
||||||
player.playerConnection.sendPacket(packet);
|
player.playerConnection.sendPacket(packet);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user