本文整理汇总了Java中cn.nukkit.math.Vector2类的典型用法代码示例。如果您正苦于以下问题:Java Vector2类的具体用法?Java Vector2怎么用?Java Vector2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector2类属于cn.nukkit.math包,在下文中一共展示了Vector2类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addLand
import cn.nukkit.math.Vector2; //导入依赖的package包/类
public int addLand(Position start, Position end, Level level, final String owner, double price, Map<String, Object> options) throws LandOverlapException, LandCountMaximumException{
Land land;
if((land = this.provider.checkOverlap(start, end)) != null){
throw new LandOverlapException("Land is overlapping", land);
}
int max = Integer.MAX_VALUE;
try{
if(this.getConfig().isInt("max-land")){
max = this.getConfig().get("max-land", 1);
}else{
max = Integer.parseInt(this.getConfig().get("max-land", "NaN").toString());
}
}catch(NumberFormatException e){}
long count = this.provider.getAll().values().stream().filter((l) -> l.getOwner().equalsIgnoreCase(owner)).count();
if(count >= max){
throw new LandCountMaximumException("Land is now maximum", max);
}
return this.provider.addLand(new Vector2(start.x, start.z), new Vector2(end.x, end.z), level, 0, owner);
}
示例2: canInteract
import cn.nukkit.math.Vector2; //导入依赖的package包/类
public boolean canInteract(Vector3 pos, double maxDistance, double maxDiff) {
if (this.distanceSquared(pos) > maxDistance * maxDistance) {
return false;
}
Vector2 dV = this.getDirectionPlane();
double dot = dV.dot(new Vector2(this.x, this.z));
double dot1 = dV.dot(new Vector2(pos.x, pos.z));
return (dot1 - dot) >= -maxDiff;
}
示例3: Land
import cn.nukkit.math.Vector2; //导入依赖的package包/类
public Land(int id, Vector2 start, Vector2 end, Level level, String levelName, double price, String owner,
Map<String, Object> options, List<String> invitee){
this.id = id;
this.price = price;
this.owner = owner;
this.invitee = new ArrayList<String>(invitee);
start = start.floor();
end = end.floor();
double startX = start.x, endX = end.x;
double startZ = start.y, endZ = end.y;
if(start.x > end.x){
startX = end.x;
endX = start.x;
}
if(start.y > end.y){
startZ = end.y;
endZ = start.y;
}
this.start = new Vector2(startX, startZ);
this.end = new Vector2(endX, endZ);
this.level = level;
this.levelName = levelName;
options.put("pvp", options.getOrDefault("pvp", false));
options.put("pickup", options.getOrDefault("pickup", false));
options.put("access", options.getOrDefault("access", true));
options.put("hide", options.getOrDefault("hide", false));
options.put("message", options.getOrDefault("message", null));
this.options = new HashMap<String, Object>(options);
}
示例4: placeObject
import cn.nukkit.math.Vector2; //导入依赖的package包/类
public void placeObject(ChunkManager level, int x, int y, int z) {
int clusterSize = this.type.clusterSize;
double angle = this.random.nextFloat() * Math.PI;
Vector2 offset = VectorMath.getDirection2D(angle).multiply(clusterSize).divide(8);
double x1 = x + 8 + offset.x;
double x2 = x + 8 - offset.x;
double z1 = z + 8 + offset.y;
double z2 = z + 8 - offset.y;
double y1 = y + this.random.nextBoundedInt(3) + 2;
double y2 = y + this.random.nextBoundedInt(3) + 2;
for (int count = 0; count <= clusterSize; ++count) {
double seedX = x1 + (x2 - x1) * count / clusterSize;
double seedY = y1 + (y2 - y1) * count / clusterSize;
double seedZ = z1 + (z2 - z1) * count / clusterSize;
double size = ((Math.sin(count * (Math.PI / clusterSize)) + 1) * this.random.nextFloat() * clusterSize / 16 + 1) / 2;
int startX = (int) (seedX - size);
int startY = (int) (seedY - size);
int startZ = (int) (seedZ - size);
int endX = (int) (seedX + size);
int endY = (int) (seedY + size);
int endZ = (int) (seedZ + size);
for (x = startX; x <= endX; ++x) {
double sizeX = (x + 0.5 - seedX) / size;
sizeX *= sizeX;
if (sizeX < 1) {
for (y = startY; y <= endY; ++y) {
double sizeY = (y + 0.5 - seedY) / size;
sizeY *= sizeY;
if (y > 0 && (sizeX + sizeY) < 1) {
for (z = startZ; z <= endZ; ++z) {
double sizeZ = (z + 0.5 - seedZ) / size;
sizeZ *= sizeZ;
if ((sizeX + sizeY + sizeZ) < 1 && level.getBlockIdAt(x, y, z) == replaceId) {
level.setBlockIdAt(x, y, z, this.type.material.getId());
if (this.type.material.getDamage() != 0) {
level.setBlockDataAt(x, y, z, this.type.material.getDamage());
}
}
}
}
}
}
}
}
}
示例5: getDirectionPlane
import cn.nukkit.math.Vector2; //导入依赖的package包/类
public Vector2 getDirectionPlane() {
return (new Vector2((float) (-Math.cos(Math.toRadians(this.yaw) - Math.PI / 2)), (float) (-Math.sin(Math.toRadians(this.yaw) - Math.PI / 2)))).normalize();
}
示例6: placeObject
import cn.nukkit.math.Vector2; //导入依赖的package包/类
public void placeObject(ChunkManager level, int x, int y, int z) {
int clusterSize = this.type.clusterSize;
double angle = this.random.nextFloat() * Math.PI;
Vector2 offset = VectorMath.getDirection2D(angle).multiply(clusterSize).divide(8);
double x1 = x + 8 + offset.x;
double x2 = x + 8 - offset.x;
double z1 = z + 8 + offset.y;
double z2 = z + 8 - offset.y;
double y1 = y + this.random.nextBoundedInt(3) + 2;
double y2 = y + this.random.nextBoundedInt(3) + 2;
for (int count = 0; count <= clusterSize; ++count) {
double seedX = x1 + (x2 - x1) * count / clusterSize;
double seedY = y1 + (y2 - y1) * count / clusterSize;
double seedZ = z1 + (z2 - z1) * count / clusterSize;
double size = ((Math.sin(count * (Math.PI / clusterSize)) + 1) * this.random.nextFloat() * clusterSize / 16 + 1) / 2;
int startX = (int) (seedX - size);
int startY = (int) (seedY - size);
int startZ = (int) (seedZ - size);
int endX = (int) (seedX + size);
int endY = (int) (seedY + size);
int endZ = (int) (seedZ + size);
for (x = startX; x <= endX; ++x) {
double sizeX = (x + 0.5 - seedX) / size;
sizeX *= sizeX;
if (sizeX < 1) {
for (y = startY; y <= endY; ++y) {
double sizeY = (y + 0.5 - seedY) / size;
sizeY *= sizeY;
if (y > 0 && (sizeX + sizeY) < 1) {
for (z = startZ; z <= endZ; ++z) {
double sizeZ = (z + 0.5 - seedZ) / size;
sizeZ *= sizeZ;
if ((sizeX + sizeY + sizeZ) < 1 && level.getBlockIdAt(x, y, z) == 1) {
level.setBlockIdAt(x, y, z, this.type.material.getId());
if (this.type.material.getDamage() != 0) {
level.setBlockDataAt(x, y, z, this.type.material.getDamage());
}
}
}
}
}
}
}
}
}
示例7: getStart
import cn.nukkit.math.Vector2; //导入依赖的package包/类
public Vector2 getStart(){
return new Vector2(start.x, start.y);
}
示例8: getEnd
import cn.nukkit.math.Vector2; //导入依赖的package包/类
public Vector2 getEnd(){
return new Vector2(end.x, end.y);
}
示例9: addLand
import cn.nukkit.math.Vector2; //导入依赖的package包/类
@Override
public int addLand(Vector2 start, Vector2 end, Level level, double price, String owner){
lands.put(landId, new Land(landId, start, end, level, level.getFolderName(), price, owner, new HashMap<String, Object>(),
new ArrayList<String>()));
return landId++;
}
示例10: addLand
import cn.nukkit.math.Vector2; //导入依赖的package包/类
public int addLand(Vector2 start, Vector2 end, Level level, double price, String owner);