本文整理汇总了Java中cn.nukkit.math.MathHelper类的典型用法代码示例。如果您正苦于以下问题:Java MathHelper类的具体用法?Java MathHelper怎么用?Java MathHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MathHelper类属于cn.nukkit.math包,在下文中一共展示了MathHelper类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: moveFlying
import cn.nukkit.math.MathHelper; //导入依赖的package包/类
public void moveFlying(float strafe, float forward, float friction) {
float speed = strafe * strafe + forward * forward;
if (speed >= 1.0E-4F) {
speed = MathHelper.sqrt(speed);
if (speed < 1.0F) {
speed = 1.0F;
}
speed = friction / speed;
strafe *= speed;
forward *= speed;
float nest = MathHelper.sin((float) (this.yaw * 3.1415927F / 180.0F));
float place = MathHelper.cos((float) (this.yaw * 3.1415927F / 180.0F));
this.motionX += strafe * place - forward * nest;
this.motionZ += forward * place + strafe * nest;
}
}
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:17,代码来源:Entity.java
示例2: getDrops
import cn.nukkit.math.MathHelper; //导入依赖的package包/类
@Override
public Item[] getDrops(Item item) {
Random random = new Random();
int count = 2 + random.nextInt(3);
Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
if (fortune != null && fortune.getLevel() >= 1) {
count += random.nextInt(fortune.getLevel() + 1);
}
return new Item[]{
new ItemGlowstoneDust(0, MathHelper.clamp(count, 1, 4))
};
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:15,代码来源:BlockGlowstone.java
示例3: applyEntityCollision
import cn.nukkit.math.MathHelper; //导入依赖的package包/类
public void applyEntityCollision(Entity entity) {
if (entity.riding != this && entity.linkedEntity != this) {
double dx = entity.x - this.x;
double dy = entity.z - this.z;
double dz = NukkitMath.getDirection(dx, dy);
if (dz >= 0.009999999776482582D) {
dz = MathHelper.sqrt((float) dz);
dx /= dz;
dy /= dz;
double d3 = 1.0D / dz;
if (d3 > 1.0D) {
d3 = 1.0D;
}
dx *= d3;
dy *= d3;
dx *= 0.05000000074505806D;
dy *= 0.05000000074505806D;
dx *= 1.0F + entityCollisionReduction;
dz *= 1.0F + entityCollisionReduction;
if (this.riding == null) {
motionX -= dx;
motionZ -= dy;
}
}
}
}
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:30,代码来源:Entity.java
示例4: calculateSkylightSubtracted
import cn.nukkit.math.MathHelper; //导入依赖的package包/类
public int calculateSkylightSubtracted(float tickDiff) {
float angle = this.calculateCelestialAngle(getTime(), tickDiff);
float light = 1 - (MathHelper.cos(angle * ((float) Math.PI * 2F)) * 2 + 0.5f);
light = light < 0 ? 0 : light > 1 ? 1 : light;
light = 1 - light;
light = (float) ((double) light * ((isRaining() ? 1 : 0) - (double) 5f / 16d));
light = (float) ((double) light * ((isThundering() ? 1 : 0) - (double) 5f / 16d));
light = 1 - light;
return (int) (light * 11f);
}
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:11,代码来源:Level.java
示例5: getNextRail
import cn.nukkit.math.MathHelper; //导入依赖的package包/类
private Vector3 getNextRail(double dx, double dy, double dz) {
int checkX = MathHelper.floor(dx);
int checkY = MathHelper.floor(dy);
int checkZ = MathHelper.floor(dz);
if (Rail.isRailBlock(level.getBlockIdAt(checkX, checkY - 1, checkZ))) {
--checkY;
}
Block block = level.getBlock(new Vector3(checkX, checkY, checkZ));
if (Rail.isRailBlock(block)) {
int[][] facing = matrix[((BlockRail) block).getRealMeta()];
double rail;
// Genisys mistake (Doesn't check surrounding more exactly)
double nextOne = (double) checkX + 0.5D + (double) facing[0][0] * 0.5D;
double nextTwo = (double) checkY + 0.5D + (double) facing[0][1] * 0.5D;
double nextThree = (double) checkZ + 0.5D + (double) facing[0][2] * 0.5D;
double nextFour = (double) checkX + 0.5D + (double) facing[1][0] * 0.5D;
double nextFive = (double) checkY + 0.5D + (double) facing[1][1] * 0.5D;
double nextSix = (double) checkZ + 0.5D + (double) facing[1][2] * 0.5D;
double nextSeven = nextFour - nextOne;
double nextEight = (nextFive - nextTwo) * 2;
double nextMax = nextSix - nextThree;
if (nextSeven == 0) {
rail = dz - (double) checkZ;
} else if (nextMax == 0) {
rail = dx - (double) checkX;
} else {
double whatOne = dx - nextOne;
double whatTwo = dz - nextThree;
rail = (whatOne * nextSeven + whatTwo * nextMax) * 2;
}
dx = nextOne + nextSeven * rail;
dy = nextTwo + nextEight * rail;
dz = nextThree + nextMax * rail;
if (nextEight < 0) {
++dy;
}
if (nextEight > 0) {
dy += 0.5D;
}
return new Vector3(dx, dy, dz);
} else {
return null;
}
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:53,代码来源:EntityMinecartAbstract.java
示例6: generate
import cn.nukkit.math.MathHelper; //导入依赖的package包/类
public boolean generate(ChunkManager level, NukkitRandom rand, Vector3 position) {
int height = this.getHeight(rand);
if (!this.ensureGrowable(level, rand, position, height)) {
return false;
} else {
this.createCrown(level, position.up(height), 2);
for (int j = (int) position.getY() + height - 2 - rand.nextBoundedInt(4); j > position.getY() + height / 2; j -= 2 + rand.nextBoundedInt(4)) {
float f = rand.nextFloat() * ((float) Math.PI * 2F);
int k = (int) (position.getX() + (0.5F + MathHelper.cos(f) * 4.0F));
int l = (int) (position.getZ() + (0.5F + MathHelper.sin(f) * 4.0F));
for (int i1 = 0; i1 < 5; ++i1) {
k = (int) (position.getX() + (1.5F + MathHelper.cos(f) * (float) i1));
l = (int) (position.getZ() + (1.5F + MathHelper.sin(f) * (float) i1));
this.setBlockAndNotifyAdequately(level, new Vector3(k, j - 3 + i1 / 2, l), this.woodMetadata);
}
int j2 = 1 + rand.nextBoundedInt(2);
int j1 = j;
for (int k1 = j - j2; k1 <= j1; ++k1) {
int l1 = k1 - j1;
this.growLeavesLayer(level, new Vector3(k, k1, l), 1 - l1);
}
}
for (int i2 = 0; i2 < height; ++i2) {
Vector3 blockpos = position.up(i2);
if (this.canGrowInto(level.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z))) {
this.setBlockAndNotifyAdequately(level, blockpos, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos.west(), 8);
this.placeVine(level, rand, blockpos.north(), 1);
}
}
if (i2 < height - 1) {
Vector3 blockpos1 = blockpos.east();
if (this.canGrowInto(level.getBlockIdAt((int) blockpos1.x, (int) blockpos1.y, (int) blockpos1.z))) {
this.setBlockAndNotifyAdequately(level, blockpos1, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos1.east(), 2);
this.placeVine(level, rand, blockpos1.north(), 1);
}
}
Vector3 blockpos2 = blockpos.south().east();
if (this.canGrowInto(level.getBlockIdAt((int) blockpos2.x, (int) blockpos2.y, (int) blockpos2.z))) {
this.setBlockAndNotifyAdequately(level, blockpos2, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos2.east(), 2);
this.placeVine(level, rand, blockpos2.south(), 4);
}
}
Vector3 blockpos3 = blockpos.south();
if (this.canGrowInto(level.getBlockIdAt((int) blockpos3.x, (int) blockpos3.y, (int) blockpos3.z))) {
this.setBlockAndNotifyAdequately(level, blockpos3, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos3.west(), 8);
this.placeVine(level, rand, blockpos3.south(), 4);
}
}
}
}
return true;
}
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:80,代码来源:ObjectJungleBigTree.java
示例7: ChunkPosition
import cn.nukkit.math.MathHelper; //导入依赖的package包/类
public ChunkPosition(Vector3 vec3d) {
this(MathHelper.floor(vec3d.x), MathHelper.floor(vec3d.y), MathHelper.floor(vec3d.z));
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:4,代码来源:ChunkPosition.java
示例8: generate
import cn.nukkit.math.MathHelper; //导入依赖的package包/类
public boolean generate(ChunkManager level, NukkitRandom rand, Vector3 position) {
int i = this.getHeight(rand);
if (!this.ensureGrowable(level, rand, position, i)) {
return false;
} else {
this.createCrown(level, position.up(i), 2);
for (int j = (int) position.getY() + i - 2 - rand.nextBoundedInt(4); j > position.getY() + i / 2; j -= 2 + rand.nextBoundedInt(4)) {
float f = rand.nextFloat() * ((float) Math.PI * 2F);
int k = (int) (position.getX() + (0.5F + MathHelper.cos(f) * 4.0F));
int l = (int) (position.getZ() + (0.5F + MathHelper.sin(f) * 4.0F));
for (int i1 = 0; i1 < 5; ++i1) {
k = (int) (position.getX() + (1.5F + MathHelper.cos(f) * (float) i1));
l = (int) (position.getZ() + (1.5F + MathHelper.sin(f) * (float) i1));
this.setBlockAndNotifyAdequately(level, new Vector3(k, j - 3 + i1 / 2, l), this.woodMetadata);
}
int j2 = 1 + rand.nextBoundedInt(2);
int j1 = j;
for (int k1 = j - j2; k1 <= j1; ++k1) {
int l1 = k1 - j1;
this.growLeavesLayer(level, new Vector3(k, k1, l), 1 - l1);
}
}
for (int i2 = 0; i2 < i; ++i2) {
Vector3 blockpos = position.up(i2);
if (this.canGrowInto(level.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z))) {
this.setBlockAndNotifyAdequately(level, blockpos, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos.west(), 8);
this.placeVine(level, rand, blockpos.north(), 1);
}
}
if (i2 < i - 1) {
Vector3 blockpos1 = blockpos.east();
if (this.canGrowInto(level.getBlockIdAt((int) blockpos1.x, (int) blockpos1.y, (int) blockpos1.z))) {
this.setBlockAndNotifyAdequately(level, blockpos1, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos1.east(), 2);
this.placeVine(level, rand, blockpos1.north(), 1);
}
}
Vector3 blockpos2 = blockpos.south().east();
if (this.canGrowInto(level.getBlockIdAt((int) blockpos2.x, (int) blockpos2.y, (int) blockpos2.z))) {
this.setBlockAndNotifyAdequately(level, blockpos2, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos2.east(), 2);
this.placeVine(level, rand, blockpos2.south(), 4);
}
}
Vector3 blockpos3 = blockpos.south();
if (this.canGrowInto(level.getBlockIdAt((int) blockpos3.x, (int) blockpos3.y, (int) blockpos3.z))) {
this.setBlockAndNotifyAdequately(level, blockpos3, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos3.west(), 8);
this.placeVine(level, rand, blockpos3.south(), 4);
}
}
}
}
return true;
}
}
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:80,代码来源:NewJungleBigTree.java
示例9: generate
import cn.nukkit.math.MathHelper; //导入依赖的package包/类
public boolean generate(ChunkManager level, NukkitRandom rand, Vector3 position) {
int i = this.getHeight(rand);
if (!this.ensureGrowable(level, rand, position, i)) {
return false;
} else {
this.createCrown(level, position.getSide(Vector3.SIDE_UP, i), 2);
for (int j = (int) position.getY() + i - 2 - rand.nextBoundedInt(4); j > position.getY() + i / 2; j -= 2 + rand.nextBoundedInt(4)) {
float f = rand.nextFloat() * ((float) Math.PI * 2F);
int k = (int) (position.getX() + (0.5F + MathHelper.cos(f) * 4.0F));
int l = (int) (position.getZ() + (0.5F + MathHelper.sin(f) * 4.0F));
for (int i1 = 0; i1 < 5; ++i1) {
k = (int) (position.getX() + (1.5F + MathHelper.cos(f) * (float) i1));
l = (int) (position.getZ() + (1.5F + MathHelper.sin(f) * (float) i1));
this.setBlockAndNotifyAdequately(level, new Vector3(k, j - 3 + i1 / 2, l), this.woodMetadata);
}
int j2 = 1 + rand.nextBoundedInt(2);
int j1 = j;
for (int k1 = j - j2; k1 <= j1; ++k1) {
int l1 = k1 - j1;
this.growLeavesLayer(level, new Vector3(k, k1, l), 1 - l1);
}
}
for (int i2 = 0; i2 < i; ++i2) {
Vector3 blockpos = position.getSide(Vector3.SIDE_UP, i2);
if (this.canGrowInto(level.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z))) {
this.setBlockAndNotifyAdequately(level, blockpos, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos.getSide(Vector3.SIDE_WEST), 8);
this.placeVine(level, rand, blockpos.getSide(Vector3.SIDE_NORTH), 1);
}
}
if (i2 < i - 1) {
Vector3 blockpos1 = blockpos.getSide(Vector3.SIDE_EAST);
if (this.canGrowInto(level.getBlockIdAt((int) blockpos1.x, (int) blockpos1.y, (int) blockpos1.z))) {
this.setBlockAndNotifyAdequately(level, blockpos1, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos1.getSide(Vector3.SIDE_EAST), 2);
this.placeVine(level, rand, blockpos1.getSide(Vector3.SIDE_NORTH), 1);
}
}
Vector3 blockpos2 = blockpos.getSide(Vector3.SIDE_SOUTH).getSide(Vector3.SIDE_EAST);
if (this.canGrowInto(level.getBlockIdAt((int) blockpos2.x, (int) blockpos2.y, (int) blockpos2.z))) {
this.setBlockAndNotifyAdequately(level, blockpos2, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos2.getSide(Vector3.SIDE_EAST), 2);
this.placeVine(level, rand, blockpos2.getSide(Vector3.SIDE_SOUTH), 4);
}
}
Vector3 blockpos3 = blockpos.getSide(Vector3.SIDE_SOUTH);
if (this.canGrowInto(level.getBlockIdAt((int) blockpos3.x, (int) blockpos3.y, (int) blockpos3.z))) {
this.setBlockAndNotifyAdequately(level, blockpos3, this.woodMetadata);
if (i2 > 0) {
this.placeVine(level, rand, blockpos3.getSide(Vector3.SIDE_WEST), 8);
this.placeVine(level, rand, blockpos3.getSide(Vector3.SIDE_SOUTH), 4);
}
}
}
}
return true;
}
}
开发者ID:NycuRO,项目名称:Apollo-OLD,代码行数:80,代码来源:JungleBigTree.java
注:本文中的cn.nukkit.math.MathHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论