Fixing stuff
-Got rid of some annoying logging -Format
This commit is contained in:
parent
9c26418354
commit
b7dcbb0f30
@ -39,8 +39,7 @@ public class ProgressiaLauncher {
|
||||
GUI.addTopLayer(new LayerTitle("Title"));
|
||||
}
|
||||
|
||||
public static void play()
|
||||
{
|
||||
public static void play() {
|
||||
proxy.setupServer();
|
||||
}
|
||||
|
||||
|
@ -66,8 +66,7 @@ public class ClientProxy implements Proxy {
|
||||
// setupServer();
|
||||
}
|
||||
|
||||
public void setupServer()
|
||||
{
|
||||
public void setupServer() {
|
||||
ServerState.startServer();
|
||||
ClientState.connectToLocalServer();
|
||||
}
|
||||
|
@ -65,18 +65,20 @@ public class ClientState {
|
||||
setInstance(client);
|
||||
|
||||
MutableString t = new MutableStringLocalized("LayerText.Load");
|
||||
layer = new LayerTestText("Text",() -> {t.update(); return t.get();});
|
||||
layer = new LayerTestText("Text", () -> {
|
||||
t.update();
|
||||
return t.get();
|
||||
});
|
||||
|
||||
ServerState.getInstance().getChunkManager().register((ChunksLoadStartListener) () -> {
|
||||
if (firstLoad)
|
||||
{
|
||||
if (firstLoad) {
|
||||
|
||||
GUI.addTopLayer(layer);
|
||||
}});
|
||||
}
|
||||
});
|
||||
|
||||
ServerState.getInstance().getChunkManager().register((ChunksLoadFinishListener) () -> {
|
||||
if (firstLoad)
|
||||
{
|
||||
if (firstLoad) {
|
||||
GUI.removeLayer(layer);
|
||||
|
||||
LayerWorld layerWorld = new LayerWorld(client);
|
||||
@ -92,10 +94,8 @@ public class ClientState {
|
||||
|
||||
}
|
||||
|
||||
public static void disconnectFromLocalServer()
|
||||
{
|
||||
for (Layer layer : GUI.getLayers())
|
||||
{
|
||||
public static void disconnectFromLocalServer() {
|
||||
for (Layer layer : GUI.getLayers()) {
|
||||
GUI.removeLayer(layer);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,6 @@ import ru.windcorp.progressia.client.audio.backend.Speaker;
|
||||
public class Music
|
||||
extends Sound {
|
||||
|
||||
|
||||
|
||||
public Music(SoundType soundType, int timeLength, float pitch, float gain) {
|
||||
super(soundType, timeLength, new Vec3(), new Vec3(), pitch, gain);
|
||||
}
|
||||
|
@ -166,7 +166,8 @@ public class GraphicsBackend {
|
||||
0,
|
||||
vidmode.width(),
|
||||
vidmode.height(),
|
||||
0);
|
||||
0
|
||||
);
|
||||
isFullscreen = true;
|
||||
}
|
||||
|
||||
@ -179,7 +180,8 @@ public class GraphicsBackend {
|
||||
(vidmode.height() - getFrameHeight()) / 2,
|
||||
getFrameWidth(),
|
||||
getFrameHeight(),
|
||||
0);
|
||||
0
|
||||
);
|
||||
isFullscreen = false;
|
||||
}
|
||||
|
||||
|
@ -104,8 +104,7 @@ public abstract class BasicButton extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
public BasicButton(String name, String label, Font labelFont)
|
||||
{
|
||||
public BasicButton(String name, String label, Font labelFont) {
|
||||
this(name, new Label(name + ".Label", labelFont, label));
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,8 @@ public class RadioButton extends BasicButton {
|
||||
addChild(group);
|
||||
|
||||
addListener(KeyEvent.class, e -> {
|
||||
if (e.isRelease()) return false;
|
||||
if (e.isRelease())
|
||||
return false;
|
||||
|
||||
if (e.getKey() == GLFW.GLFW_KEY_LEFT || e.getKey() == GLFW.GLFW_KEY_UP) {
|
||||
if (this.group != null) {
|
||||
@ -149,7 +150,8 @@ public class RadioButton extends BasicButton {
|
||||
group.selectNext();
|
||||
removeAction(group.listener);
|
||||
group.buttons.remove(this);
|
||||
group.getSelected(); // Clear reference if this was the only button in the group
|
||||
group.getSelected(); // Clear reference if this was the only button
|
||||
// in the group
|
||||
}
|
||||
|
||||
this.group = group;
|
||||
@ -178,7 +180,8 @@ public class RadioButton extends BasicButton {
|
||||
this.checked = checked;
|
||||
|
||||
if (group != null) {
|
||||
group.listener.accept(this); // Failsafe for manual invocations of setChecked()
|
||||
group.listener.accept(this); // Failsafe for manual invocations of
|
||||
// setChecked()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,8 @@ import java.util.function.Consumer;
|
||||
|
||||
public class RadioButtonGroup {
|
||||
|
||||
private final Collection<Consumer<RadioButtonGroup>> actions = Collections.synchronizedCollection(new ArrayList<>());
|
||||
private final Collection<Consumer<RadioButtonGroup>> actions = Collections
|
||||
.synchronizedCollection(new ArrayList<>());
|
||||
final List<RadioButton> buttons = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
private RadioButton selected = null;
|
||||
|
@ -51,7 +51,8 @@ public class ChunkRenderModel implements Renderable {
|
||||
|
||||
@Override
|
||||
public void render(ShapeRenderHelper renderer) {
|
||||
if (model == null) return;
|
||||
if (model == null)
|
||||
return;
|
||||
|
||||
renderer.pushTransform().translate(
|
||||
chunk.getX() * ChunkData.BLOCKS_PER_CHUNK,
|
||||
|
@ -75,7 +75,9 @@ public abstract class BlockRenderTexturedCube
|
||||
|
||||
@Override
|
||||
public final void getFaces(
|
||||
ChunkData chunk, Vec3i blockInChunk, BlockFace blockFace,
|
||||
ChunkData chunk,
|
||||
Vec3i blockInChunk,
|
||||
BlockFace blockFace,
|
||||
boolean inner,
|
||||
Consumer<Face> output,
|
||||
Vec3 offset
|
||||
@ -84,7 +86,9 @@ public abstract class BlockRenderTexturedCube
|
||||
}
|
||||
|
||||
private Face createFace(
|
||||
ChunkData chunk, Vec3i blockInChunk, BlockFace blockFace,
|
||||
ChunkData chunk,
|
||||
Vec3i blockInChunk,
|
||||
BlockFace blockFace,
|
||||
boolean inner,
|
||||
Vec3 offset
|
||||
) {
|
||||
@ -110,7 +114,13 @@ public abstract class BlockRenderTexturedCube
|
||||
|
||||
if (!opaque) {
|
||||
for (int i = 0; i < BLOCK_FACE_COUNT; ++i) {
|
||||
faces[i + BLOCK_FACE_COUNT] = createFace(chunk, blockInChunk, BlockFace.getFaces().get(i), true, Vectors.ZERO_3);
|
||||
faces[i + BLOCK_FACE_COUNT] = createFace(
|
||||
chunk,
|
||||
blockInChunk,
|
||||
BlockFace.getFaces().get(i),
|
||||
true,
|
||||
Vectors.ZERO_3
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,9 @@ public abstract class TileRenderSurface extends TileRender implements TileOptimi
|
||||
|
||||
@Override
|
||||
public final void getFaces(
|
||||
ChunkData chunk, Vec3i blockInChunk, BlockFace blockFace,
|
||||
ChunkData chunk,
|
||||
Vec3i blockInChunk,
|
||||
BlockFace blockFace,
|
||||
boolean inner,
|
||||
Consumer<Face> output,
|
||||
Vec3 offset
|
||||
@ -68,7 +70,9 @@ public abstract class TileRenderSurface extends TileRender implements TileOptimi
|
||||
}
|
||||
|
||||
private Face createFace(
|
||||
ChunkData chunk, Vec3i blockInChunk, BlockFace blockFace,
|
||||
ChunkData chunk,
|
||||
Vec3i blockInChunk,
|
||||
BlockFace blockFace,
|
||||
boolean inner,
|
||||
Vec3 offset
|
||||
) {
|
||||
|
@ -95,9 +95,12 @@ public interface GenericChunk<Self extends GenericChunk<Self, B, T, TS>, B exten
|
||||
default boolean isSurfaceBiC(Vec3i blockInChunk) {
|
||||
int hits = 0;
|
||||
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.x)) hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.y)) hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.z)) hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.x))
|
||||
hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.y))
|
||||
hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.z))
|
||||
hits++;
|
||||
|
||||
return hits >= 1;
|
||||
}
|
||||
@ -117,9 +120,12 @@ public interface GenericChunk<Self extends GenericChunk<Self, B, T, TS>, B exten
|
||||
default boolean isEdgeBiC(Vec3i blockInChunk) {
|
||||
int hits = 0;
|
||||
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.x)) hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.y)) hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.z)) hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.x))
|
||||
hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.y))
|
||||
hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.z))
|
||||
hits++;
|
||||
|
||||
return hits >= 2;
|
||||
}
|
||||
@ -139,9 +145,12 @@ public interface GenericChunk<Self extends GenericChunk<Self, B, T, TS>, B exten
|
||||
default boolean isVertexBiC(Vec3i blockInChunk) {
|
||||
int hits = 0;
|
||||
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.x)) hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.y)) hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.z)) hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.x))
|
||||
hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.y))
|
||||
hits++;
|
||||
if (Coordinates.isOnChunkBorder(blockInChunk.z))
|
||||
hits++;
|
||||
|
||||
return hits == 3;
|
||||
}
|
||||
|
@ -81,24 +81,20 @@ public class ChunkManager {
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ChunksLoadListener
|
||||
{
|
||||
public interface ChunksLoadListener {
|
||||
void handle(boolean starting);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface ChunksLoadEventListener
|
||||
{
|
||||
private interface ChunksLoadEventListener {
|
||||
void handle();
|
||||
}
|
||||
|
||||
public interface ChunksLoadStartListener extends ChunksLoadEventListener
|
||||
{
|
||||
public interface ChunksLoadStartListener extends ChunksLoadEventListener {
|
||||
|
||||
}
|
||||
|
||||
public interface ChunksLoadFinishListener extends ChunksLoadEventListener
|
||||
{
|
||||
public interface ChunksLoadFinishListener extends ChunksLoadEventListener {
|
||||
|
||||
}
|
||||
|
||||
@ -111,7 +107,8 @@ public class ChunkManager {
|
||||
|
||||
private Collection<ChunksLoadListener> listeners = Collections.synchronizedCollection(new ArrayList<>());
|
||||
private Collection<ChunksLoadStartListener> startListeners = Collections.synchronizedCollection(new ArrayList<>());
|
||||
private Collection<ChunksLoadFinishListener> finishListeners = Collections.synchronizedCollection( new ArrayList<>());
|
||||
private Collection<ChunksLoadFinishListener> finishListeners = Collections
|
||||
.synchronizedCollection(new ArrayList<>());
|
||||
|
||||
// TODO replace with a normal Map managed by some sort of PlayerListener,
|
||||
// weak maps are weak
|
||||
@ -132,23 +129,19 @@ public class ChunkManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void register(ChunksLoadListener cll)
|
||||
{
|
||||
public void register(ChunksLoadListener cll) {
|
||||
listeners.add(cll);
|
||||
}
|
||||
|
||||
public void register(ChunksLoadStartListener clsl)
|
||||
{
|
||||
public void register(ChunksLoadStartListener clsl) {
|
||||
startListeners.add(clsl);
|
||||
}
|
||||
|
||||
public void register(ChunksLoadFinishListener clfl)
|
||||
{
|
||||
public void register(ChunksLoadFinishListener clfl) {
|
||||
finishListeners.add(clfl);
|
||||
}
|
||||
|
||||
public void unregisterAll()
|
||||
{
|
||||
public void unregisterAll() {
|
||||
listeners.clear();
|
||||
}
|
||||
|
||||
@ -178,8 +171,7 @@ public class ChunkManager {
|
||||
|
||||
private void processQueues() {
|
||||
|
||||
if (toUnload.size()!=0 || toLoad.size()!=0)
|
||||
{
|
||||
if (toUnload.size() != 0 || toLoad.size() != 0) {
|
||||
LogManager.getLogger().info(String.valueOf(toUnload.size()) + " " + String.valueOf(toLoad.size()));
|
||||
}
|
||||
listeners.forEach(l -> l.handle(false));
|
||||
|
@ -73,8 +73,7 @@ public class PlayerManager {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void removePlayer(Player player)
|
||||
{
|
||||
public void removePlayer(Player player) {
|
||||
players.remove(player);
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,7 @@ public class ServerThread implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (isShuttingDown)
|
||||
{
|
||||
if (isShuttingDown) {
|
||||
getTicker().stop();
|
||||
executor.shutdown();
|
||||
return;
|
||||
|
@ -116,7 +116,6 @@ class Ticker {
|
||||
getCoordinator().crash(e, this.name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private synchronized boolean sleep() {
|
||||
|
@ -90,15 +90,17 @@ public class LayerButtonTest extends MenuLayer {
|
||||
ClientState.disconnectFromLocalServer();
|
||||
|
||||
MutableString t = new MutableStringLocalized("LayerText.Save");
|
||||
LayerTestText layer = new LayerTestText("Text",() -> {t.update(); return t.get();});
|
||||
LayerTestText layer = new LayerTestText("Text", () -> {
|
||||
t.update();
|
||||
return t.get();
|
||||
});
|
||||
|
||||
GUI.addTopLayer(layer);
|
||||
|
||||
ChunkManager cm = ServerState.getInstance().getChunkManager();
|
||||
alive = true;
|
||||
cm.register((ChunksLoadFinishListener) () -> {
|
||||
if (alive)
|
||||
{
|
||||
if (alive) {
|
||||
GUI.removeLayer(layer);
|
||||
GUI.addTopLayer(new LayerTitle("Title"));
|
||||
// cm.unregisterAll();
|
||||
@ -117,7 +119,6 @@ public class LayerButtonTest extends MenuLayer {
|
||||
ClientState.setInstance(null);
|
||||
// ServerState.getInstance().getChunkManager().unloadAll();
|
||||
|
||||
|
||||
}));
|
||||
|
||||
getContent().takeFocus();
|
||||
|
@ -12,13 +12,13 @@ public class LayerTestText extends GUILayer {
|
||||
public LayerTestText(String name, Supplier<String> value) {
|
||||
super(name, new LayoutVertical(20, 10));
|
||||
|
||||
//MutableString title = new MutableStringLocalized("Layer"+name+".Title");
|
||||
// MutableString title = new
|
||||
// MutableStringLocalized("Layer"+name+".Title");
|
||||
Font titleFont = new Font().deriveBold().withColor(Colors.BLACK).withAlign(0.5f);
|
||||
getRoot().addChild(new Label(name + ".Text", titleFont, value));
|
||||
}
|
||||
|
||||
public LayerTestText(String name, String value)
|
||||
{
|
||||
public LayerTestText(String name, String value) {
|
||||
this(name, () -> value);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,8 @@ public class LayerTitle extends GUILayer {
|
||||
getRoot().addChild(new Button(name + ".Play", new Label(name + ".Play", buttonFont, playText)).addAction(b -> {
|
||||
GUI.removeLayer(this);
|
||||
|
||||
ProgressiaLauncher.play();}));
|
||||
ProgressiaLauncher.play();
|
||||
}));
|
||||
|
||||
MutableString quitText = new MutableStringLocalized("Layer" + name + ".Quit");
|
||||
getRoot().addChild(new Button(name + "Quit", new Label(name + ".Quit", buttonFont, quitText)).addAction(b -> {
|
||||
|
@ -141,7 +141,8 @@ public class TestMusicPlayer implements Runnable {
|
||||
}
|
||||
|
||||
public static void startNextNow() {
|
||||
if (instance == null) return;
|
||||
if (instance == null)
|
||||
return;
|
||||
|
||||
synchronized (instance) {
|
||||
instance.nextStart = System.currentTimeMillis();
|
||||
|
@ -91,8 +91,7 @@ public class TestPlayerControls {
|
||||
private LayerTestGUI debugLayer = null;
|
||||
private Runnable updateCallback = null;
|
||||
|
||||
public static void resetInstance()
|
||||
{
|
||||
public static void resetInstance() {
|
||||
INSTANCE = new TestPlayerControls();
|
||||
}
|
||||
|
||||
|
@ -78,24 +78,28 @@ public class TestWorldDiskIO {
|
||||
return loc << 1;
|
||||
}
|
||||
|
||||
/*private static int intFromNat(int loc) // Possibly unused
|
||||
{
|
||||
if ((loc & 1) == 1)
|
||||
return -loc >> 1;
|
||||
return loc >> 1;
|
||||
}*/
|
||||
/*
|
||||
* private static int intFromNat(int loc) // Possibly unused
|
||||
* {
|
||||
* if ((loc & 1) == 1)
|
||||
* return -loc >> 1;
|
||||
* return loc >> 1;
|
||||
* }
|
||||
*/
|
||||
|
||||
private static Vec3i getRegion(Vec3i chunkLoc) {
|
||||
return new Vec3i(natFromInt(chunkLoc.x/regionSize.x), natFromInt(chunkLoc.y/regionSize.y), natFromInt(chunkLoc.z/regionSize.z));
|
||||
return new Vec3i(
|
||||
natFromInt(chunkLoc.x / regionSize.x),
|
||||
natFromInt(chunkLoc.y / regionSize.y),
|
||||
natFromInt(chunkLoc.z / regionSize.z)
|
||||
);
|
||||
}
|
||||
|
||||
private static int mod(int a, int m)
|
||||
{
|
||||
private static int mod(int a, int m) {
|
||||
return ((a % m) + m) % m;
|
||||
}
|
||||
|
||||
private static Vec3i getRegionLoc(Vec3i chunkLoc)
|
||||
{
|
||||
private static Vec3i getRegionLoc(Vec3i chunkLoc) {
|
||||
return new Vec3i(mod(chunkLoc.x, regionSize.x), mod(chunkLoc.y, regionSize.y), mod(chunkLoc.z, regionSize.z));
|
||||
}
|
||||
|
||||
@ -130,8 +134,7 @@ public class TestWorldDiskIO {
|
||||
}
|
||||
}
|
||||
|
||||
private static void expand(int sectors)
|
||||
{
|
||||
private static void expand(int sectors) {
|
||||
|
||||
}
|
||||
|
||||
@ -197,9 +200,7 @@ public class TestWorldDiskIO {
|
||||
ChunkIO.save(chunk, output, IOContext.SAVE);
|
||||
writeGenerationHint(chunk, output, server);
|
||||
}
|
||||
}
|
||||
else if (currentFormat == 65536)
|
||||
{
|
||||
} else if (currentFormat == 65536) {
|
||||
LOG.debug(
|
||||
"Saving {} {} {}",
|
||||
chunk.getPosition().x,
|
||||
@ -220,18 +221,19 @@ public class TestWorldDiskIO {
|
||||
)
|
||||
);
|
||||
|
||||
/*if (!dosave)
|
||||
{
|
||||
return;
|
||||
}
|
||||
dosave = false;*/
|
||||
/*
|
||||
* if (!dosave)
|
||||
* {
|
||||
* return;
|
||||
* }
|
||||
* dosave = false;
|
||||
*/
|
||||
|
||||
try (
|
||||
RandomAccessFile output = new RandomAccessFile(path.toFile(), "rw")
|
||||
) {
|
||||
// LOG.debug(output.read());
|
||||
if (output.read()<0)
|
||||
{
|
||||
if (output.read() < 0) {
|
||||
LOG.info("Making header");
|
||||
output.writeChars("\0".repeat((offsetBytes + 1) * chunksPerRegion));
|
||||
}
|
||||
@ -243,17 +245,18 @@ public class TestWorldDiskIO {
|
||||
int offset = output.readInt();
|
||||
int sectorLength = offset & 255;
|
||||
offset = offset >> 8;
|
||||
if (sectorLength == 0)
|
||||
{
|
||||
if (sectorLength == 0) {
|
||||
int outputLen = (int) output.length();
|
||||
offset = (int) (outputLen - fullOffset) / sectorSize + 1;
|
||||
output.seek(shortOffset);
|
||||
output.writeInt(offset << 8);
|
||||
output.seek(outputLen);
|
||||
/*while (output.length()<fullOffset+sectorSize*offset)
|
||||
{
|
||||
output.write((int) (output.length()%256));
|
||||
}*/
|
||||
/*
|
||||
* while (output.length()<fullOffset+sectorSize*offset)
|
||||
* {
|
||||
* output.write((int) (output.length()%256));
|
||||
* }
|
||||
*/
|
||||
output.setLength(fullOffset + offset * sectorSize);
|
||||
// output.write(200);
|
||||
}
|
||||
@ -261,7 +264,9 @@ public class TestWorldDiskIO {
|
||||
// int bytestoWrite = output.readInt();
|
||||
// output.mark(sectorSize*sectorLength);
|
||||
|
||||
//BufferedOutputStream counter = new BufferedOutputStream(Files.newOutputStream( SAVE_DIR.resolve(tempFile)));
|
||||
// BufferedOutputStream counter = new
|
||||
// BufferedOutputStream(Files.newOutputStream(
|
||||
// SAVE_DIR.resolve(tempFile)));
|
||||
ByteArrayOutputStream tempDataStream = new ByteArrayOutputStream();
|
||||
DataOutputStream trueOutput = new DataOutputStream(
|
||||
new DeflaterOutputStream(
|
||||
@ -277,13 +282,14 @@ public class TestWorldDiskIO {
|
||||
ChunkIO.save(chunk, trueOutput, IOContext.SAVE);
|
||||
writeGenerationHint(chunk, trueOutput, server);
|
||||
|
||||
/*while (counter.getCount()%sectorSize != 0) {
|
||||
counter.write(0);
|
||||
}*/
|
||||
|
||||
|
||||
LOG.info("Wrote {} bytes to {},{},{}",trueOutput.size(),chunk.getPosition().x,chunk.getPosition().y,chunk.getPosition().z);
|
||||
/*
|
||||
* while (counter.getCount()%sectorSize != 0) {
|
||||
* counter.write(0);
|
||||
* }
|
||||
*/
|
||||
|
||||
// LOG.info("Wrote {} bytes to
|
||||
// {},{},{}",trueOutput.size(),chunk.getPosition().x,chunk.getPosition().y,chunk.getPosition().z);
|
||||
|
||||
trueOutput.close();
|
||||
|
||||
@ -294,7 +300,8 @@ public class TestWorldDiskIO {
|
||||
|
||||
output.seek(shortOffset + offsetBytes);
|
||||
output.write((int) tempData.length / sectorSize + 1);
|
||||
LOG.info("Used {} sectors",(int) tempData.length/sectorSize + 1);
|
||||
// LOG.info("Used {} sectors",(int)
|
||||
// tempData.length/sectorSize + 1);
|
||||
|
||||
output.close();
|
||||
|
||||
@ -348,20 +355,21 @@ public class TestWorldDiskIO {
|
||||
|
||||
int bfClone = bestFormat;
|
||||
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
bw.write(bfClone >> 24);
|
||||
LOG.debug(bfClone >> 24);
|
||||
bfClone = bfClone << 8;
|
||||
}
|
||||
|
||||
/*bw.write(
|
||||
new char[] {
|
||||
(char) bestFormat / (256 * 256 * 256),
|
||||
(char) (bestFormat % 256) / (256 * 256),
|
||||
(char) (bestFormat % (256 * 256)) / (256),
|
||||
(char) (bestFormat % (256 * 256 * 256)) }
|
||||
);*/
|
||||
/*
|
||||
* bw.write(
|
||||
* new char[] {
|
||||
* (char) bestFormat / (256 * 256 * 256),
|
||||
* (char) (bestFormat % 256) / (256 * 256),
|
||||
* (char) (bestFormat % (256 * 256)) / (256),
|
||||
* (char) (bestFormat % (256 * 256 * 256)) }
|
||||
* );
|
||||
*/
|
||||
|
||||
bw.close();
|
||||
} catch (IOException e) {
|
||||
@ -521,19 +529,19 @@ public class TestWorldDiskIO {
|
||||
}
|
||||
}
|
||||
|
||||
private static ChunkData loadRegion(Path path, Vec3i chunkPos, WorldData world, Server server) throws IOException, DecodingException
|
||||
{
|
||||
private static ChunkData loadRegion(Path path, Vec3i chunkPos, WorldData world, Server server)
|
||||
throws IOException,
|
||||
DecodingException {
|
||||
try (
|
||||
BufferedInputStream input = new BufferedInputStream(Files.newInputStream(path))
|
||||
) {
|
||||
LOG.info(path.toString());
|
||||
// LOG.info(path.toString());
|
||||
Vec3i pos = getRegionLoc(chunkPos);
|
||||
int shortOffset = (offsetBytes + 1) * (pos.z + regionSize.z * (pos.y + regionSize.y * pos.x));
|
||||
int fullOffset = (offsetBytes + 1) * (chunksPerRegion);
|
||||
input.skipNBytes(shortOffset);
|
||||
int offset = 0;
|
||||
for (int i=0;i<offsetBytes;i++)
|
||||
{
|
||||
for (int i = 0; i < offsetBytes; i++) {
|
||||
offset *= 256;
|
||||
offset += input.read();
|
||||
}
|
||||
@ -541,12 +549,13 @@ public class TestWorldDiskIO {
|
||||
input.skipNBytes(fullOffset - shortOffset - offsetBytes - 1);
|
||||
input.skipNBytes(sectorSize * offset);
|
||||
|
||||
LOG.info("Read {} sectors", sectorLength);
|
||||
// LOG.info("Read {} sectors", sectorLength);
|
||||
|
||||
byte tempData[] = input.readNBytes(sectorSize * sectorLength);
|
||||
|
||||
DataInputStream trueInput = new DataInputStream(
|
||||
new InflaterInputStream(new BufferedInputStream(new ByteArrayInputStream(tempData))));
|
||||
new InflaterInputStream(new BufferedInputStream(new ByteArrayInputStream(tempData)))
|
||||
);
|
||||
ChunkData chunk = ChunkIO.load(world, chunkPos, trueInput, IOContext.SAVE);
|
||||
readGenerationHint(chunk, trueInput, server);
|
||||
trueInput.close();
|
||||
|
Reference in New Issue
Block a user