WIP level dat for MCAWorld

This commit is contained in:
Jesse Boyd 2019-11-14 19:20:35 +00:00
parent d7b3db215e
commit 54f62e689b
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 122 additions and 6 deletions

View File

@ -0,0 +1,46 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.object.io.PGZIPOutputStream;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.jnbt.NBTOutputStream;
import it.unimi.dsi.fastutil.io.FastBufferedInputStream;
import it.unimi.dsi.fastutil.io.FastBufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import static com.google.common.base.Preconditions.checkArgument;
public class LevelDat {
private final File file;
private CompoundTag tag;
public LevelDat(File file) {
checkArgument(file.exists());
this.file = file;
}
public void load() throws IOException {
try (NBTInputStream nis = new NBTInputStream(new FastBufferedInputStream(new GZIPInputStream(new FastBufferedInputStream(new FileInputStream(file)))))) {
this.tag = (CompoundTag) nis.readNamedTag().getTag();
}
}
public void save() throws IOException {
if (this.tag != null) {
try (NBTOutputStream nos = new NBTOutputStream(new FastBufferedOutputStream(new GZIPOutputStream(new FastBufferedOutputStream(new FileOutputStream(file)))))) {
nos.writeNamedTag("", tag);
}
}
}
public CompoundTag getTag() {
return tag;
}
}

View File

@ -1,23 +1,93 @@
package com.boydti.fawe.jnbt.anvil;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
import com.google.common.base.Preconditions;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.AbstractWorld;
import com.sk89q.worldedit.world.block.BlockState;
public class MCAWorld implements Extent {
@Override
public BlockVector3 getMinimumPoint() {
return null;
import javax.annotation.Nullable;
import java.io.File;
import static com.google.common.base.Preconditions.checkArgument;
public class MCAWorld extends AbstractWorld {
private final File path;
public MCAWorld(File path) {
checkArgument(path.isDirectory());
this.path = path;
}
@Override
public BlockVector3 getMaximumPoint() {
return null;
public String getName() {
return path.getName();
}
@Override
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
return false;
}
@Override
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
return false;
}
@Override
public boolean clearContainerBlockContents(BlockVector3 position) {
return false;
}
@Override
public void dropItem(Vector3 position, BaseItemStack item) {
}
@Override
public void simulateBlockMine(BlockVector3 position) {
}
@Override
public boolean regenerate(Region region, EditSession editSession) {
return false;
}
@Override
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
return false;
}
@Override
public BlockVector3 getSpawnPosition() {
return null;
}
@Override
public void refreshChunk(int chunkX, int chunkZ) {
}
@Override
public IChunkGet get(int x, int z) {
return null;
}
@Override
public void sendFakeChunk(@Nullable Player player, ChunkPacket packet) {
}
}