本文整理汇总了Java中net.minecraft.util.MathHelper类的典型用法代码示例。如果您正苦于以下问题:Java MathHelper类的具体用法?Java MathHelper怎么用?Java MathHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MathHelper类属于net.minecraft.util包,在下文中一共展示了MathHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updatePower
import net.minecraft.util.MathHelper; //导入依赖的package包/类
public void updatePower(World worldIn, BlockPos pos)
{
if (!worldIn.provider.getHasNoSky())
{
IBlockState iblockstate = worldIn.getBlockState(pos);
int i = worldIn.getLightFor(EnumSkyBlock.SKY, pos) - worldIn.getSkylightSubtracted();
float f = worldIn.getCelestialAngleRadians(1.0F);
float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F);
f = f + (f1 - f) * 0.2F;
i = Math.round((float)i * MathHelper.cos(f));
i = MathHelper.clamp_int(i, 0, 15);
if (this.inverted)
{
i = 15 - i;
}
if (((Integer)iblockstate.getValue(POWER)).intValue() != i)
{
worldIn.setBlockState(pos, iblockstate.withProperty(POWER, Integer.valueOf(i)), 3);
}
}
}
示例2: attackEntityFromPart
import net.minecraft.util.MathHelper; //导入依赖的package包/类
public boolean attackEntityFromPart(EntityDragonPart dragonPart, DamageSource source, float p_70965_3_)
{
if (dragonPart != this.dragonPartHead)
{
p_70965_3_ = p_70965_3_ / 4.0F + 1.0F;
}
float f = this.rotationYaw * (float)Math.PI / 180.0F;
float f1 = MathHelper.sin(f);
float f2 = MathHelper.cos(f);
this.targetX = this.posX + (double)(f1 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F);
this.targetY = this.posY + (double)(this.rand.nextFloat() * 3.0F) + 1.0D;
this.targetZ = this.posZ - (double)(f2 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F);
this.target = null;
if (source.getEntity() instanceof EntityPlayer || source.isExplosion())
{
this.attackDragonFrom(source, p_70965_3_);
}
return true;
}
示例3: handleHookCasting
import net.minecraft.util.MathHelper; //导入依赖的package包/类
public void handleHookCasting(double p_146035_1_, double p_146035_3_, double p_146035_5_, float p_146035_7_, float p_146035_8_)
{
float f = MathHelper.sqrt_double(p_146035_1_ * p_146035_1_ + p_146035_3_ * p_146035_3_ + p_146035_5_ * p_146035_5_);
p_146035_1_ = p_146035_1_ / (double)f;
p_146035_3_ = p_146035_3_ / (double)f;
p_146035_5_ = p_146035_5_ / (double)f;
p_146035_1_ = p_146035_1_ + this.rand.nextGaussian() * 0.007499999832361937D * (double)p_146035_8_;
p_146035_3_ = p_146035_3_ + this.rand.nextGaussian() * 0.007499999832361937D * (double)p_146035_8_;
p_146035_5_ = p_146035_5_ + this.rand.nextGaussian() * 0.007499999832361937D * (double)p_146035_8_;
p_146035_1_ = p_146035_1_ * (double)p_146035_7_;
p_146035_3_ = p_146035_3_ * (double)p_146035_7_;
p_146035_5_ = p_146035_5_ * (double)p_146035_7_;
this.motionX = p_146035_1_;
this.motionY = p_146035_3_;
this.motionZ = p_146035_5_;
float f1 = MathHelper.sqrt_double(p_146035_1_ * p_146035_1_ + p_146035_5_ * p_146035_5_);
this.prevRotationYaw = this.rotationYaw = (float)(MathHelper.func_181159_b(p_146035_1_, p_146035_5_) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float)(MathHelper.func_181159_b(p_146035_3_, (double)f1) * 180.0D / Math.PI);
this.ticksInGround = 0;
}
示例4: update
import net.minecraft.util.MathHelper; //导入依赖的package包/类
/**
* Like the old updateEntity(), except more generic.
*/
public void update()
{
if (this.minecart.isDead)
{
this.donePlaying = true;
}
else
{
this.xPosF = (float)this.minecart.posX;
this.yPosF = (float)this.minecart.posY;
this.zPosF = (float)this.minecart.posZ;
float f = MathHelper.sqrt_double(this.minecart.motionX * this.minecart.motionX + this.minecart.motionZ * this.minecart.motionZ);
if ((double)f >= 0.01D)
{
this.distance = MathHelper.clamp_float(this.distance + 0.0025F, 0.0F, 1.0F);
this.volume = 0.0F + MathHelper.clamp_float(f, 0.0F, 0.5F) * 0.7F;
}
else
{
this.distance = 0.0F;
this.volume = 0.0F;
}
}
}
示例5: getEntitiesWithinAABB
import net.minecraft.util.MathHelper; //导入依赖的package包/类
public <T extends Entity> List<T> getEntitiesWithinAABB(Class <? extends T > clazz, AxisAlignedBB aabb, Predicate <? super T > filter)
{
int i = MathHelper.floor_double((aabb.minX - 2.0D) / 16.0D);
int j = MathHelper.floor_double((aabb.maxX + 2.0D) / 16.0D);
int k = MathHelper.floor_double((aabb.minZ - 2.0D) / 16.0D);
int l = MathHelper.floor_double((aabb.maxZ + 2.0D) / 16.0D);
List<T> list = Lists.<T>newArrayList();
for (int i1 = i; i1 <= j; ++i1)
{
for (int j1 = k; j1 <= l; ++j1)
{
if (this.isChunkLoaded(i1, j1, true))
{
this.getChunkFromChunkCoords(i1, j1).getEntitiesOfTypeWithinAAAB(clazz, aabb, list, filter);
}
}
}
return list;
}
示例6: getStarBrightness
import net.minecraft.util.MathHelper; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public float getStarBrightness(float par1)
{
final float var2 = this.worldObj.getCelestialAngle(par1);
float var3 = 1.0F - (MathHelper.cos(var2 * (float) Math.PI * 2.0F) * 2.0F + 0.25F);
if (var3 < 0.0F)
{
var3 = 0.0F;
}
if (var3 > 1.0F)
{
var3 = 1.0F;
}
return var3 * var3 * 0.5F + 0.3F;
}
示例7: dropMagazine
import net.minecraft.util.MathHelper; //导入依赖的package包/类
private void dropMagazine(World world, ItemStack stack, Entity entity)
{
if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
{
this.setCooldown(stack, 60);
return;
}
ItemStack clipStack = Helper.getAmmoStack(ObsidianMagazine.class, MathHelper.floor_double(stack.getItemDamage() / 2) + 1); // Unloading all ammo into that clip, with some loss
stack.setItemDamage(this.getMaxDamage()); // Emptying out
// Creating the clip
EntityItem entityitem = new EntityItem(world, entity.posX, entity.posY + 1.0d, entity.posZ, clipStack);
entityitem.delayBeforeCanPickup = 10;
// And dropping it
if (entity.captureDrops) { entity.capturedDrops.add(entityitem); }
else { world.spawnEntityInWorld(entityitem); }
// SFX
world.playSoundAtEntity(entity, "random.click", 1.7F, 0.3F);
}
示例8: removeSunnyPath
import net.minecraft.util.MathHelper; //导入依赖的package包/类
/**
* Trims path data from the end to the first sun covered block
*/
protected void removeSunnyPath()
{
super.removeSunnyPath();
if (this.shouldAvoidSun)
{
if (this.worldObj.canSeeSky(new BlockPos(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.getEntityBoundingBox().minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ))))
{
return;
}
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i)
{
PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i);
if (this.worldObj.canSeeSky(new BlockPos(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord)))
{
this.currentPath.setCurrentPathLength(i - 1);
return;
}
}
}
}
示例9: getWeakPower
import net.minecraft.util.MathHelper; //导入依赖的package包/类
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
if (!this.canProvidePower())
{
return 0;
}
else
{
int i = 0;
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityChest)
{
i = ((TileEntityChest)tileentity).numPlayersUsing;
}
return MathHelper.clamp_int(i, 0, 15);
}
}
示例10: onUpdateNavigation
import net.minecraft.util.MathHelper; //导入依赖的package包/类
public void onUpdateNavigation()
{
if (!this.noPath())
{
super.onUpdateNavigation();
}
else
{
if (this.targetPosition != null)
{
double d0 = (double)(this.theEntity.width * this.theEntity.width);
if (this.theEntity.getDistanceSqToCenter(this.targetPosition) >= d0 && (this.theEntity.posY <= (double)this.targetPosition.getY() || this.theEntity.getDistanceSqToCenter(new BlockPos(this.targetPosition.getX(), MathHelper.floor_double(this.theEntity.posY), this.targetPosition.getZ())) >= d0))
{
this.theEntity.getMoveHelper().setMoveTo((double)this.targetPosition.getX(), (double)this.targetPosition.getY(), (double)this.targetPosition.getZ(), this.speed);
}
else
{
this.targetPosition = null;
}
}
}
}
示例11: setRotationAngles
import net.minecraft.util.MathHelper; //导入依赖的package包/类
/**
* Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
* and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
* "far" arms and legs can swing at most.
*/
public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity entityIn)
{
super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, entityIn);
float f = MathHelper.sin(this.swingProgress * (float)Math.PI);
float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float)Math.PI);
this.bipedRightArm.rotateAngleZ = 0.0F;
this.bipedLeftArm.rotateAngleZ = 0.0F;
this.bipedRightArm.rotateAngleY = -(0.1F - f * 0.6F);
this.bipedLeftArm.rotateAngleY = 0.1F - f * 0.6F;
this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F);
this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F);
this.bipedRightArm.rotateAngleX -= f * 1.2F - f1 * 0.4F;
this.bipedLeftArm.rotateAngleX -= f * 1.2F - f1 * 0.4F;
this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F;
this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F;
this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F;
this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F;
}
示例12: EntityThrowable
import net.minecraft.util.MathHelper; //导入依赖的package包/类
public EntityThrowable(World worldIn, EntityLivingBase throwerIn)
{
super(worldIn);
this.thrower = throwerIn;
this.setSize(0.25F, 0.25F);
this.setLocationAndAngles(throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight(), throwerIn.posZ, throwerIn.rotationYaw, throwerIn.rotationPitch);
this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.posY -= 0.10000000149011612D;
this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
this.setPosition(this.posX, this.posY, this.posZ);
float f = 0.4F;
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
this.motionY = (double)(-MathHelper.sin((this.rotationPitch + this.getInaccuracy()) / 180.0F * (float)Math.PI) * f);
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, this.getVelocity(), 1.0F);
}
示例13: updateRotation
import net.minecraft.util.MathHelper; //导入依赖的package包/类
private float updateRotation(float p_75652_1_, float p_75652_2_, float p_75652_3_)
{
float f = MathHelper.wrapAngleTo180_float(p_75652_2_ - p_75652_1_);
if (f > p_75652_3_)
{
f = p_75652_3_;
}
if (f < -p_75652_3_)
{
f = -p_75652_3_;
}
return p_75652_1_ + f;
}
示例14: getFacingFromEntity
import net.minecraft.util.MathHelper; //导入依赖的package包/类
public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn)
{
if (MathHelper.abs((float)entityIn.posX - (float)clickedBlock.getX()) < 2.0F && MathHelper.abs((float)entityIn.posZ - (float)clickedBlock.getZ()) < 2.0F)
{
double d0 = entityIn.posY + (double)entityIn.getEyeHeight();
if (d0 - (double)clickedBlock.getY() > 2.0D)
{
return EnumFacing.UP;
}
if ((double)clickedBlock.getY() - d0 > 0.0D)
{
return EnumFacing.DOWN;
}
}
return entityIn.getHorizontalFacing().getOpposite();
}
示例15: func_181015_d
import net.minecraft.util.MathHelper; //导入依赖的package包/类
public void func_181015_d(BlockPos p_181015_1_)
{
if (this.timeUntilPortal > 0)
{
this.timeUntilPortal = this.getPortalCooldown();
}
else
{
if (!this.worldObj.isRemote && !p_181015_1_.equals(this.field_181016_an))
{
this.field_181016_an = p_181015_1_;
BlockPattern.PatternHelper blockpattern$patternhelper = Blocks.portal.func_181089_f(this.worldObj, p_181015_1_);
double d0 = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? (double)blockpattern$patternhelper.func_181117_a().getZ() : (double)blockpattern$patternhelper.func_181117_a().getX();
double d1 = blockpattern$patternhelper.getFinger().getAxis() == EnumFacing.Axis.X ? this.posZ : this.posX;
d1 = Math.abs(MathHelper.func_181160_c(d1 - (double)(blockpattern$patternhelper.getFinger().rotateY().getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE ? 1 : 0), d0, d0 - (double)blockpattern$patternhelper.func_181118_d()));
double d2 = MathHelper.func_181160_c(this.posY - 1.0D, (double)blockpattern$patternhelper.func_181117_a().getY(), (double)(blockpattern$patternhelper.func_181117_a().getY() - blockpattern$patternhelper.func_181119_e()));
this.field_181017_ao = new Vec3(d1, d2, 0.0D);
this.field_181018_ap = blockpattern$patternhelper.getFinger();
}
this.inPortal = true;
}
}