mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-07-01 09:05:08 +02:00
BREAKS OLD UNDO FILES + better compression
Reduce block position entropy by encoding coordinates relative to last position
This commit is contained in:
parent
0e26ce6e1e
commit
dcc0c15c03
|
@ -24,12 +24,15 @@ import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
|
|
||||||
public class ChunkListener implements Listener {
|
public class ChunkListener implements Listener {
|
||||||
|
|
||||||
|
int rateLimit = 0;
|
||||||
|
|
||||||
public ChunkListener() {
|
public ChunkListener() {
|
||||||
if (Settings.TICK_LIMITER.ENABLED) {
|
if (Settings.TICK_LIMITER.ENABLED) {
|
||||||
Bukkit.getPluginManager().registerEvents(ChunkListener.this, Fawe.<FaweBukkit>imp().getPlugin());
|
Bukkit.getPluginManager().registerEvents(ChunkListener.this, Fawe.<FaweBukkit>imp().getPlugin());
|
||||||
TaskManager.IMP.repeat(new Runnable() {
|
TaskManager.IMP.repeat(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
rateLimit--;
|
||||||
physicsFreeze = false;
|
physicsFreeze = false;
|
||||||
itemFreeze = false;
|
itemFreeze = false;
|
||||||
counter.clear();
|
counter.clear();
|
||||||
|
@ -99,8 +102,11 @@ public class ChunkListener implements Listener {
|
||||||
lastPhysY = y;
|
lastPhysY = y;
|
||||||
if (++count.x == Settings.TICK_LIMITER.PHYSICS) {
|
if (++count.x == Settings.TICK_LIMITER.PHYSICS) {
|
||||||
badChunks.add(MathMan.pairInt(cx, cz));
|
badChunks.add(MathMan.pairInt(cx, cz));
|
||||||
|
if (rateLimit <= 0) {
|
||||||
|
rateLimit = 120;
|
||||||
Fawe.debug("[Tick Limiter] Detected and cancelled physics lag source at " + block.getLocation());
|
Fawe.debug("[Tick Limiter] Detected and cancelled physics lag source at " + block.getLocation());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastPhysY = y;
|
lastPhysY = y;
|
||||||
|
@ -148,8 +154,11 @@ public class ChunkListener implements Listener {
|
||||||
count.x = Settings.TICK_LIMITER.PHYSICS;
|
count.x = Settings.TICK_LIMITER.PHYSICS;
|
||||||
cleanup(loc.getChunk());
|
cleanup(loc.getChunk());
|
||||||
badChunks.add(MathMan.pairInt(cx, cz));
|
badChunks.add(MathMan.pairInt(cx, cz));
|
||||||
|
if (rateLimit <= 0) {
|
||||||
|
rateLimit = 120;
|
||||||
Fawe.debug("[Tick Limiter] Detected and cancelled item lag source at " + loc);
|
Fawe.debug("[Tick Limiter] Detected and cancelled item lag source at " + loc);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,13 +124,17 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||||
}
|
}
|
||||||
if (mode == 1 || mode == 4) { // small
|
if (mode == 1 || mode == 4) { // small
|
||||||
posDel = new FaweStreamPositionDelegate() {
|
posDel = new FaweStreamPositionDelegate() {
|
||||||
|
int lx,ly,lz;
|
||||||
@Override
|
@Override
|
||||||
public void write(OutputStream out, int x, int y, int z) throws IOException {
|
public void write(OutputStream out, int x, int y, int z) throws IOException {
|
||||||
byte b1 = (byte) y;
|
int rx = -lx + (lx = x);
|
||||||
byte b2 = (byte) (x);
|
int ry = -ly + (ly = y);
|
||||||
byte b3 = (byte) (z);
|
int rz = -lz + (lz = z);
|
||||||
int x16 = (x >> 8) & 0xF;
|
byte b1 = (byte) (ry);
|
||||||
int z16 = (z >> 8) & 0xF;
|
byte b2 = (byte) (rx);
|
||||||
|
byte b3 = (byte) (rz);
|
||||||
|
int x16 = (rx >> 8) & 0xF;
|
||||||
|
int z16 = (rz >> 8) & 0xF;
|
||||||
byte b4 = MathMan.pair16(x16, z16);
|
byte b4 = MathMan.pair16(x16, z16);
|
||||||
out.write(b1);
|
out.write(b1);
|
||||||
out.write(b2);
|
out.write(b2);
|
||||||
|
@ -145,31 +149,33 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||||
if (in.read(buffer) == -1) {
|
if (in.read(buffer) == -1) {
|
||||||
throw new EOFException();
|
throw new EOFException();
|
||||||
}
|
}
|
||||||
return (((buffer[1] & 0xFF) + ((MathMan.unpair16x(buffer[3])) << 8)) << 20) >> 20;
|
return lx = lx + ((((buffer[1] & 0xFF) + ((MathMan.unpair16x(buffer[3])) << 8)) << 20) >> 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int readY(InputStream in) {
|
public int readY(InputStream in) {
|
||||||
return buffer[0] & 0xFF;
|
return (ly = ly + buffer[0]) & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int readZ(InputStream in) throws IOException {
|
public int readZ(InputStream in) throws IOException {
|
||||||
return (((buffer[2] & 0xFF) + ((MathMan.unpair16y(buffer[3])) << 8)) << 20) >> 20;
|
return lz = lz + ((((buffer[2] & 0xFF) + ((MathMan.unpair16y(buffer[3])) << 8)) << 20) >> 20);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
posDel = new FaweStreamPositionDelegate() {
|
posDel = new FaweStreamPositionDelegate() {
|
||||||
|
|
||||||
byte[] buffer = new byte[5];
|
byte[] buffer = new byte[5];
|
||||||
|
int lx,ly,lz;
|
||||||
@Override
|
@Override
|
||||||
public void write(OutputStream stream, int x, int y, int z) throws IOException {
|
public void write(OutputStream stream, int x, int y, int z) throws IOException {
|
||||||
stream.write((x) & 0xff);
|
int rx = -lx + (lx = x);
|
||||||
stream.write(((x) >> 8) & 0xff);
|
int ry = -ly + (ly = y);
|
||||||
stream.write((z) & 0xff);
|
int rz = -lz + (lz = z);
|
||||||
stream.write(((z) >> 8) & 0xff);
|
stream.write((rx) & 0xff);
|
||||||
stream.write((byte) y);
|
stream.write(((rx) >> 8) & 0xff);
|
||||||
|
stream.write((rz) & 0xff);
|
||||||
|
stream.write(((rz) >> 8) & 0xff);
|
||||||
|
stream.write((byte) ry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -177,17 +183,17 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||||
if (is.read(buffer) == -1) {
|
if (is.read(buffer) == -1) {
|
||||||
throw new EOFException();
|
throw new EOFException();
|
||||||
}
|
}
|
||||||
return (buffer[0] & 0xFF) + (buffer[1] << 8);
|
return lx = (lx + (buffer[0] & 0xFF) + (buffer[1] << 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int readY(InputStream is) throws IOException {
|
public int readY(InputStream is) throws IOException {
|
||||||
return buffer[4] & 0xFF;
|
return (ly = (ly + (buffer[4]))) & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int readZ(InputStream is) throws IOException {
|
public int readZ(InputStream is) throws IOException {
|
||||||
return (buffer[2] & 0xFF) + (buffer[3] << 8);
|
return lz = (lz + (buffer[2] & 0xFF) + (buffer[3] << 8));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,6 @@ public class MainUtil {
|
||||||
return new FaweInputStream(is);
|
return new FaweInputStream(is);
|
||||||
}
|
}
|
||||||
int amountAbs = Math.abs(amount);
|
int amountAbs = Math.abs(amount);
|
||||||
LZ4Factory factory = LZ4Factory.fastestInstance();
|
|
||||||
if (amountAbs > 6) {
|
if (amountAbs > 6) {
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
is = new BufferedInputStream(new GZIPInputStream(is, buffer));
|
is = new BufferedInputStream(new GZIPInputStream(is, buffer));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user