use of com.fastasyncworldedit.core.internal.io.FaweInputStream in project FastAsyncWorldEdit by IntellectualSites.
the class MemoryOptimizedHistory method getBlockIS.
@Override
public FaweInputStream getBlockIS() throws IOException {
if (ids == null) {
return null;
}
FaweInputStream result = MainUtil.getCompressedIS(new FastByteArraysInputStream(ids));
readHeader(result);
return result;
}
use of com.fastasyncworldedit.core.internal.io.FaweInputStream in project FastAsyncWorldEdit by IntellectualSites.
the class FaweStreamChangeSet method getBiomeIterator.
public Iterator<MutableBiomeChange> getBiomeIterator(final boolean dir) throws IOException {
final FaweInputStream is = getBiomeIS();
if (is == null) {
return Collections.emptyIterator();
}
final MutableBiomeChange change = new MutableBiomeChange();
return new Iterator<MutableBiomeChange>() {
private MutableBiomeChange last = new MutableBiomeChange();
public MutableBiomeChange read() {
try {
int int1 = is.read();
if (int1 != -1) {
int x = ((int1 << 24) + (is.read() << 16) + (is.read() << 8) + is.read()) << 2;
int z = ((is.read() << 24) + (is.read() << 16) + (is.read() << 8) + is.read()) << 2;
int y = (is.read() - 128) << 2;
int from = is.readVarInt();
int to = is.readVarInt();
change.setBiome(x, y, z, from, to);
return change;
}
} catch (EOFException ignored) {
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
}
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
public boolean hasNext() {
return last != null || ((last = read()) != null);
}
@Override
public MutableBiomeChange next() {
MutableBiomeChange tmp = last;
if (tmp == null) {
tmp = read();
}
last = null;
return tmp;
}
@Override
public void remove() {
throw new IllegalArgumentException("CANNOT REMOVE");
}
};
}
use of com.fastasyncworldedit.core.internal.io.FaweInputStream in project FastAsyncWorldEdit by IntellectualSites.
the class FaweStreamChangeSet method summarize.
@Override
public SimpleChangeSetSummary summarize(Region region, boolean shallow) {
int ox = getOriginX();
int oz = getOriginZ();
SimpleChangeSetSummary summary = summarizeShallow();
if (region != null && !region.contains(ox, oz)) {
return summary;
}
try (FaweInputStream fis = getBlockIS()) {
if (!shallow) {
int amount = (Settings.settings().HISTORY.BUFFER_SIZE - HEADER_SIZE) / 9;
MutableFullBlockChange change = new MutableFullBlockChange(null, 0, false);
for (int i = 0; i < amount; i++) {
int x = posDel.readX(fis) + ox;
int y = posDel.readY(fis);
int z = posDel.readZ(fis) + ox;
idDel.readCombined(fis, change);
summary.add(x, z, change.to);
}
}
} catch (EOFException ignored) {
} catch (IOException e) {
e.printStackTrace();
}
return summary;
}
use of com.fastasyncworldedit.core.internal.io.FaweInputStream in project FastAsyncWorldEdit by IntellectualSites.
the class DiskStorageHistory method readHeader.
public IntPair readHeader() {
int ox = getOriginX();
int oz = getOriginZ();
if (ox == 0 && oz == 0 && bdFile.exists()) {
try (FileInputStream fis = new FileInputStream(bdFile)) {
final FaweInputStream gis = MainUtil.getCompressedIS(fis);
// skip mode
gis.skipFully(1);
// skip version
gis.skipFully(1);
// origin
ox = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + gis.read());
oz = ((gis.read() << 24) + (gis.read() << 16) + (gis.read() << 8) + gis.read());
setOrigin(ox, oz);
fis.close();
gis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return new IntPair(ox, oz);
}
use of com.fastasyncworldedit.core.internal.io.FaweInputStream in project FastAsyncWorldEdit by IntellectualSites.
the class DiskStorageHistory method getBlockIS.
@Override
public FaweInputStream getBlockIS() throws IOException {
if (!bdFile.exists()) {
return null;
}
FaweInputStream is = MainUtil.getCompressedIS(new FileInputStream(bdFile));
readHeader(is);
return is;
}
Aggregations