本文整理汇总了Java中ethanjones.cubes.world.reference.AreaReference类的典型用法代码示例。如果您正苦于以下问题:Java AreaReference类的具体用法?Java AreaReference怎么用?Java AreaReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AreaReference类属于ethanjones.cubes.world.reference包,在下文中一共展示了AreaReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
public void write(DataOutputStream outputStream) throws IOException {
outputStream.writeInt(caveStartX);
outputStream.writeInt(caveStartY);
outputStream.writeInt(caveStartZ);
outputStream.writeInt(blocks.size());
Set<Entry<AreaReference, int[]>> s = blocks.entrySet();
for (Entry<AreaReference, int[]> entry : s) {
AreaReference key = entry.getKey();
int[] value = entry.getValue();
outputStream.writeInt(key.areaX);
outputStream.writeInt(key.areaZ);
outputStream.writeInt(value.length);
for (int i = 0; i < value.length; i++) {
outputStream.writeInt(value[i]);
}
}
}
示例2: read
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
public static Cave read(DataInputStream inputStream) throws IOException {
int caveStartX = inputStream.readInt();
int caveStartY = inputStream.readInt();
int caveStartZ = inputStream.readInt();
int mapSize = inputStream.readInt();
HashMap<AreaReference, int[]> blocks = new HashMap<AreaReference, int[]>();
for (int i = 0; i < mapSize; i++) {
int areaX = inputStream.readInt();
int areaZ = inputStream.readInt();
int valueLength = inputStream.readInt();
AreaReference areaReference = new AreaReference().setFromAreaCoordinates(areaX, areaZ);
int[] value = new int[valueLength];
for (int j = 0; j < valueLength; j++) {
value[j] = inputStream.readInt();
}
blocks.put(areaReference, value);
}
return new Cave(caveStartX, caveStartY, caveStartZ, blocks);
}
示例3: generate
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
public Cave generate() {
int spawnDist = (int) distanceFromSpawn(caveStartX, caveStartZ);
Log.debug("Generating new cave at " + caveStartX + "," + caveStartZ + " (" + spawnDist + " blocks from spawn)");
generateNodes();
calculateBlocks();
Cave cave = new Cave(caveStartX, caveStartY, caveStartZ, new HashMap<AreaReference, int[]>() {
{
for (Map.Entry<AreaReference, IntArray> entry : blocks.entrySet()) {
this.put(entry.getKey(), entry.getValue().toArray());
}
}
});
return cave;
}
示例4: generateCave
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
private Cave generateCave(final AreaReference a) {
int offsetX = smoothWorld.pseudorandomInt(a.areaX, a.areaZ, Area.SIZE_BLOCKS - 1);
int offsetZ = smoothWorld.pseudorandomInt(a.areaZ, a.areaX, Area.SIZE_BLOCKS - 1);
int x = a.minBlockX() + offsetX;
int z = a.minBlockZ() + offsetZ;
CaveGenerator caveGenerator = new CaveGenerator(x, z, smoothWorld);
final Cave cave = caveGenerator.generate();
final Save save = Cubes.getServer().world.save;
Executor.executeNotSided(new Runnable() {
@Override
public void run() {
save.writeCave(a, cave);
}
});
return cave;
}
示例5: readCave
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
public Cave readCave(AreaReference areaReference) {
if (fileHandle == null)
return null;
FileHandle folder = folderCave();
FileHandle file = folder.child(areaReference.areaX + "_" + areaReference.areaZ);
if (!file.exists())
return null;
try {
InputStream read = file.read();
DataInputStream dataInputStream = new DataInputStream(read);
Cave cave = Cave.read(dataInputStream);
read.close();
return cave;
} catch (IOException e) {
Log.warning("Failed to read cave", e);
return null;
}
}
示例6: of
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
public static LuaVector of(Object o) {
if (o instanceof LuaVector)
return new LuaVector((LuaVector) o);
if (o instanceof BlockReference)
return new LuaVector((BlockReference) o);
if (o instanceof AreaReference)
return new LuaVector((AreaReference) o);
if (o instanceof Vector3)
return new LuaVector((Vector3) o);
if (o instanceof LuaValue) {
LuaValue l = (LuaValue) o;
if (l.isuserdata(LuaValue.class))
return new LuaVector((LuaVector) l.checkuserdata());
}
throw new IllegalArgumentException(String.valueOf(o));
}
示例7: write
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
public void write(DataOutputStream outputStream) throws IOException {
outputStream.writeInt(caveStartX);
outputStream.writeInt(caveStartY);
outputStream.writeInt(caveStartZ);
outputStream.writeInt(blocks.size());
for (Entry<AreaReference, int[]> entry : blocks.entrySet()) {
AreaReference key = entry.getKey();
int[] value = entry.getValue();
outputStream.writeInt(key.areaX);
outputStream.writeInt(key.areaZ);
outputStream.writeInt(value.length);
for (int i = 0; i < value.length; i++) {
outputStream.writeInt(value[i]);
}
}
}
示例8: read
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
public static Cave read(DataInputStream inputStream) throws IOException {
int caveStartX = inputStream.readInt();
int caveStartY = inputStream.readInt();
int caveStartZ = inputStream.readInt();
int mapSize = inputStream.readInt();
HashMap<AreaReference, int[]> blocks = new HashMap<AreaReference, int[]>();
for (int i = 0; i < mapSize; i++) {
int areaX = inputStream.readInt();
int areaZ = inputStream.readInt();
int valueLength = inputStream.readInt();
AreaReference areaReference = new AreaReference().setFromAreaCoordinates(areaX, areaZ);
int[] value = new int[valueLength];
for (int j = 0; j < valueLength; j++) {
value[j] = inputStream.readInt();
}
blocks.put(areaReference, value);
}
return new Cave(caveStartX, caveStartY, caveStartZ, blocks);
}
示例9: generateCave
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
private Cave generateCave(final AreaReference a) {
int offsetX = smoothWorld.pseudorandomInt(a.areaX, a.areaZ, Area.SIZE_BLOCKS - 1);
int offsetZ = smoothWorld.pseudorandomInt(a.areaZ, a.areaX, Area.SIZE_BLOCKS - 1);
int x = a.minBlockX() + offsetX;
int z = a.minBlockZ() + offsetZ;
CaveGenerator caveGenerator = new CaveGenerator(x, z, smoothWorld);
final Cave cave = caveGenerator.generate();
final Save save = Cubes.getServer().world.save;
Executor.executeNotSided(new Runnable() {
@Override
public void run() {
save.writeCave(a, cave);
}
});
return cave;
}
示例10: readCave
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
public Cave readCave(AreaReference areaReference) {
if (fileHandle == null) return null;
FileHandle folder = folderCave();
FileHandle file = folder.child(areaReference.areaX + "_" + areaReference.areaZ);
if (!file.exists()) return null;
try {
InputStream read = file.read();
DataInputStream dataInputStream = new DataInputStream(read);
Cave cave = Cave.read(dataInputStream);
read.close();
return cave;
} catch (IOException e) {
Log.warning("Failed to read cave", e);
return null;
}
}
示例11: Cave
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
public Cave(int x, int y, int z, HashMap<AreaReference, int[]> blocks) {
this.caveStartX = x;
this.caveStartY = y;
this.caveStartZ = z;
this.blocks = blocks;
}
示例12: apply
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
public void apply(Area area) {
int[] array = blocks.get(new AreaReference().setFromArea(area));
if (array == null)
return;
for (int ref : array) {
if (ref < area.blocks.length)
area.blocks[ref] = 0;
}
}
示例13: applyCaveNull
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
private void applyCaveNull(Cave cave, AreaReference areaReference) {
cave = loadCave(areaReference);
if (cave == null) {
cave = generateCave(areaReference);
}
if (!caves.replace(areaReference.copy(), Thread.currentThread(), cave)) {
throw new IllegalStateException();
}
synchronized (caves) {
caves.notifyAll();
}
}
示例14: applyCaveThread
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
private void applyCaveThread(Cave cave, Object o, AreaReference areaReference) {
while (cave == null) {
synchronized (caves) {
try {
caves.wait();
} catch (InterruptedException ignored) {
}
}
o = caves.get(areaReference);
if (o instanceof Cave) {
cave = (Cave) o;
}
}
}
示例15: apply
import ethanjones.cubes.world.reference.AreaReference; //导入依赖的package包/类
public void apply(Area area) {
getSpawnCave().apply(area);
AreaReference areaReference;
for (int aX = area.areaX - caveAreaRadius; aX <= area.areaX + caveAreaRadius; aX++) {
for (int aZ = area.areaZ - caveAreaRadius; aZ <= area.areaZ + caveAreaRadius; aZ++) {
// 6 bits = 2^6 = 64
// one in 64 areas
if (smoothWorld.pseudorandomBits(aX, aZ, 6, true) == 0) {
Cave cave = null;
areaReference = new AreaReference().setFromAreaCoordinates(aX, aZ);
Object o = caves.putIfAbsent(areaReference, Thread.currentThread());
if (o instanceof Cave) {
cave = (Cave) o;
} else if (o == null) { // this thread
applyCaveNull(cave, areaReference);
} else if (o instanceof Thread) { // wait for another thread
applyCaveThread(cave, o, areaReference);
} else {
throw new IllegalStateException(o.getClass().getName());
}
cave.apply(area);
}
}
}
}