本文整理汇总了Java中net.minecraft.util.math.MathHelper.abs方法的典型用法代码示例。如果您正苦于以下问题:Java MathHelper.abs方法的具体用法?Java MathHelper.abs怎么用?Java MathHelper.abs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.math.MathHelper
的用法示例。
在下文中一共展示了MathHelper.abs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: searchBox
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static void searchBox(BlockPos blockPos) {
double x = blockPos.getX() - Minecraft.getMinecraft().getRenderManager().renderPosX;
double y = blockPos.getY() - Minecraft.getMinecraft().getRenderManager().renderPosY;
double z = blockPos.getZ() - Minecraft.getMinecraft().getRenderManager().renderPosZ;
GL11.glBlendFunc(770, 771);
GL11.glEnable(GL_BLEND);
GL11.glLineWidth(1.0F);
float sinus = 1F - MathHelper
.abs(MathHelper.sin(Minecraft.getSystemTime() % 10000L / 10000.0F * (float) Math.PI * 4.0F) * 1F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL_DEPTH_TEST);
GL11.glDepthMask(false);
GL11.glColor4f(1F - sinus, sinus, 0F, 0.15F);
drawColorBox(new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0), 1F - sinus, sinus, 0F, 0.15F);
GL11.glColor4d(0, 0, 0, 0.5);
drawSelectionBoundingBox(new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0));
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL_DEPTH_TEST);
GL11.glDepthMask(true);
GL11.glDisable(GL_BLEND);
}
示例2: getGreatestDistance
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Returns the absolute greatest distance in the BlockPos object.
*/
private int getGreatestDistance(BlockPos posIn)
{
int i = MathHelper.abs(posIn.getX());
int j = MathHelper.abs(posIn.getY());
int k = MathHelper.abs(posIn.getZ());
if (k > i && k > j)
{
return k;
}
else
{
return j > i ? j : i;
}
}
示例3: searchBox
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static void searchBox(IBlockPos IBlockPos) {
RenderUtils.fixDarkLight();
GlStateManager.resetColor();
double x = IBlockPos.getX() - Minecraft.getMinecraft().getRenderManager().renderPosX;
double y = IBlockPos.getY() - Minecraft.getMinecraft().getRenderManager().renderPosY;
double z = IBlockPos.getZ() - Minecraft.getMinecraft().getRenderManager().renderPosZ;
GL11.glBlendFunc(770, 771);
GL11.glEnable(3042);
GL11.glLineWidth(1.0F);
float sinus = 1.0F - MathHelper
.abs(MathHelper.sin(Minecraft.getSystemTime() % 10000L / 10000.0F * 3.1415927F * 4.0F) * 1.0F);
GL11.glDisable(3553);
GL11.glDisable(2929);
GL11.glDepthMask(false);
GL11.glColor4f(1.0F - sinus, sinus, 0.0F, 0.15F);
drawColorBox(new AxisAlignedBB(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D), 1.0F - sinus, sinus, 0.0F, 0.15F);
GL11.glColor4d(0.0D, 0.0D, 0.0D, 0.5D);
drawSelectionBoundingBox(new AxisAlignedBB(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D));
GL11.glEnable(3553);
GL11.glEnable(2929);
GL11.glDepthMask(true);
GL11.glDisable(3042);
}
示例4: transformEatFirstPerson
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private void transformEatFirstPerson(float p_187454_1_, EnumHandSide p_187454_2_, ItemStack p_187454_3_)
{
float f = (float)this.mc.player.getItemInUseCount() - p_187454_1_ + 1.0F;
float f1 = f / (float)p_187454_3_.getMaxItemUseDuration();
if (f1 < 0.8F)
{
float f2 = MathHelper.abs(MathHelper.cos(f / 4.0F * (float)Math.PI) * 0.1F);
GlStateManager.translate(0.0F, f2, 0.0F);
}
float f3 = 1.0F - (float)Math.pow((double)f1, 27.0D);
int i = p_187454_2_ == EnumHandSide.RIGHT ? 1 : -1;
GlStateManager.translate(f3 * 0.6F * (float)i, f3 * -0.5F, f3 * 0.0F);
GlStateManager.rotate((float)i * f3 * 90.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(f3 * 10.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate((float)i * f3 * 30.0F, 0.0F, 0.0F, 1.0F);
}
示例5: getFacingFromEntity
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static EnumFacing getFacingFromEntity(BlockPos pos, EntityLivingBase p_185647_1_)
{
if (MathHelper.abs((float)p_185647_1_.posX - (float)pos.getX()) < 2.0F && MathHelper.abs((float)p_185647_1_.posZ - (float)pos.getZ()) < 2.0F)
{
double d0 = p_185647_1_.posY + (double)p_185647_1_.getEyeHeight();
if (d0 - (double)pos.getY() > 2.0D)
{
return EnumFacing.UP;
}
if ((double)pos.getY() - d0 > 0.0D)
{
return EnumFacing.DOWN;
}
}
return p_185647_1_.getHorizontalFacing().getOpposite();
}
示例6: transformEatFirstPerson
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private void transformEatFirstPerson(float p_187454_1_, EnumHandSide p_187454_2_, ItemStack p_187454_3_)
{
float f = (float)this.mc.thePlayer.getItemInUseCount() - p_187454_1_ + 1.0F;
float f1 = f / (float)p_187454_3_.getMaxItemUseDuration();
if (f1 < 0.8F)
{
float f2 = MathHelper.abs(MathHelper.cos(f / 4.0F * (float)Math.PI) * 0.1F);
GlStateManager.translate(0.0F, f2, 0.0F);
}
float f3 = 1.0F - (float)Math.pow((double)f1, 27.0D);
int i = p_187454_2_ == EnumHandSide.RIGHT ? 1 : -1;
GlStateManager.translate(f3 * 0.6F * (float)i, f3 * -0.5F, f3 * 0.0F);
GlStateManager.rotate((float)i * f3 * 90.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(f3 * 10.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate((float)i * f3 * 30.0F, 0.0F, 0.0F, 1.0F);
}
示例7: getGreatestDistance
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Returns the absolute greatest distance in the BlockPos object.
*/
private int getGreatestDistance(BlockPos posIn)
{
int i = MathHelper.abs(posIn.getX());
int j = MathHelper.abs(posIn.getY());
int k = MathHelper.abs(posIn.getZ());
return k > i && k > j ? k : (j > i ? j : i);
}
示例8: parseAngle
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private float parseAngle(JsonObject object)
{
float f = JsonUtils.getFloat(object, "angle");
if (f != 0.0F && MathHelper.abs(f) != 22.5F && MathHelper.abs(f) != 45.0F)
{
throw new JsonParseException("Invalid rotation " + f + " found, only -45/-22.5/0/22.5/45 allowed");
}
else
{
return f;
}
}
示例9: pathFollow
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
protected void pathFollow()
{
Vec3d vec3d = this.getEntityPosition();
int i = this.currentPath.getCurrentPathLength();
for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j)
{
if ((double)this.currentPath.getPathPointFromIndex(j).yCoord != Math.floor(vec3d.yCoord))
{
i = j;
break;
}
}
this.maxDistanceToWaypoint = this.theEntity.width > 0.75F ? this.theEntity.width / 2.0F : 0.75F - this.theEntity.width / 2.0F;
Vec3d vec3d1 = this.currentPath.getCurrentPos();
if (MathHelper.abs((float)(this.theEntity.posX - (vec3d1.xCoord + 0.5D))) < this.maxDistanceToWaypoint && MathHelper.abs((float)(this.theEntity.posZ - (vec3d1.zCoord + 0.5D))) < this.maxDistanceToWaypoint && Math.abs(this.theEntity.posY - vec3d1.yCoord) < 1.0D)
{
this.currentPath.setCurrentPathIndex(this.currentPath.getCurrentPathIndex() + 1);
}
int k = MathHelper.ceil(this.theEntity.width);
int l = MathHelper.ceil(this.theEntity.height);
int i1 = k;
for (int j1 = i - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1)
{
if (this.isDirectPathBetweenPoints(vec3d, this.currentPath.getVectorFromIndex(this.theEntity, j1), k, l, i1))
{
this.currentPath.setCurrentPathIndex(j1);
break;
}
}
this.checkForStuck(vec3d);
}
示例10: pathFollow
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
protected void pathFollow()
{
Vec3d vec3d = this.getEntityPosition();
int i = this.currentPath.getCurrentPathLength();
for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j)
{
if ((double)this.currentPath.getPathPointFromIndex(j).yCoord != Math.floor(vec3d.yCoord))
{
i = j;
break;
}
}
this.maxDistanceToWaypoint = this.theEntity.width > 0.75F ? this.theEntity.width / 2.0F : 0.75F - this.theEntity.width / 2.0F;
Vec3d vec3d1 = this.currentPath.getCurrentPos();
if (MathHelper.abs((float)(this.theEntity.posX - (vec3d1.xCoord + 0.5D))) < this.maxDistanceToWaypoint && MathHelper.abs((float)(this.theEntity.posZ - (vec3d1.zCoord + 0.5D))) < this.maxDistanceToWaypoint && Math.abs(this.theEntity.posY - vec3d1.yCoord) < 1.0D)
{
this.currentPath.setCurrentPathIndex(this.currentPath.getCurrentPathIndex() + 1);
}
int k = MathHelper.ceiling_float_int(this.theEntity.width);
int l = MathHelper.ceiling_float_int(this.theEntity.height);
int i1 = k;
for (int j1 = i - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1)
{
if (this.isDirectPathBetweenPoints(vec3d, this.currentPath.getVectorFromIndex(this.theEntity, j1), k, l, i1))
{
this.currentPath.setCurrentPathIndex(j1);
break;
}
}
this.checkForStuck(vec3d);
}
示例11: generate
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public boolean generate(World worldIn, Random rand, BlockPos position)
{
if (this.spike == null)
{
throw new IllegalStateException("Decoration requires priming with a spike");
}
else
{
int i = this.spike.getRadius();
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(new BlockPos(position.getX() - i, 0, position.getZ() - i), new BlockPos(position.getX() + i, this.spike.getHeight() + 10, position.getZ() + i)))
{
if (blockpos$mutableblockpos.distanceSq((double)position.getX(), (double)blockpos$mutableblockpos.getY(), (double)position.getZ()) <= (double)(i * i + 1) && blockpos$mutableblockpos.getY() < this.spike.getHeight())
{
this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.OBSIDIAN.getDefaultState());
}
else if (blockpos$mutableblockpos.getY() > 65)
{
this.setBlockAndNotifyAdequately(worldIn, blockpos$mutableblockpos, Blocks.AIR.getDefaultState());
}
}
if (this.spike.isGuarded())
{
for (int j = -2; j <= 2; ++j)
{
for (int k = -2; k <= 2; ++k)
{
if (MathHelper.abs(j) == 2 || MathHelper.abs(k) == 2)
{
this.setBlockAndNotifyAdequately(worldIn, new BlockPos(position.getX() + j, this.spike.getHeight(), position.getZ() + k), Blocks.IRON_BARS.getDefaultState());
this.setBlockAndNotifyAdequately(worldIn, new BlockPos(position.getX() + j, this.spike.getHeight() + 1, position.getZ() + k), Blocks.IRON_BARS.getDefaultState());
this.setBlockAndNotifyAdequately(worldIn, new BlockPos(position.getX() + j, this.spike.getHeight() + 2, position.getZ() + k), Blocks.IRON_BARS.getDefaultState());
}
this.setBlockAndNotifyAdequately(worldIn, new BlockPos(position.getX() + j, this.spike.getHeight() + 3, position.getZ() + k), Blocks.IRON_BARS.getDefaultState());
}
}
}
EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(worldIn);
entityendercrystal.setBeamTarget(this.beamTarget);
entityendercrystal.setEntityInvulnerable(this.crystalInvulnerable);
entityendercrystal.setLocationAndAngles((double)((float)position.getX() + 0.5F), (double)(this.spike.getHeight() + 1), (double)((float)position.getZ() + 0.5F), rand.nextFloat() * 360.0F, 0.0F);
worldIn.spawnEntityInWorld(entityendercrystal);
this.setBlockAndNotifyAdequately(worldIn, new BlockPos(position.getX(), this.spike.getHeight(), position.getZ()), Blocks.BEDROCK.getDefaultState());
return true;
}
}
示例12: getIslandHeightValue
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private float getIslandHeightValue(int p_185960_1_, int p_185960_2_, int p_185960_3_, int p_185960_4_)
{
float f = (float)(p_185960_1_ * 2 + p_185960_3_);
float f1 = (float)(p_185960_2_ * 2 + p_185960_4_);
float f2 = 100.0F - MathHelper.sqrt(f * f + f1 * f1) * 8.0F;
if (f2 > 80.0F)
{
f2 = 80.0F;
}
if (f2 < -100.0F)
{
f2 = -100.0F;
}
for (int i = -12; i <= 12; ++i)
{
for (int j = -12; j <= 12; ++j)
{
long k = (long)(p_185960_1_ + i);
long l = (long)(p_185960_2_ + j);
if (k * k + l * l > 4096L && this.islandNoise.getValue((double)k, (double)l) < -0.8999999761581421D)
{
float f3 = (MathHelper.abs((float)k) * 3439.0F + MathHelper.abs((float)l) * 147.0F) % 13.0F + 9.0F;
f = (float)(p_185960_3_ - i * 2);
f1 = (float)(p_185960_4_ - j * 2);
float f4 = 100.0F - MathHelper.sqrt(f * f + f1 * f1) * f3;
if (f4 > 80.0F)
{
f4 = 80.0F;
}
if (f4 < -100.0F)
{
f4 = -100.0F;
}
if (f4 > f2)
{
f2 = f4;
}
}
}
}
return f2;
}
示例13: abs
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static float abs(float p_abs_0_)
{
return MathHelper.abs(p_abs_0_);
}
示例14: equalsDelta
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private boolean equalsDelta(float p_equalsDelta_1_, float p_equalsDelta_2_, float p_equalsDelta_3_)
{
float f = MathHelper.abs(p_equalsDelta_1_ - p_equalsDelta_2_);
return f < p_equalsDelta_3_;
}
示例15: getIslandHeightValue
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private float getIslandHeightValue(int p_185960_1_, int p_185960_2_, int p_185960_3_, int p_185960_4_)
{
float f = (float)(p_185960_1_ * 2 + p_185960_3_);
float f1 = (float)(p_185960_2_ * 2 + p_185960_4_);
float f2 = 100.0F - MathHelper.sqrt_float(f * f + f1 * f1) * 8.0F;
if (f2 > 80.0F)
{
f2 = 80.0F;
}
if (f2 < -100.0F)
{
f2 = -100.0F;
}
for (int i = -12; i <= 12; ++i)
{
for (int j = -12; j <= 12; ++j)
{
long k = (long)(p_185960_1_ + i);
long l = (long)(p_185960_2_ + j);
if (k * k + l * l > 4096L && this.islandNoise.getValue((double)k, (double)l) < -0.8999999761581421D)
{
float f3 = (MathHelper.abs((float)k) * 3439.0F + MathHelper.abs((float)l) * 147.0F) % 13.0F + 9.0F;
f = (float)(p_185960_3_ - i * 2);
f1 = (float)(p_185960_4_ - j * 2);
float f4 = 100.0F - MathHelper.sqrt_float(f * f + f1 * f1) * f3;
if (f4 > 80.0F)
{
f4 = 80.0F;
}
if (f4 < -100.0F)
{
f4 = -100.0F;
}
if (f4 > f2)
{
f2 = f4;
}
}
}
}
return f2;
}