Fix strange schem load issue + start work on MCRExtent
This commit is contained in:
parent
424bcc5d05
commit
08f35d420a
@ -32,6 +32,9 @@ ext {
|
||||
}
|
||||
|
||||
version = date + revision + buildNumber
|
||||
if ( project.hasProperty("lzNoVersion") ) { // gradle build -PlzNoVersion
|
||||
version = "";
|
||||
}
|
||||
description = """FastAsyncWorldEdit"""
|
||||
|
||||
subprojects {
|
||||
|
9
core/src/main/java/com/boydti/fawe/jnbt/MCRFile.java
Normal file
9
core/src/main/java/com/boydti/fawe/jnbt/MCRFile.java
Normal file
@ -0,0 +1,9 @@
|
||||
package com.boydti.fawe.jnbt;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MCRFile {
|
||||
public MCRFile(File regionFolder, int mcrX, int mcrZ) {
|
||||
// TODO load NBT
|
||||
}
|
||||
}
|
125
core/src/main/java/com/boydti/fawe/object/extent/MCRExtent.java
Normal file
125
core/src/main/java/com/boydti/fawe/object/extent/MCRExtent.java
Normal file
@ -0,0 +1,125 @@
|
||||
package com.boydti.fawe.object.
|
||||
|
||||
import com.boydti.fawe.example.NMSMappedFaweQueue;
|
||||
import com.boydti.fawe.jnbt.MCRFile;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class MCRExtent extends AbstractDelegateExtent {
|
||||
private final FaweQueue queue;
|
||||
private final File folder;
|
||||
|
||||
private Map<Long, MCRFile> regions;
|
||||
|
||||
public MCRExtent(World world, FaweQueue queue) {
|
||||
super(world);
|
||||
this.queue = queue;
|
||||
this.folder = new File(queue.getSaveFolder(), "regions");
|
||||
this.regions = new HashMap<>();
|
||||
}
|
||||
|
||||
public FaweQueue getQueue() {
|
||||
return queue;
|
||||
}
|
||||
|
||||
private int lastX = Integer.MAX_VALUE;
|
||||
private int lastZ = Integer.MAX_VALUE;
|
||||
private MCRFile lastMCR;
|
||||
|
||||
private MCRFile getMCR(int x, int y, int z) {
|
||||
int mcrX = x >> 9;
|
||||
int mcrZ = z >> 9;
|
||||
if (mcrX == lastX && mcrZ == lastZ) {
|
||||
return lastMCR;
|
||||
}
|
||||
lastX = mcrX;
|
||||
lastZ = mcrZ;
|
||||
long pair = MathMan.pairInt(lastX, lastZ);
|
||||
lastMCR = regions.get(pair);
|
||||
if (lastMCR == null) {
|
||||
lastMCR = new MCRFile(folder, lastX, lastZ);
|
||||
regions.put(pair, lastMCR);
|
||||
}
|
||||
return lastMCR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getBlock(Vector position) {
|
||||
// TODO get block from MCR
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getLazyBlock(Vector position) {
|
||||
// TODO set block in MCR
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
||||
// TODO set block in MCR
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
// TODO add entity to MCR
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities() {
|
||||
// TODO get entities from MCR
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
// TODO get entities from MCR
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
// TODO get biome from MCR
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return super.getMinimumPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return super.getMaximumPoint();
|
||||
}
|
||||
|
||||
protected Operation commitBefore() {
|
||||
// Save MCR file if modified
|
||||
return null;
|
||||
}
|
||||
}
|
@ -104,26 +104,26 @@ public final class NBTInputStream implements Closeable {
|
||||
case NBTConstants.TYPE_END:
|
||||
return;
|
||||
case NBTConstants.TYPE_BYTE:
|
||||
is.skip(1);
|
||||
is.skipBytes(1);
|
||||
return;
|
||||
case NBTConstants.TYPE_SHORT:
|
||||
is.skip(2);
|
||||
is.skipBytes(2);
|
||||
return;
|
||||
case NBTConstants.TYPE_INT:
|
||||
is.skip(4);
|
||||
is.skipBytes(4);
|
||||
return;
|
||||
case NBTConstants.TYPE_LONG:
|
||||
is.skip(8);
|
||||
is.skipBytes(8);
|
||||
return;
|
||||
case NBTConstants.TYPE_FLOAT:
|
||||
is.skip(4);
|
||||
is.skipBytes(4);
|
||||
return;
|
||||
case NBTConstants.TYPE_DOUBLE:
|
||||
is.skip(8);
|
||||
is.skipBytes(8);
|
||||
return;
|
||||
case NBTConstants.TYPE_STRING:
|
||||
int length = is.readShort();
|
||||
is.skip(length);
|
||||
is.skipBytes(length);
|
||||
return;
|
||||
case NBTConstants.TYPE_BYTE_ARRAY:
|
||||
RunnableVal2 reader = getReader.runAndGet(node + ".?", null).value2;
|
||||
@ -133,7 +133,7 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
reader = getReader.runAndGet(node + ".#", null).value2;
|
||||
if (reader == null) {
|
||||
is.skip(length);
|
||||
is.skipBytes(length);
|
||||
return;
|
||||
}
|
||||
if (reader instanceof NBTStreamer.ByteReader) {
|
||||
@ -191,7 +191,7 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
reader = getReader.runAndGet(node + ".#", null).value2;
|
||||
if (reader == null) {
|
||||
is.skip(length << 2);
|
||||
is.skipBytes(length << 2);
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user