本文整理汇总了Java中ethanjones.cubes.world.CoordinateConverter类的典型用法代码示例。如果您正苦于以下问题:Java CoordinateConverter类的具体用法?Java CoordinateConverter怎么用?Java CoordinateConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CoordinateConverter类属于ethanjones.cubes.world包,在下文中一共展示了CoordinateConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryPropagateRemove
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
private static void tryPropagateRemove(ArrayDeque<LightNode> removeQueue, ArrayDeque<LightNode> addQueue,
LightWorldSection w, int x, int y, int z, int l) {
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 p = ((a.light[ref] >> 4) & 0xF);
if (p != 0 && p < l) {
a.light[ref] = (byte) (a.light[ref] & 0xF); // same as
// ((a.light[ref] &
// 0xF0) | (0 << 4))
a.updateRender(y / SIZE_BLOCKS);
a.modify();
removeQueue.add(new LightNode(x, y, z, p));
} else if (p >= l) {
addQueue.add(new LightNode(x, y, z, p));
}
}
示例2: preventNoclip
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
@EventHandler
public void preventNoclip(PlayerMovementEvent event) {
Player player = event.getPlayer();
Vector3 pos = event.newPosition;
if (world.getArea(CoordinateConverter.area(pos.x), CoordinateConverter.area(pos.z)) != null
&& !event.isCanceled()) {
int blockX = CoordinateConverter.block(pos.x);
int blockZ = CoordinateConverter.block(pos.z);
int minBlockY = CoordinateConverter.block(pos.y - player.height);
int maxBlockY = CoordinateConverter.block(pos.y + 0.2f);
for (int y = minBlockY; y <= maxBlockY; y++) {
if (world.getBlock(blockX, y, blockZ) != null) {
event.setCanceled(true);
return;
}
}
limit(pos, +r, 0, player.height);
limit(pos, -r, 0, player.height);
limit(pos, 0, +r, player.height);
limit(pos, 0, -r, player.height);
}
}
示例3: tryPropagateAdd
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的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));
}
}
示例4: tryPropagateRemove
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
private static void tryPropagateRemove(ArrayDeque<LightNode> removeQueue, ArrayDeque<LightNode> addQueue,
LightWorldSection w, int x, int y, int z, int l) {
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 p = a.light[ref] & 0xF;
if (p != 0 && p < l) {
a.light[ref] = (byte) (a.light[ref] & 0xF0); // same as
// ((a.light[ref] &
// 0xF0) | 0)
a.updateRender(y / SIZE_BLOCKS);
a.modify();
removeQueue.add(new LightNode(x, y, z, p));
} else if (p >= l) {
addQueue.add(new LightNode(x, y, z, p));
}
}
示例5: preventNoclip
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
@EventHandler
public void preventNoclip(PlayerMovementEvent event) {
Player player = event.getPlayer();
Vector3 pos = event.newPosition;
if (world.getArea(CoordinateConverter.area(pos.x), CoordinateConverter.area(pos.z)) != null && !event.isCanceled()) {
int blockX = CoordinateConverter.block(pos.x);
int blockZ = CoordinateConverter.block(pos.z);
int minBlockY = CoordinateConverter.block(pos.y - player.height);
int maxBlockY = CoordinateConverter.block(pos.y + 0.2f);
for (int y = minBlockY; y <= maxBlockY; y++) {
if (world.getBlock(blockX, y, blockZ) != null) {
event.setCanceled(true);
return;
}
}
limit(pos, +r, 0, player.height);
limit(pos, -r, 0, player.height);
limit(pos, 0, +r, player.height);
limit(pos, 0, -r, player.height);
}
}
示例6: tryPropagateRemove
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
private static void tryPropagateRemove(ArrayDeque<LightNode> removeQueue, ArrayDeque<LightNode> addQueue, LightWorldSection w, int x, int y, int z, int l) {
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 p = ((a.light[ref] >> 4) & 0xF);
if (p != 0 && p < l) {
a.light[ref] = (byte) (a.light[ref] & 0xF); // same as ((a.light[ref] & 0xF0) | (0 << 4))
a.updateRender(y / SIZE_BLOCKS);
a.modify();
removeQueue.add(new LightNode(x, y, z, p));
} else if (p >= l) {
addQueue.add(new LightNode(x, y, z, p));
}
}
示例7: tryPropagateRemove
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
private static void tryPropagateRemove(ArrayDeque<LightNode> removeQueue, ArrayDeque<LightNode> addQueue, LightWorldSection w, int x, int y, int z, int l) {
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 p = a.light[ref] & 0xF;
if (p != 0 && p < l) {
a.light[ref] = (byte) (a.light[ref] & 0xF0); // same as ((a.light[ref] & 0xF0) | 0)
a.updateRender(y / SIZE_BLOCKS);
a.modify();
removeQueue.add(new LightNode(x, y, z, p));
} else if (p >= l) {
addQueue.add(new LightNode(x, y, z, p));
}
}
示例8: update
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
public boolean update() {
super.update();
if (Side.isServer()) {
if (age >= (600000 / Cubes.tickMS)) {
if (itemStack.item == Blocks.sapling.getItemBlock() && itemStack.count == 1) {
int x = CoordinateConverter.block(position.x), y = CoordinateConverter.block(position.y), z = CoordinateConverter.block(position.z);
if (Cubes.getServer().world.getBlock(x, y - 1, z) == Blocks.grass) {
Cubes.getServer().world.setBlock(Blocks.sapling, x, y, z);
}
}
return true;
}
if (age >= 0) {
for (ClientIdentifier clientIdentifier : Cubes.getServer().getAllClients()) {
float distance2 = VectorUtil.distance2(this.position, clientIdentifier.getPlayer().position.cpy().sub(0, clientIdentifier.getPlayer().height, 0));
if (distance2 < 1f) {
InventoryHelper.addItemstack(clientIdentifier.getPlayer().getInventory(), itemStack);
return true;
}
}
}
}
age++;
return false;
}
示例9: getDebugString
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
public static String getDebugString() {
Vector3 p = Cubes.getClient().player.position;
ms.addValue(Gdx.graphics.getRawDeltaTime() * 1000f);
builder.setLength(brandingDebugLength);
builder.append("FPS:").append(Gdx.graphics.getFramesPerSecond()).append(" MS:").append(twoDP.format(ms.getMean())).append(" MEM:").append(Compatibility.get().getFreeMemory()).append("MB").append(lineSeparator);
builder.append("TPS C:").append(Cubes.getClient().ticksPerSecond.last()).append(" A:").append(oneDP.format(Cubes.getClient().ticksPerSecond.average()));
if (Cubes.getServer() != null) builder.append(" S:").append(Cubes.getServer().ticksPerSecond.last()).append(" A:").append(oneDP.format(Cubes.getServer().ticksPerSecond.average()));
builder.append(lineSeparator);
builder.append("POS X:").append(twoDP.format(p.x)).append("(").append(CoordinateConverter.area(p.x)).append(")").append(" Y:").append(twoDP.format(p.y)).append("(").append(CoordinateConverter.area(p.y)).append(")").append(" Z:").append(twoDP.format(p.z)).append("(").append(CoordinateConverter.area(p.z)).append(")").append(lineSeparator);
builder.append("DIR X:").append(twoDP.format(Cubes.getClient().player.angle.x)).append(" Y:").append(twoDP.format(Cubes.getClient().player.angle.y)).append(" Z:").append(twoDP.format(Cubes.getClient().player.angle.z)).append(lineSeparator);
builder.append("R A:").append(AreaRenderer.renderedThisFrame).append(" M:").append(AreaRenderer.renderedMeshesThisFrame).append(" D:").append(Settings.getIntegerSetting(Settings.GRAPHICS_VIEW_DISTANCE));
if (Settings.getBooleanSettingValue(Settings.GRAPHICS_FOG)) builder.append(" FOG");
if (AmbientOcclusion.isEnabled()) builder.append(" AO");
builder.append(lineSeparator);
if (glProfiler) {
builder.append("TC:").append(LastFrame.totalCalls).append(" DG:").append(LastFrame.drawCalls).append(" TB:").append(LastFrame.textureBindings).append(" SS:").append(LastFrame.shaderSwitches).append(" VC:").append(LastFrame.vertexCount()).append(lineSeparator);
}
builder.append("W B:").append(getBlockLight()).append(" S:").append(getSunlight()).append(" T:").append(Cubes.getClient().world.getTime());
BlockIntersection blockIntersection = BlockIntersection.getBlockIntersection(Cubes.getClient().player.position, Cubes.getClient().player.angle, Cubes.getClient().world);
if (blockIntersection != null && blockIntersection.getBlock() != null) {
builder.append(lineSeparator).append("B ID:").append(blockIntersection.getBlock().id).append(" M:").append(blockIntersection.getBlockMeta());
}
return builder.toString();
}
示例10: transparent
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
protected boolean transparent(int x, int y, int z) {
Area a = getArea(CoordinateConverter.area(x), CoordinateConverter.area(z));
if (!a.isReady())
return true;
int ref = Area.getRef(x - a.minBlockX, y, z - a.minBlockZ);
return TransparencyManager.isTransparent(a.blocks[ref]);
}
示例11: isLightSource
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
protected boolean isLightSource(int x, int y, int z) {
Area a = getArea(CoordinateConverter.area(x), CoordinateConverter.area(z));
if (!a.isReady())
return false;
int b = a.blocks[Area.getRef(x - a.minBlockX, y, z - a.minBlockZ)];
if (b == 0)
return false;
int blockID = b & 0xFFFFF;
int blockMeta = (b >> 20) & 0xFF;
return IDManager.toBlock(blockID).getLightLevel(blockMeta) > 0;
}
示例12: tryPropagateAdd
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
private static void tryPropagateAdd(ArrayDeque<LightNode> lightQueue, LightWorldSection w, int x, int y, int z,
int l) {
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;
if ((a.light[ref] & 0xF) + 2 <= l) {
a.light[ref] = (byte) ((a.light[ref] & 0xF0) | (l - 1));
a.updateRender(y / SIZE_BLOCKS);
a.modify();
lightQueue.add(new LightNode(x, y, z, l - 1));
}
}
示例13: getEntitiesForSave
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
public DataGroup[] getEntitiesForSave(int areaX, int areaZ) {
lock.readLock();
ArrayList<DataGroup> dataGroups = new ArrayList<DataGroup>();
for (Entity entity : values()) {
if (areaX == CoordinateConverter.area(entity.position.x)
&& areaZ == CoordinateConverter.area(entity.position.z) && !(entity instanceof Player)) {
dataGroups.add(entity.write());
}
}
DataGroup[] array = dataGroups.size() == 0 ? new DataGroup[0]
: dataGroups.toArray(new DataGroup[dataGroups.size()]);
lock.readUnlock();
return array;
}
示例14: setFromPosition
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
public BlockReference setFromPosition(float x, float y, float z) {
this.blockX = CoordinateConverter.block(x);
this.blockY = CoordinateConverter.block(y);
this.blockZ = CoordinateConverter.block(z);
this.hashCode = 0;
return this;
}
示例15: setFromVector3
import ethanjones.cubes.world.CoordinateConverter; //导入依赖的package包/类
public BlockReference setFromVector3(Vector3 vector3) {
this.blockX = CoordinateConverter.block(vector3.x);
this.blockY = CoordinateConverter.block(vector3.y);
this.blockZ = CoordinateConverter.block(vector3.z);
this.hashCode = 0;
return this;
}