本文整理汇总了Java中ethanjones.cubes.world.storage.Area类的典型用法代码示例。如果您正苦于以下问题:Java Area类的具体用法?Java Area怎么用?Java Area使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Area类属于ethanjones.cubes.world.storage包,在下文中一共展示了Area类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: randomTick
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
@Override
public int randomTick(World world, Area area, int x, int y, int z, int meta) {
if (y < area.maxY) {
if (!validGrass(world, area, x, y, z, true)) {
area.setBlock(Blocks.dirt, x, y, z, 0);
}
}
for (int i = y - 1; i <= y + 1; i++) {
checkDirt(world, area, x + 1, i, z + 1);
checkDirt(world, area, x + 1, i, z);
checkDirt(world, area, x + 1, i, z - 1);
checkDirt(world, area, x, i, z + 1);
checkDirt(world, area, x, i, z - 1);
checkDirt(world, area, x - 1, i, z + 1);
checkDirt(world, area, x - 1, i, z);
checkDirt(world, area, x - 1, i, z - 1);
}
return meta;
}
示例2: tick
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
@Override
public void tick() {
Performance.start(PerformanceTags.SERVER_WORLD_UPDATE);
updateLock.writeLock();
super.tick();
Performance.start(PerformanceTags.SERVER_WORLD_AREA_TICK);
map.lock.readLock();
for (Area area : map) {
area.tick();
}
map.lock.readUnlock();
Performance.stop(PerformanceTags.SERVER_WORLD_AREA_TICK);
updateLock.writeUnlock();
Performance.stop(PerformanceTags.SERVER_WORLD_UPDATE);
}
示例3: generate
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
@Override
public void generate(Area area) {
for (int x = 0; x < Area.SIZE_BLOCKS; x++) {
for (int z = 0; z < Area.SIZE_BLOCKS; z++) {
set(area, Blocks.bedrock, x, 0, z, 0);
set(area, Blocks.stone, x, 1, z, 0);
set(area, Blocks.stone, x, 2, z, 0);
set(area, Blocks.dirt, x, 3, z, 0);
set(area, Blocks.grass, x, 4, z, 0);
}
}
if (area.areaX == 0 && area.areaZ == 0 && old) {
set(area, Blocks.bedrock, 1, 4, 1, 0);
set(area, Blocks.bedrock, 1, 7, 1, 0);
set(area, Blocks.stone, 5, 5, 3, 0);
set(area, Blocks.grass, 3, 5, 5, 0);
}
}
示例4: generateIf1
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
private void generateIf1(int y, int x, int z, Area area){
if (y % 2 == 0) {
if (x % 2 == 0) {
if (z % 2 == 0)
set(area, Blocks.grass, x, y, z, 0);
} else {
if (z % 2 == 1)
set(area, Blocks.grass, x, y, z, 0);
}
} else {
if (x % 2 == 1) {
if (z % 2 == 0)
set(area, Blocks.grass, x, y, z, 0);
} else {
if (z % 2 == 1)
set(area, Blocks.grass, x, y, z, 0);
}
}
}
示例5: read
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
public static Area read(Save save, int x, int z) {
FileHandle file = file(save, x, z);
if (!file.exists()) {
// Log.warning("Area does not exist");
return null;
}
Inflater inflater = inflaterThreadLocal.get();
try {
inflater.reset();
InputStream inputStream = file.read(8192);
InflaterInputStream inflaterInputStream = new InflaterInputStream(inputStream, inflater);
BufferedInputStream bufferedInputStream = new BufferedInputStream(inflaterInputStream);
DataInputStream dataInputStream = new DataInputStream(bufferedInputStream);
Area area = new Area(x, z);
area.read(dataInputStream);
dataInputStream.close();
return area;
} catch (Exception e) {
Log.error("Failed to read area " + x + "," + z, e);
return null;
}
}
示例6: randomTick
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
@Override
public int randomTick(World world, Area area, int x, int y, int z, int meta) {
if (y < area.maxY) {
if (!validGrass(world, area, x, y, z, true)) {
area.setBlock(Blocks.dirt, x, y, z, 0);
}
}
for (int i = y - 1; i <= y + 1; i++) {
checkDirt(world, area, x + 1, i, z + 1);
checkDirt(world, area, x + 1, i, z);
checkDirt(world, area, x + 1, i, z - 1);
checkDirt(world, area, x, i, z + 1);
checkDirt(world, area, x, i, z - 1);
checkDirt(world, area, x - 1, i, z + 1);
checkDirt(world, area, x - 1, i, z);
checkDirt(world, area, x - 1, i, z - 1);
}
return meta;
}
示例7: generate
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
@Override
public void generate(Area area) {
Expression[] expressions = expressionThreadLocal.get();
for (int x = 0; x < Area.SIZE_BLOCKS; x++) {
for (int z = 0; z < Area.SIZE_BLOCKS; z++) {
int minHeight = -1, maxHeight = -1;
for (Expression e : expressions) {
int y = height(e, x + area.minBlockX, z + area.minBlockZ);
if (y != -1 && (minHeight == -1 || y < minHeight)) minHeight = y;
if (y > maxHeight) maxHeight = y;
}
if (minHeight != -1) {
for (int y = minHeight; y <= maxHeight; y++) {
block(area, x, y, z);
}
}
}
}
}
示例8: tryPropagateAdd
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
private static void tryPropagateAdd(ArrayDeque<LightNode> lightQueue, LightWorldSection w, int x, int y, int z,
int ln) {
int dX = CoordinateConverter.area(x) - w.initialAreaX;
int dZ = CoordinateConverter.area(z) - w.initialAreaZ;
Area a = w.areas[dX + 1][dZ + 1];
int ref = getRef(x - a.minBlockX, y, z - a.minBlockZ);
if (!a.isReady() || y > a.maxY || !TransparencyManager.isTransparent(a.blocks[ref]))
return;
int i = ((a.light[ref] >> 4) & 0xF);
if (i + 1 <= ln) { // DIFFERENT + 1 instead of + 2
a.light[ref] = (byte) ((a.light[ref] & 0xF) | (ln << 4));
a.updateRender(y / SIZE_BLOCKS);
a.modify();
lightQueue.add(new LightNode(x, y, z, ln));
}
}
示例9: generate
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
@Override
public void generate(Area area) {
for (int x = 0; x < Area.SIZE_BLOCKS; x++) {
for (int z = 0; z < Area.SIZE_BLOCKS; z++) {
set(area, Blocks.bedrock, x, 0, z, 0);
set(area, Blocks.stone, x, 1, z, 0);
set(area, Blocks.stone, x, 2, z, 0);
set(area, Blocks.dirt, x, 3, z, 0);
set(area, Blocks.grass, x, 4, z, 0);
}
}
if (area.areaX == 0 && area.areaZ == 0 && old) {
set(area, Blocks.bedrock, 1, 4, 1, 0);
set(area, Blocks.bedrock, 1, 7, 1, 0);
set(area, Blocks.stone, 5, 5, 3, 0);
set(area, Blocks.grass, 3, 5, 5, 0);
}
}
示例10: spreadLight
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
public static void spreadLight(int x, int y, int z, Area area, LightWorldSection w) {
if (y >= 0 && y <= area.maxY) {
ArrayDeque<LightNode> lightQueue = new ArrayDeque<LightNode>(1000);
lightIf1(x, y, z, w, lightQueue);
lightIf2(x, y, z, w, lightQueue);
if (y <= w.maxY(x, z + 1) && (w.transparent(x, y, z + 1) || w.isLightSource(x, y, z + 1)))
lightQueue.add(new LightNode(x, y, z + 1, w.getLight(x, y, z + 1)));
if (y <= w.maxY(x, z - 1) && (w.transparent(x, y, z - 1) || w.isLightSource(x, y, z - 1)))
lightQueue.add(new LightNode(x, y, z - 1, w.getLight(x, y, z - 1)));
propagateAdd(lightQueue, w);
}
}
示例11: complete
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
public boolean complete(Area area, int ySection, AreaMap areaMap, int status) {
if (status == AreaRenderStatus.COMPLETE) {
completeIF1(area, ySection);
Area maxX = areaMap.lockedGetArea(area.areaX + 1, area.areaZ);
completeIf2(maxX, ySection);
completeIf3(areaMap, area, ySection);
Area maxZ = areaMap.lockedGetArea(area.areaX, area.areaZ + 1);
completeIf3(maxZ, ySection);
Area minZ = areaMap.lockedGetArea(area.areaX, area.areaZ - 1);
if (minZ != null && !minZ.isBlank())
if (minZ.renderStatus.length < ySection - 1 || (minZ.renderStatus[ySection]
& AreaRenderStatus.COMPLETE_MAX_Z) != AreaRenderStatus.COMPLETE_MAX_Z)
return false;
return true;
}
return false;
}
示例12: setBlocks
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
public void setBlocks(Block block, int x1, int y1, int z1, int x2, int y2, int z2, int meta) {
int minX = Math.min(x1, x2);
int minY = Math.min(y1, y2);
int minZ = Math.min(z1, z2);
int maxX = Math.max(x1, x2);
int maxY = Math.max(y1, y2);
int maxZ = Math.max(z1, z2);
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
Area area = getArea(CoordinateConverter.area(x), CoordinateConverter.area(z));
if (area != null) {
for (int y = minY; y <= maxY; y++) {
area.setBlock(block, x - area.minBlockX, y, z - area.minBlockZ, meta);
}
}
}
}
}
示例13: spreadLight
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
public static void spreadLight(int x, int y, int z, Area area, LightWorldSection w) {
if (y >= 0 && y <= area.maxY) {
ArrayDeque<LightNode> lightQueue = new ArrayDeque<LightNode>(1000);
if (y <= w.maxY(x + 1, z) && (w.transparent(x + 1, y, z) || w.isLightSource(x + 1, y, z)))
lightQueue.add(new LightNode(x + 1, y, z, w.getLight(x + 1, y, z)));
if (y <= w.maxY(x - 1, z) && (w.transparent(x - 1, y, z) || w.isLightSource(x - 1, y, z)))
lightQueue.add(new LightNode(x - 1, y, z, w.getLight(x - 1, y, z)));
if (y < w.maxY(x, z) && (w.transparent(x, y + 1, z) || w.isLightSource(x, y + 1, z)))
lightQueue.add(new LightNode(x, y + 1, z, w.getLight(x, y + 1, z)));
if (y > 0 && (w.transparent(x, y - 1, z) || w.isLightSource(x, y - 1, z)))
lightQueue.add(new LightNode(x, y - 1, z, w.getLight(x, y - 1, z)));
if (y <= w.maxY(x, z + 1) && (w.transparent(x, y, z + 1) || w.isLightSource(x, y, z + 1)))
lightQueue.add(new LightNode(x, y, z + 1, w.getLight(x, y, z + 1)));
if (y <= w.maxY(x, z - 1) && (w.transparent(x, y, z - 1) || w.isLightSource(x, y, z - 1)))
lightQueue.add(new LightNode(x, y, z - 1, w.getLight(x, y, z - 1)));
propagateAdd(lightQueue, w);
}
}
示例14: handlePacket
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
@Override
public void handlePacket() {
Area area = Side.getCubes().world.getArea(areaX, areaZ);
if (area != null) {
BlockData blockData = area.getBlockData(blockX, blockY, blockZ);
blockData.read(dataGroup);
}
if (Side.isServer()) {
ClientIdentifier client = Cubes.getServer().getClient(getSocketMonitor());
if (client != null) {
PacketBlockData n = new PacketBlockData();
n.areaX = this.areaX;
n.areaZ = this.areaZ;
n.blockX = this.blockX;
n.blockY = this.blockY;
n.blockZ = this.blockZ;
n.dataGroup = this.dataGroup;
NetworkingManager.sendPacketToOtherClients(n, client);
}
}
}
示例15: BlockIf
import ethanjones.cubes.world.storage.Area; //导入依赖的package包/类
private void BlockIf(int x1, int i1, Area area1, Block block1, float[] vertexOffset1, Vector3 areaOffset1,
BlockTextureHandler textureHandler1, boolean ao1, int y1, int z1, float[] vertices1, Object maxX1,
int MIN_AREA) {
if (x1 < SIZE_BLOCKS - 1) {
if (block1.renderFace(BlockFace.posX, area1.blocks[i1 + MAX_X_OFFSET])) {
// light: byte is signed (-128 to 127) so & 0xFF to convert
// to 0-255
vertexOffset1 = createMaxX(areaOffset1, textureHandler1.getSide(BlockFace.posX),
AmbientOcclusion.posX(area1, x1, y1, z1, ao1), x1, y1, z1,
area1.light[i1 + MAX_X_OFFSET] & 0xFF, vertices1, vertexOffset1);
}
} else if (maxX1 == null || y1 > maxX1.maxY) {
vertexOffset1 = createMaxX(areaOffset1, textureHandler1.getSide(BlockFace.posX),
AmbientOcclusion.posX(area1, x1, y1, z1, ao1), x1, y1, z1, MAX_SUNLIGHT, vertices1, vertexOffset1);
} else if (block1.renderFace(BlockFace.posX, maxX1.blocks[getRef(MIN_AREA, y1, z1)])) {
vertexOffset1 = createMaxX(areaOffset1, textureHandler1.getSide(BlockFace.posX),
AmbientOcclusion.posX(area1, x1, y1, z1, ao1), x1, y1, z1,
maxX1.light[getRef(MIN_AREA, y1, z1)] & 0xFF, vertices1, vertexOffset1);
}
}