本文整理汇总了Java中ethanjones.cubes.world.World类的典型用法代码示例。如果您正苦于以下问题:Java World类的具体用法?Java World怎么用?Java World使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
World类属于ethanjones.cubes.world包,在下文中一共展示了World类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updatePosition
import ethanjones.cubes.world.World; //导入依赖的package包/类
public void updatePosition(float time) {
if (!inLoadedArea())
return;
World world = Side.getCubes().world;
float r = 0f;
if (!motion.isZero() || !WorldGravity.onBlock(world, position, height, r)) {
position.add(motion.x * time, motion.y * time, motion.z * time);
motion.y -= GRAVITY * time;
if (WorldGravity.onBlock(world, position, height, r) && motion.y < 0) {
position.y = WorldGravity.getBlockY(position, height) + 1 + height;
motion.y = 0f;
}
if (Side.isServer())
world.syncEntity(uuid);
}
}
示例2: updatePositionIf
import ethanjones.cubes.world.World; //导入依赖的package包/类
private void updatePositionIf(World world, float time, Side side) {
if (!motion.isZero() || !WorldGravity.onBlock(world, tmpVector, height, PLAYER_RADIUS)) {
tmpVector.add(motion.x * time, motion.y * time, motion.z * time);
motion.y -= GRAVITY * time;
if (WorldGravity.onBlock(world, tmpVector, height, PLAYER_RADIUS) && motion.y < 0) {
tmpVector.y = WorldGravity.getBlockY(tmpVector, height) + 1 + height;
motion.y = 0f;
}
if (!new PlayerMovementEvent(this, tmpVector).post().isCanceled()) {
position.set(tmpVector);
if (side == Side.Server)
world.syncEntity(uuid);
}
}
}
示例3: setWorldTransform
import ethanjones.cubes.world.World; //导入依赖的package包/类
public static void setWorldTransform(Renderable renderable, boolean isMoon) {
Vector3 pos = Cubes.getClient().player.position;
int r = 512;
float f = (float) (Cubes.getClient().world.getTime() - (World.MAX_TIME / 4)) / (float) World.MAX_TIME;
if (isMoon)
f += 0.5f;
f %= 1;
float x = (pos.x + (r * Math.cos(f * 2 * Math.PI)));
float y = (pos.y + (r * Math.sin(f * 2 * Math.PI)));
float z = pos.z;
renderable.worldTransform.setToTranslation(x, y, z);
renderable.worldTransform.scl(75f);
renderable.worldTransform.rotate(Vector3.Z, (f - 0.25f % 1) * 360);
}
示例4: randomTick
import ethanjones.cubes.world.World; //导入依赖的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;
}
示例5: init
import ethanjones.cubes.world.World; //导入依赖的package包/类
public static void init() {
CommandBuilder save = new CommandBuilder("save").register().setCommandPermission(CommandPermission.Extended);
save.setCommandListener(new CommandListener() {
@Override
public void onCommand(CommandBuilder builder, List<CommandArgument> arguments, CommandSender sender) {
World world = Cubes.getServer().world;
if (world.save.readOnly) {
sender.print(Localization.get("command.save.readOnly"));
} else {
sender.print(Localization.get( "command.save.starting"));
Cubes.getServer().world.save();
}
}
});
}
示例6: updatePosition
import ethanjones.cubes.world.World; //导入依赖的package包/类
public void updatePosition(float time) {
if (!inLoadedArea()) return;
World world = Side.getCubes().world;
float r = 0f;
if (!motion.isZero() || !WorldGravity.onBlock(world, position, height, r)) {
position.add(motion.x * time, motion.y * time, motion.z * time);
motion.y -= GRAVITY * time;
if (WorldGravity.onBlock(world, position, height, r) && motion.y < 0) {
position.y = WorldGravity.getBlockY(position, height) + 1 + height;
motion.y = 0f;
}
if (Side.isServer()) world.syncEntity(uuid);
}
}
示例7: randomTick
import ethanjones.cubes.world.World; //导入依赖的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;
}
示例8: checkDirt
import ethanjones.cubes.world.World; //导入依赖的package包/类
private void checkDirt(World world, Area area, int x, int y, int z) {
if (x < 0 || x >= Area.SIZE_BLOCKS || z < 0 || z >= Area.SIZE_BLOCKS) {
Area a = area.neighbourBlockCoordinates(x + area.minBlockX, z + area.minBlockZ);
if (a == null) return;
if (Lock.tryToLock(true, a)) {
int bX = (x + area.minBlockX) - a.minBlockX;
int bZ = (z + area.minBlockZ) - a.minBlockZ;
if (a.getBlock(bX, y, bZ) == Blocks.dirt && validGrass(world, a, bX, y, bZ, false)) {
a.setBlock(Blocks.grass, bX, y, bZ, 0);
}
a.lock.writeUnlock();
}
} else {
if (area.getBlock(x, y, z) == Blocks.dirt && validGrass(world, area, x, y, z, false)) {
area.setBlock(Blocks.grass, x, y, z, 0);
}
}
}
示例9: renderFor
import ethanjones.cubes.world.World; //导入依赖的package包/类
private void renderFor(World world, float deltaTime) {
for (Entity entity : world.entities.values()) {
entity.updatePosition(deltaTime);
if (entity instanceof RenderableProvider)
modelBatch.render(((RenderableProvider) entity));
}
}
示例10: randomTick
import ethanjones.cubes.world.World; //导入依赖的package包/类
@Override
public int randomTick(World world, Area area, int x, int y, int z, int meta) {
if ((world.isDay() && area.getSunlight(x, y + 1, z) >= 10) || area.getLight(x, y + 1, z) >= 10) {
if (meta >= 7) {
new TreeGenerator().generateTree(x + area.minBlockX, y, z + area.minBlockZ,
3 + ThreadRandom.get().nextInt(3), area);
} else {
meta++;
}
}
return meta;
}
示例11: drops
import ethanjones.cubes.world.World; //导入依赖的package包/类
@Override
public ItemStack[] drops(World world, int x, int y, int z, int mtD) {
if (drops == null)
return super.drops(world, x, y, z, mtD);
ItemStack[] itemStacks = new ItemStack[drops[mtD].length]; // TODO
// percentage
// change
// drops
for (int i = 0; i < itemStacks.length; i++) {
itemStacks[i] = drops[mtD][i].convertToItemStack();
}
return itemStacks;
}
示例12: drops
import ethanjones.cubes.world.World; //导入依赖的package包/类
@Override
public ItemStack[] drops(World world, int x, int y, int z, int meta) {
boolean sapling = ThreadRandom.get().nextInt(24) == 0;
boolean leaves = ThreadRandom.get().nextInt(6) == 0;
if (sapling && leaves) {
return new ItemStack[] { new ItemStack(Blocks.sapling.getItemBlock()),
new ItemStack(Blocks.leaves.getItemBlock()) };
} else if (sapling) {
return new ItemStack[] { new ItemStack(Blocks.sapling.getItemBlock()) };
} else if (leaves) {
return new ItemStack[] { new ItemStack(Blocks.leaves.getItemBlock()) };
} else {
return new ItemStack[0];
}
}
示例13: validGrass
import ethanjones.cubes.world.World; //导入依赖的package包/类
private boolean validGrass(World world, Area area, int x, int y, int z, boolean skipTimeCheck) {
Block above = area.getBlock(x, y + 1, z);
int aboveMeta = area.getMeta(x, y + 1, z);
if (above != null && !above.isTransparent(aboveMeta)) {
return false;
} else if (((skipTimeCheck || world.isDay()) && area.getSunlight(x, y + 1, z) >= 10)
|| area.getLight(x, y + 1, z) >= 10) {
return true;
}
return false;
}
示例14: kDirtIf1
import ethanjones.cubes.world.World; //导入依赖的package包/类
kDirtIf1(Area a, int x, Area area, int z, int y, World world) {
if (a == null)
return;
if (Lock.tryToLock(true, a)) {
int bX = (x + area.minBlockX) - a.minBlockX;
int bZ = (z + area.minBlockZ) - a.minBlockZ;
if (a.getBlock(bX, y, bZ) == Blocks.dirt && validGrass(world, a, bX, y, bZ, false)) {
a.setBlock(Blocks.grass, bX, y, bZ, 0);
}
a.lock.writeUnlock();
}
}
示例15: setWorldTransform
import ethanjones.cubes.world.World; //导入依赖的package包/类
public static void setWorldTransform(Renderable renderable, boolean isMoon) {
Vector3 pos = Cubes.getClient().player.position;
int r = 512;
float f = (float) (Cubes.getClient().world.getTime() - (World.MAX_TIME / 4)) / (float) World.MAX_TIME;
if (isMoon) f += 0.5f;
f %= 1;
float x = (float) (pos.x + (r * Math.cos(f * 2 * Math.PI)));
float y = (float) (pos.y + (r * Math.sin(f * 2 * Math.PI)));
float z = pos.z;
renderable.worldTransform.setToTranslation(x, y, z);
renderable.worldTransform.scl(75f);
renderable.worldTransform.rotate(Vector3.Z, (f - 0.25f % 1) * 360);
}