当前位置: 首页>>代码示例>>Java>>正文


Java CoordinateConverter.block方法代码示例

本文整理汇总了Java中ethanjones.cubes.world.CoordinateConverter.block方法的典型用法代码示例。如果您正苦于以下问题:Java CoordinateConverter.block方法的具体用法?Java CoordinateConverter.block怎么用?Java CoordinateConverter.block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ethanjones.cubes.world.CoordinateConverter的用法示例。


在下文中一共展示了CoordinateConverter.block方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:24,代码来源:PlayerCollision.java

示例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);
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:23,代码来源:PlayerCollision.java

示例3: 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;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:26,代码来源:ItemEntity.java

示例4: 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;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:8,代码来源:BlockReference.java

示例5: 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;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:8,代码来源:BlockReference.java

示例6: updateIf

import ethanjones.cubes.world.CoordinateConverter; //导入方法依赖的package包/类
private void updateIf() {
	if (itemStack.item == Blocks.sapling.getItemBlock() && itemStack.count == 1) {
		int x = CoordinateConverter.block(position.x);
		int y = CoordinateConverter.block(position.y);
		int 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);
		}
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:11,代码来源:ItemEntity.java

示例7: 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;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:8,代码来源:BlockReference.java

示例8: 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;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:8,代码来源:BlockReference.java

示例9: check

import ethanjones.cubes.world.CoordinateConverter; //导入方法依赖的package包/类
private boolean check(Vector3 position, float xOffset, float yOffset, float zOffset) {
	int x = CoordinateConverter.block(position.x + xOffset);
	int y = CoordinateConverter.block(position.y + yOffset);
	int z = CoordinateConverter.block(position.z + zOffset);
	return world.getBlock(x, y, z) != null;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:7,代码来源:PlayerCollision.java

示例10: getBlockY

import ethanjones.cubes.world.CoordinateConverter; //导入方法依赖的package包/类
public static int getBlockY(Vector3 pos, float height) {
  float f = pos.y - height;
  return CoordinateConverter.block(f - 0.01f);
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:5,代码来源:WorldGravity.java

示例11: check

import ethanjones.cubes.world.CoordinateConverter; //导入方法依赖的package包/类
private boolean check(Vector3 position, float xOffset, float yOffset, float zOffset) {
  int x = CoordinateConverter.block(position.x + xOffset);
  int y = CoordinateConverter.block(position.y + yOffset);
  int z = CoordinateConverter.block(position.z + zOffset);
  return world.getBlock(x, y, z) != null;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:7,代码来源:PlayerCollision.java


注:本文中的ethanjones.cubes.world.CoordinateConverter.block方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。