Java Code Examples for net.minecraft.util.MathHelper

The following are top voted examples for showing how to use net.minecraft.util.MathHelper. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: BaseClient   File: MovingSoundMinecart.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example 2
Project: BaseClient   File: EntityDragon.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 3
Project: BaseClient   File: World.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 4
Project: TRAPPIST-1   File: WorldProviderTrappistOneB.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 5
Project: minecraft-quiverbow   File: OSP.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 6
Project: BaseClient   File: EntityThrowable.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 7
Project: BaseClient   File: EntityLookHelper.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 8
Project: BaseClient   File: EntityFishHook.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 9
Project: BaseClient   File: BlockPistonBase.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 10
Project: BaseClient   File: BlockPistonBase.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 11
Project: BaseClient   File: Entity.java   Source Code and License 6 votes vote down vote up
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;
    }
}
 
Example 12
Project: BaseClient   File: EntityEnderCrystal.java   Source Code and License 6 votes vote down vote up
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    ++this.innerRotation;
    this.dataWatcher.updateObject(8, Integer.valueOf(this.health));
    int i = MathHelper.floor_double(this.posX);
    int j = MathHelper.floor_double(this.posY);
    int k = MathHelper.floor_double(this.posZ);

    if (this.worldObj.provider instanceof WorldProviderEnd && this.worldObj.getBlockState(new BlockPos(i, j, k)).getBlock() != Blocks.fire)
    {
        this.worldObj.setBlockState(new BlockPos(i, j, k), Blocks.fire.getDefaultState());
    }
}
 
Example 13
Project: BaseClient   File: EntityFallingBlock.java   Source Code and License 5 votes vote down vote up
public void fall(float distance, float damageMultiplier)
{
    Block block = this.fallTile.getBlock();

    if (this.hurtEntities)
    {
        int i = MathHelper.ceiling_float_int(distance - 1.0F);

        if (i > 0)
        {
            List<Entity> list = Lists.newArrayList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox()));
            boolean flag = block == Blocks.anvil;
            DamageSource damagesource = flag ? DamageSource.anvil : DamageSource.fallingBlock;

            for (Entity entity : list)
            {
                entity.attackEntityFrom(damagesource, (float)Math.min(MathHelper.floor_float((float)i * this.fallHurtAmount), this.fallHurtMax));
            }

            if (flag && (double)this.rand.nextFloat() < 0.05000000074505806D + (double)i * 0.05D)
            {
                int j = ((Integer)this.fallTile.getValue(BlockAnvil.DAMAGE)).intValue();
                ++j;

                if (j > 2)
                {
                    this.canSetAsBlock = true;
                }
                else
                {
                    this.fallTile = this.fallTile.withProperty(BlockAnvil.DAMAGE, Integer.valueOf(j));
                }
            }
        }
    }
}
 
Example 14
Project: BaseClient   File: WorldProvider.java   Source Code and License 5 votes vote down vote up
/**
 * Return Vec3D with biome specific fog color
 */
public Vec3 getFogColor(float p_76562_1_, float p_76562_2_)
{
    float f = MathHelper.cos(p_76562_1_ * (float)Math.PI * 2.0F) * 2.0F + 0.5F;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    float f1 = 0.7529412F;
    float f2 = 0.84705883F;
    float f3 = 1.0F;
    f1 = f1 * (f * 0.94F + 0.06F);
    f2 = f2 * (f * 0.94F + 0.06F);
    f3 = f3 * (f * 0.91F + 0.09F);
    return new Vec3((double)f1, (double)f2, (double)f3);
}
 
Example 15
Project: BaseClient   File: EntityFireball.java   Source Code and License 5 votes vote down vote up
public EntityFireball(World worldIn, double x, double y, double z, double accelX, double accelY, double accelZ)
{
    super(worldIn);
    this.setSize(1.0F, 1.0F);
    this.setLocationAndAngles(x, y, z, this.rotationYaw, this.rotationPitch);
    this.setPosition(x, y, z);
    double d0 = (double)MathHelper.sqrt_double(accelX * accelX + accelY * accelY + accelZ * accelZ);
    this.accelerationX = accelX / d0 * 0.1D;
    this.accelerationY = accelY / d0 * 0.1D;
    this.accelerationZ = accelZ / d0 * 0.1D;
}
 
Example 16
Project: BaseClient   File: World.java   Source Code and License 5 votes vote down vote up
/**
 * Returns if any of the blocks within the aabb are liquids. Args: aabb
 */
public boolean isAnyLiquid(AxisAlignedBB bb)
{
    int i = MathHelper.floor_double(bb.minX);
    int j = MathHelper.floor_double(bb.maxX);
    int k = MathHelper.floor_double(bb.minY);
    int l = MathHelper.floor_double(bb.maxY);
    int i1 = MathHelper.floor_double(bb.minZ);
    int j1 = MathHelper.floor_double(bb.maxZ);
    BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

    for (int k1 = i; k1 <= j; ++k1)
    {
        for (int l1 = k; l1 <= l; ++l1)
        {
            for (int i2 = i1; i2 <= j1; ++i2)
            {
                Block block = this.getBlockState(blockpos$mutableblockpos.func_181079_c(k1, l1, i2)).getBlock();

                if (block.getMaterial().isLiquid())
                {
                    return true;
                }
            }
        }
    }

    return false;
}
 
Example 17
Project: BaseClient   File: S2CPacketSpawnGlobalEntity.java   Source Code and License 5 votes vote down vote up
public S2CPacketSpawnGlobalEntity(Entity entityIn)
{
    this.entityId = entityIn.getEntityId();
    this.x = MathHelper.floor_double(entityIn.posX * 32.0D);
    this.y = MathHelper.floor_double(entityIn.posY * 32.0D);
    this.z = MathHelper.floor_double(entityIn.posZ * 32.0D);

    if (entityIn instanceof EntityLightningBolt)
    {
        this.type = 1;
    }
}
 
Example 18
Project: BaseClient   File: Entity.java   Source Code and License 5 votes vote down vote up
public Entity(World worldIn)
{
    this.entityId = nextEntityID++;
    this.renderDistanceWeight = 1.0D;
    this.boundingBox = ZERO_AABB;
    this.width = 0.6F;
    this.height = 1.8F;
    this.nextStepDistance = 1;
    this.rand = new Random();
    this.fireResistance = 1;
    this.firstUpdate = true;
    this.entityUniqueID = MathHelper.getRandomUuid(this.rand);
    this.cmdResultStats = new CommandResultStats();
    this.worldObj = worldIn;
    this.setPosition(0.0D, 0.0D, 0.0D);

    if (worldIn != null)
    {
        this.dimension = worldIn.provider.getDimensionId();
    }

    this.dataWatcher = new DataWatcher(this);
    this.dataWatcher.addObject(0, Byte.valueOf((byte)0));
    this.dataWatcher.addObject(1, Short.valueOf((short)300));
    this.dataWatcher.addObject(3, Byte.valueOf((byte)0));
    this.dataWatcher.addObject(2, "");
    this.dataWatcher.addObject(4, Byte.valueOf((byte)0));
    this.entityInit();
}
 
Example 19
Project: BaseClient   File: EntityChicken.java   Source Code and License 5 votes vote down vote up
public void updateRiderPosition()
{
    super.updateRiderPosition();
    float f = MathHelper.sin(this.renderYawOffset * (float)Math.PI / 180.0F);
    float f1 = MathHelper.cos(this.renderYawOffset * (float)Math.PI / 180.0F);
    float f2 = 0.1F;
    float f3 = 0.0F;
    this.riddenByEntity.setPosition(this.posX + (double)(f2 * f), this.posY + (double)(this.height * 0.5F) + this.riddenByEntity.getYOffset() + (double)f3, this.posZ - (double)(f2 * f1));

    if (this.riddenByEntity instanceof EntityLivingBase)
    {
        ((EntityLivingBase)this.riddenByEntity).renderYawOffset = this.renderYawOffset;
    }
}
 
Example 20
Project: BaseClient   File: RenderEnderCrystal.java   Source Code and License 5 votes vote down vote up
/**
 * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
 * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
 * (Render<T extends Entity>) and this method has signature public void doRender(T entity, double d, double d1,
 * double d2, float f, float f1). But JAD is pre 1.5 so doe
 */
public void doRender(EntityEnderCrystal entity, double x, double y, double z, float entityYaw, float partialTicks)
{
    float f = (float)entity.innerRotation + partialTicks;
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)x, (float)y, (float)z);
    this.bindTexture(enderCrystalTextures);
    float f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F;
    f1 = f1 * f1 + f1;
    this.modelEnderCrystal.render(entity, 0.0F, f * 3.0F, f1 * 0.2F, 0.0F, 0.0F, 0.0625F);
    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
 
Example 21
Project: BaseClient   File: RenderGlobal.java   Source Code and License 5 votes vote down vote up
private RenderChunk func_181562_a(BlockPos p_181562_1_, RenderChunk p_181562_2_, EnumFacing p_181562_3_)
{
    BlockPos blockpos = p_181562_2_.getPositionOffset16(p_181562_3_);

    if (blockpos.getY() >= 0 && blockpos.getY() < 256)
    {
        int i = MathHelper.abs_int(p_181562_1_.getX() - blockpos.getX());
        int j = MathHelper.abs_int(p_181562_1_.getZ() - blockpos.getZ());

        if (Config.isFogOff())
        {
            if (i > this.renderDistance || j > this.renderDistance)
            {
                return null;
            }
        }
        else
        {
            int k = i * i + j * j;

            if (k > this.renderDistanceSq)
            {
                return null;
            }
        }

        return this.viewFrustum.getRenderChunk(blockpos);
    }
    else
    {
        return null;
    }
}
 
Example 22
Project: BaseClient   File: EntitySmokeFX.java   Source Code and License 5 votes vote down vote up
/**
 * Renders the particle
 */
public void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float p_180434_4_, float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_)
{
    float f = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    this.particleScale = this.smokeParticleScale * f;
    super.renderParticle(worldRendererIn, entityIn, partialTicks, p_180434_4_, p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_);
}
 
Example 23
Project: BaseClient   File: PathPoint.java   Source Code and License 5 votes vote down vote up
/**
 * Returns the linear distance to another path point
 */
public float distanceTo(PathPoint pathpointIn)
{
    float f = (float)(pathpointIn.xCoord - this.xCoord);
    float f1 = (float)(pathpointIn.yCoord - this.yCoord);
    float f2 = (float)(pathpointIn.zCoord - this.zCoord);
    return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2);
}
 
Example 24
Project: TextDisplayer   File: ModernTextBox.java   Source Code and License 5 votes vote down vote up
/**
 * sets the position of the cursor to the provided index
 */
public void setCursorPosition(int position) {
    this.cursorPosition = position;
    int i = this.text.length();
    this.cursorPosition = MathHelper.clamp_int(this.cursorPosition, 0, i);
    this.setSelectionPos(this.cursorPosition);
}
 
Example 25
Project: BaseClient   File: Entity.java   Source Code and License 5 votes vote down vote up
/**
 * Checks if this entity is inside of an opaque block
 */
public boolean isEntityInsideOpaqueBlock()
{
    if (this.noClip)
    {
        return false;
    }
    else
    {
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);

        for (int i = 0; i < 8; ++i)
        {
            int j = MathHelper.floor_double(this.posY + (double)(((float)((i >> 0) % 2) - 0.5F) * 0.1F) + (double)this.getEyeHeight());
            int k = MathHelper.floor_double(this.posX + (double)(((float)((i >> 1) % 2) - 0.5F) * this.width * 0.8F));
            int l = MathHelper.floor_double(this.posZ + (double)(((float)((i >> 2) % 2) - 0.5F) * this.width * 0.8F));

            if (blockpos$mutableblockpos.getX() != k || blockpos$mutableblockpos.getY() != j || blockpos$mutableblockpos.getZ() != l)
            {
                blockpos$mutableblockpos.func_181079_c(k, j, l);

                if (this.worldObj.getBlockState(blockpos$mutableblockpos).getBlock().isVisuallyOpaque())
                {
                    return true;
                }
            }
        }

        return false;
    }
}
 
Example 26
Project: BaseClient   File: EntityMoveHelper.java   Source Code and License 5 votes vote down vote up
/**
 * Limits the given angle to a upper and lower limit.
 */
protected float limitAngle(float p_75639_1_, float p_75639_2_, float p_75639_3_)
{
    float f = MathHelper.wrapAngleTo180_float(p_75639_2_ - p_75639_1_);

    if (f > p_75639_3_)
    {
        f = p_75639_3_;
    }

    if (f < -p_75639_3_)
    {
        f = -p_75639_3_;
    }

    float f1 = p_75639_1_ + f;

    if (f1 < 0.0F)
    {
        f1 += 360.0F;
    }
    else if (f1 > 360.0F)
    {
        f1 -= 360.0F;
    }

    return f1;
}
 
Example 27
Project: connor41-etfuturum2   File: PlacedEndCrystalRenderer.java   Source Code and License 5 votes vote down vote up
@Override
public void doRender(EntityEnderCrystal crystal, double x, double y, double z, float p_76986_8_, float partialTickTime) {
	float rotation = crystal.innerRotation + partialTickTime;
	OpenGLHelper.pushMatrix();
	OpenGLHelper.translate(x, y, z);
	bindTexture(TEXTURE);
	float f3 = MathHelper.sin(rotation * 0.2F) / 2.0F + 0.5F;
	f3 += f3 * f3;
	MODEL.render(crystal, 0.0F, rotation * 3.0F, f3 * 0.2F, 0.0F, 0.0F, 0.0625F);
	OpenGLHelper.popMatrix();
}
 
Example 28
Project: BaseClient   File: PathPoint.java   Source Code and License 5 votes vote down vote up
/**
 * Returns the linear distance to another path point
 */
public float distanceTo(PathPoint pathpointIn)
{
    float f = (float)(pathpointIn.xCoord - this.xCoord);
    float f1 = (float)(pathpointIn.yCoord - this.yCoord);
    float f2 = (float)(pathpointIn.zCoord - this.zCoord);
    return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2);
}
 
Example 29
Project: BaseClient   File: World.java   Source Code and License 5 votes vote down vote up
/**
 * Returns true if the given bounding box contains the given material
 */
public boolean isMaterialInBB(AxisAlignedBB bb, Material materialIn)
{
    int i = MathHelper.floor_double(bb.minX);
    int j = MathHelper.floor_double(bb.maxX + 1.0D);
    int k = MathHelper.floor_double(bb.minY);
    int l = MathHelper.floor_double(bb.maxY + 1.0D);
    int i1 = MathHelper.floor_double(bb.minZ);
    int j1 = MathHelper.floor_double(bb.maxZ + 1.0D);
    BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

    for (int k1 = i; k1 < j; ++k1)
    {
        for (int l1 = k; l1 < l; ++l1)
        {
            for (int i2 = i1; i2 < j1; ++i2)
            {
                if (this.getBlockState(blockpos$mutableblockpos.func_181079_c(k1, l1, i2)).getBlock().getMaterial() == materialIn)
                {
                    return true;
                }
            }
        }
    }

    return false;
}
 
Example 30
Project: BaseClient   File: EntityHorse.java   Source Code and License 5 votes vote down vote up
public void fall(float distance, float damageMultiplier)
{
    if (distance > 1.0F)
    {
        this.playSound("mob.horse.land", 0.4F, 1.0F);
    }

    int i = MathHelper.ceiling_float_int((distance * 0.5F - 3.0F) * damageMultiplier);

    if (i > 0)
    {
        this.attackEntityFrom(DamageSource.fall, (float)i);

        if (this.riddenByEntity != null)
        {
            this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float)i);
        }

        Block block = this.worldObj.getBlockState(new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ)).getBlock();

        if (block.getMaterial() != Material.air && !this.isSilent())
        {
            Block.SoundType block$soundtype = block.stepSound;
            this.worldObj.playSoundAtEntity(this, block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F);
        }
    }
}
 
Example 31
Project: BaseClient   File: EntityHorse.java   Source Code and License 5 votes vote down vote up
public void fall(float distance, float damageMultiplier)
{
    if (distance > 1.0F)
    {
        this.playSound("mob.horse.land", 0.4F, 1.0F);
    }

    int i = MathHelper.ceiling_float_int((distance * 0.5F - 3.0F) * damageMultiplier);

    if (i > 0)
    {
        this.attackEntityFrom(DamageSource.fall, (float)i);

        if (this.riddenByEntity != null)
        {
            this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float)i);
        }

        Block block = this.worldObj.getBlockState(new BlockPos(this.posX, this.posY - 0.2D - (double)this.prevRotationYaw, this.posZ)).getBlock();

        if (block.getMaterial() != Material.air && !this.isSilent())
        {
            Block.SoundType block$soundtype = block.stepSound;
            this.worldObj.playSoundAtEntity(this, block$soundtype.getStepSound(), block$soundtype.getVolume() * 0.5F, block$soundtype.getFrequency() * 0.75F);
        }
    }
}
 
Example 32
Project: BaseClient   File: ModelBlaze.java   Source Code and License 5 votes vote down vote up
/**
 * 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)
{
    float f = p_78087_3_ * (float)Math.PI * -0.1F;

    for (int i = 0; i < 4; ++i)
    {
        this.blazeSticks[i].rotationPointY = -2.0F + MathHelper.cos(((float)(i * 2) + p_78087_3_) * 0.25F);
        this.blazeSticks[i].rotationPointX = MathHelper.cos(f) * 9.0F;
        this.blazeSticks[i].rotationPointZ = MathHelper.sin(f) * 9.0F;
        ++f;
    }

    f = ((float)Math.PI / 4F) + p_78087_3_ * (float)Math.PI * 0.03F;

    for (int j = 4; j < 8; ++j)
    {
        this.blazeSticks[j].rotationPointY = 2.0F + MathHelper.cos(((float)(j * 2) + p_78087_3_) * 0.25F);
        this.blazeSticks[j].rotationPointX = MathHelper.cos(f) * 7.0F;
        this.blazeSticks[j].rotationPointZ = MathHelper.sin(f) * 7.0F;
        ++f;
    }

    f = 0.47123894F + p_78087_3_ * (float)Math.PI * -0.05F;

    for (int k = 8; k < 12; ++k)
    {
        this.blazeSticks[k].rotationPointY = 11.0F + MathHelper.cos(((float)k * 1.5F + p_78087_3_) * 0.5F);
        this.blazeSticks[k].rotationPointX = MathHelper.cos(f) * 5.0F;
        this.blazeSticks[k].rotationPointZ = MathHelper.sin(f) * 5.0F;
        ++f;
    }

    this.blazeHead.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI);
    this.blazeHead.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI);
}
 
Example 33
Project: connor41-etfuturum2   File: EntityAICustomDoorInteract.java   Source Code and License 5 votes vote down vote up
@Override
public boolean shouldExecute() {
	if (!theEntity.isCollidedHorizontally)
		return false;
	else {
		PathNavigate pathnavigate = theEntity.getNavigator();
		PathEntity pathentity = pathnavigate.getPath();

		if (pathentity != null && !pathentity.isFinished() && pathnavigate.getCanBreakDoors()) {
			for (int i = 0; i < Math.min(pathentity.getCurrentPathIndex() + 2, pathentity.getCurrentPathLength()); ++i) {
				PathPoint pathpoint = pathentity.getPathPointFromIndex(i);
				entityPosX = pathpoint.xCoord;
				entityPosY = pathpoint.yCoord + 1;
				entityPosZ = pathpoint.zCoord;

				if (theEntity.getDistanceSq(entityPosX, theEntity.posY, entityPosZ) <= 2.25D) {
					field_151504_e = func_151503_a(entityPosX, entityPosY, entityPosZ);

					if (field_151504_e != null)
						return true;
				}
			}

			entityPosX = MathHelper.floor_double(theEntity.posX);
			entityPosY = MathHelper.floor_double(theEntity.posY + 1.0D);
			entityPosZ = MathHelper.floor_double(theEntity.posZ);
			field_151504_e = func_151503_a(entityPosX, entityPosY, entityPosZ);
			return field_151504_e != null;
		} else
			return false;
	}
}
 
Example 34
Project: BaseClient   File: RenderGlobal.java   Source Code and License 5 votes vote down vote up
private RenderChunk func_181562_a(BlockPos p_181562_1_, RenderChunk p_181562_2_, EnumFacing p_181562_3_)
{
    BlockPos blockpos = p_181562_2_.getPositionOffset16(p_181562_3_);

    if (blockpos.getY() >= 0 && blockpos.getY() < 256)
    {
        int i = MathHelper.abs_int(p_181562_1_.getX() - blockpos.getX());
        int j = MathHelper.abs_int(p_181562_1_.getZ() - blockpos.getZ());

        if (Config.isFogOff())
        {
            if (i > this.renderDistance || j > this.renderDistance)
            {
                return null;
            }
        }
        else
        {
            int k = i * i + j * j;

            if (k > this.renderDistanceSq)
            {
                return null;
            }
        }

        return this.viewFrustum.getRenderChunk(blockpos);
    }
    else
    {
        return null;
    }
}
 
Example 35
Project: BaseClient   File: EntityCrit2FX.java   Source Code and License 5 votes vote down vote up
/**
 * Renders the particle
 */
public void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float p_180434_4_, float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_)
{
    float f = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
    f = MathHelper.clamp_float(f, 0.0F, 1.0F);
    this.particleScale = this.field_174839_a * f;
    super.renderParticle(worldRendererIn, entityIn, partialTicks, p_180434_4_, p_180434_5_, p_180434_6_, p_180434_7_, p_180434_8_);
}
 
Example 36
Project: BaseClient   File: RenderTNTPrimed.java   Source Code and License 4 votes vote down vote up
/**
 * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
 * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
 * (Render<T extends Entity>) and this method has signature public void doRender(T entity, double d, double d1,
 * double d2, float f, float f1). But JAD is pre 1.5 so doe
 */
public void doRender(EntityTNTPrimed entity, double x, double y, double z, float entityYaw, float partialTicks)
{
    BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)x, (float)y + 0.5F, (float)z);

    if ((float)entity.fuse - partialTicks + 1.0F < 10.0F)
    {
        float f = 1.0F - ((float)entity.fuse - partialTicks + 1.0F) / 10.0F;
        f = MathHelper.clamp_float(f, 0.0F, 1.0F);
        f = f * f;
        f = f * f;
        float f1 = 1.0F + f * 0.3F;
        GlStateManager.scale(f1, f1, f1);
    }

    float f2 = (1.0F - ((float)entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F;
    this.bindEntityTexture(entity);
    GlStateManager.translate(-0.5F, -0.5F, 0.5F);
    blockrendererdispatcher.renderBlockBrightness(Blocks.tnt.getDefaultState(), entity.getBrightness(partialTicks));
    GlStateManager.translate(0.0F, 0.0F, 1.0F);

    if (entity.fuse / 5 % 2 == 0)
    {
        GlStateManager.disableTexture2D();
        GlStateManager.disableLighting();
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(770, 772);
        GlStateManager.color(1.0F, 1.0F, 1.0F, f2);
        GlStateManager.doPolygonOffset(-3.0F, -3.0F);
        GlStateManager.enablePolygonOffset();
        blockrendererdispatcher.renderBlockBrightness(Blocks.tnt.getDefaultState(), 1.0F);
        GlStateManager.doPolygonOffset(0.0F, 0.0F);
        GlStateManager.disablePolygonOffset();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.disableBlend();
        GlStateManager.enableLighting();
        GlStateManager.enableTexture2D();
    }

    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
 
Example 37
Project: BaseClient   File: EntityRenderer.java   Source Code and License 4 votes vote down vote up
/**
 * Updates the entity renderer
 */
public void updateRenderer()
{
    if (OpenGlHelper.shadersSupported && ShaderLinkHelper.getStaticShaderLinkHelper() == null)
    {
        ShaderLinkHelper.setNewStaticShaderLinkHelper();
    }

    this.updateFovModifierHand();
    this.updateTorchFlicker();
    this.fogColor2 = this.fogColor1;
    this.thirdPersonDistanceTemp = this.thirdPersonDistance;

    if (this.mc.gameSettings.smoothCamera)
    {
        float f = this.mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
        float f1 = f * f * f * 8.0F;
        this.smoothCamFilterX = this.mouseFilterXAxis.smooth(this.smoothCamYaw, 0.05F * f1);
        this.smoothCamFilterY = this.mouseFilterYAxis.smooth(this.smoothCamPitch, 0.05F * f1);
        this.smoothCamPartialTicks = 0.0F;
        this.smoothCamYaw = 0.0F;
        this.smoothCamPitch = 0.0F;
    }
    else
    {
        this.smoothCamFilterX = 0.0F;
        this.smoothCamFilterY = 0.0F;
        this.mouseFilterXAxis.reset();
        this.mouseFilterYAxis.reset();
    }

    if (this.mc.getRenderViewEntity() == null)
    {
        this.mc.setRenderViewEntity(this.mc.thePlayer);
    }

    Entity entity = this.mc.getRenderViewEntity();
    double d0 = entity.posX;
    double d1 = entity.posY + (double)entity.getEyeHeight();
    double d2 = entity.posZ;
    float f3 = this.mc.theWorld.getLightBrightness(new BlockPos(d0, d1, d2));
    float f4 = (float)this.mc.gameSettings.renderDistanceChunks / 16.0F;
    f4 = MathHelper.clamp_float(f4, 0.0F, 1.0F);
    float f2 = f3 * (1.0F - f4) + f4;
    this.fogColor1 += (f2 - this.fogColor1) * 0.1F;
    ++this.rendererUpdateCount;
    this.itemRenderer.updateEquippedItem();
    this.addRainParticles();
    this.bossColorModifierPrev = this.bossColorModifier;

    if (BossStatus.hasColorModifier)
    {
        this.bossColorModifier += 0.05F;

        if (this.bossColorModifier > 1.0F)
        {
            this.bossColorModifier = 1.0F;
        }

        BossStatus.hasColorModifier = false;
    }
    else if (this.bossColorModifier > 0.0F)
    {
        this.bossColorModifier -= 0.0125F;
    }
}
 
Example 38
Project: minecraft-quiverbow   File: SmallRocket.java   Source Code and License 4 votes vote down vote up
@Override
public void onImpact(MovingObjectPosition target)	// Server-side
{
	if (target.entityHit != null) 	// Hit a entity
   	{
		// Damage
		target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float)this.damage);
		target.entityHit.hurtResistantTime = 0; // No immunity frames
		
		// Knockback
           double f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
           if (f3 > 0.0F) 
           {
           	target.entityHit.addVelocity(
       			this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f3, 
       			0.1D, 
       			this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f3
           	);
           }
           
		// Effect
		if ( !(target.entityHit instanceof EntityEnderman) ) { target.entityHit.setFire(this.fireDuration); } 
		
		this.setDead();	
		
	}
	else 	// Hit a block
	{ 
		Block block = this.worldObj.getBlock(target.blockX, target.blockY, target.blockZ);
		
		// Glass breaking, once
		if (Helper.tryBlockBreak(this.worldObj, this, target, 1) && this.targetsHit < 1) { this.targetsHit += 1; }
		else { this.setDead(); }	// else, either we didn't break that block or we already hit one entity
           
		// Let's ignite TNT explicitly here.
		if (block == Blocks.tnt)
		{
			this.worldObj.setBlockToAir(target.blockX, target.blockY, target.blockZ); // setBlockToAir
              
			EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(this.worldObj, 
               		(double)((float)target.blockX + 0.5F), 
               		(double)((float)target.blockY + 0.5F), 
               		(double)((float)target.blockZ + 0.5F), 
               		this.shootingEntity);									

               this.worldObj.spawnEntityInWorld(entitytntprimed);			// This is TNT, so begone with that block and replace it with primed TNT
               
               this.worldObj.playSoundAtEntity(entitytntprimed, "random.fuse", 1.0F, 1.0F);
		}
		// else, block is not TNT
	} 
	
	if (!this.isInWater()) // Only explode if we're not in water
	{																			
		boolean griefing = true;	// Allowed by default
		
		if (this.shootingEntity instanceof EntityPlayer)
		{
			griefing = this.dmgTerrain;	// It's up to player settings to allow/forbid this
		}
		else
		{
			griefing = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing");	// Are we allowed to break things?
		}
		
		this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) this.explosionSize, griefing); 	
		// 4.0F is TNT, false is for "not flaming"
		// Editchevsky: Actually, false is double-used for "don't damage terrain"
	}
}
 
Example 39
Project: BaseClient   File: RealmsMth.java   Source Code and License 4 votes vote down vote up
public static float sqrt(double p_sqrt_0_)
{
    return MathHelper.sqrt_double(p_sqrt_0_);
}
 
Example 40
Project: Technical   File: TechnicalWorldGenMinable.java   Source Code and License 4 votes vote down vote up
public boolean generateSparse(World world, Random random, int x, int y, int z) {
	float f = random.nextFloat() * (float) Math.PI;
	double d0 = (double) ((float) (x + 8) + MathHelper.sin(f) * (float) this.numberOfBlocks / 8.0F);
	double d1 = (double) ((float) (x + 8) - MathHelper.sin(f) * (float) this.numberOfBlocks / 8.0F);
	double d2 = (double) ((float) (z + 8) + MathHelper.cos(f) * (float) this.numberOfBlocks / 8.0F);
	double d3 = (double) ((float) (z + 8) - MathHelper.cos(f) * (float) this.numberOfBlocks / 8.0F);
	double d4 = (double) (y + random.nextInt(3) - 2);
	double d5 = (double) (y + random.nextInt(3) - 2);

	for(int l = 0; l <= this.numberOfBlocks; ++l) {
		double d6 = d0 + (d1 - d0) * (double) l / (double) this.numberOfBlocks;
		double d7 = d4 + (d5 - d4) * (double) l / (double) this.numberOfBlocks;
		double d8 = d2 + (d3 - d2) * (double) l / (double) this.numberOfBlocks;
		double d9 = random.nextDouble() * (double) this.numberOfBlocks / 16.0D;
		double d10 = (double) (MathHelper.sin((float) l * (float) Math.PI / (float) this.numberOfBlocks) + 1.0F) * d9 + 1.0D;
		double d11 = (double) (MathHelper.sin((float) l * (float) Math.PI / (float) this.numberOfBlocks) + 1.0F) * d9 + 1.0D;
		int i1 = MathHelper.floor_double(d6 - d10 / 2.0D);
		int j1 = MathHelper.floor_double(d7 - d11 / 2.0D);
		int k1 = MathHelper.floor_double(d8 - d10 / 2.0D);
		int l1 = MathHelper.floor_double(d6 + d10 / 2.0D);
		int i2 = MathHelper.floor_double(d7 + d11 / 2.0D);
		int j2 = MathHelper.floor_double(d8 + d10 / 2.0D);

		for(int k2 = i1; k2 <= l1; ++k2) {
			if(random.nextInt(20) == 0) {
				double d12 = ((double) k2 + 0.5D - d6) / (d10 / 2.0D);

				if(d12 * d12 < 1.0D) {
					for(int l2 = j1; l2 <= i2; ++l2) {
						double d13 = ((double) l2 + 0.5D - d7) / (d11 / 2.0D);

						if(d12 * d12 + d13 * d13 < 1.0D) {
							for(int i3 = k1; i3 <= j2; ++i3) {
								double d14 = ((double) i3 + 0.5D - d8) / (d10 / 2.0D);

								if(d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && world.getBlock(k2, l2, i3).isReplaceableOreGen(world, k2, l2, i3, targetBlock)) {
									FMLLog.log(Level.INFO, k2 + " " + l2 + " " + i3);
									world.setBlock(k2, l2, i3, this.blocktoGen, mineableBlockMeta, 2);
								}
							}
						}
					}
				}
			}
		}
	}
	return true;
}
 
Example 41
Project: BaseClient   File: CommandSpreadPlayers.java   Source Code and License 4 votes vote down vote up
public void func_111097_a(Random p_111097_1_, double p_111097_2_, double p_111097_4_, double p_111097_6_, double p_111097_8_)
{
    this.field_111101_a = MathHelper.getRandomDoubleInRange(p_111097_1_, p_111097_2_, p_111097_6_);
    this.field_111100_b = MathHelper.getRandomDoubleInRange(p_111097_1_, p_111097_4_, p_111097_8_);
}
 
Example 42
Project: BaseClient   File: RenderGlobal.java   Source Code and License 4 votes vote down vote up
private boolean isPositionInRenderChunk(BlockPos pos, RenderChunk renderChunkIn)
{
    BlockPos blockpos = renderChunkIn.getPosition();
    return MathHelper.abs_int(pos.getX() - blockpos.getX()) > 16 ? false : (MathHelper.abs_int(pos.getY() - blockpos.getY()) > 16 ? false : MathHelper.abs_int(pos.getZ() - blockpos.getZ()) <= 16);
}
 
Example 43
Project: Technical   File: TechnicalWorldGenMinable.java   Source Code and License 4 votes vote down vote up
public boolean generate(World world, Random random, int x, int y, int z) {
	float f = random.nextFloat() * (float) Math.PI;
	double d0 = (double) ((float) (x + 8) + MathHelper.sin(f) * (float) this.numberOfBlocks / 8.0F);
	double d1 = (double) ((float) (x + 8) - MathHelper.sin(f) * (float) this.numberOfBlocks / 8.0F);
	double d2 = (double) ((float) (z + 8) + MathHelper.cos(f) * (float) this.numberOfBlocks / 8.0F);
	double d3 = (double) ((float) (z + 8) - MathHelper.cos(f) * (float) this.numberOfBlocks / 8.0F);
	double d4 = (double) (y + random.nextInt(3) - 2);
	double d5 = (double) (y + random.nextInt(3) - 2);

	for(int l = 0; l <= this.numberOfBlocks; ++l) {
		double d6 = d0 + (d1 - d0) * (double) l / (double) this.numberOfBlocks;
		double d7 = d4 + (d5 - d4) * (double) l / (double) this.numberOfBlocks;
		double d8 = d2 + (d3 - d2) * (double) l / (double) this.numberOfBlocks;
		double d9 = random.nextDouble() * (double) this.numberOfBlocks / 16.0D;
		double d10 = (double) (MathHelper.sin((float) l * (float) Math.PI / (float) this.numberOfBlocks) + 1.0F) * d9 + 1.0D;
		double d11 = (double) (MathHelper.sin((float) l * (float) Math.PI / (float) this.numberOfBlocks) + 1.0F) * d9 + 1.0D;
		int i1 = MathHelper.floor_double(d6 - d10 / 2.0D);
		int j1 = MathHelper.floor_double(d7 - d11 / 2.0D);
		int k1 = MathHelper.floor_double(d8 - d10 / 2.0D);
		int l1 = MathHelper.floor_double(d6 + d10 / 2.0D);
		int i2 = MathHelper.floor_double(d7 + d11 / 2.0D);
		int j2 = MathHelper.floor_double(d8 + d10 / 2.0D);

		for(int k2 = i1; k2 <= l1; ++k2) {
			double d12 = ((double) k2 + 0.5D - d6) / (d10 / 2.0D);

			if(d12 * d12 < 1.0D) {
				for(int l2 = j1; l2 <= i2; ++l2) {
					double d13 = ((double) l2 + 0.5D - d7) / (d11 / 2.0D);

					if(d12 * d12 + d13 * d13 < 1.0D) {
						for(int i3 = k1; i3 <= j2; ++i3) {
							double d14 = ((double) i3 + 0.5D - d8) / (d10 / 2.0D);

							if(d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && world.getBlock(k2, l2, i3).isReplaceableOreGen(world, k2, l2, i3, targetBlock)) {
								world.setBlock(k2, l2, i3, this.blocktoGen, mineableBlockMeta, 2);
							}
						}
					}
				}
			}
		}
	}
	return true;
}
 
Example 44
Project: BaseClient   File: ServerConfigurationManager.java   Source Code and License 4 votes vote down vote up
/**
 * Transfers an entity from a world to another world.
 */
public void transferEntityToWorld(Entity entityIn, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_)
{
    double d0 = entityIn.posX;
    double d1 = entityIn.posZ;
    double d2 = 8.0D;
    float f = entityIn.rotationYaw;
    p_82448_3_.theProfiler.startSection("moving");

    if (entityIn.dimension == -1)
    {
        d0 = MathHelper.clamp_double(d0 / d2, p_82448_4_.getWorldBorder().minX() + 16.0D, p_82448_4_.getWorldBorder().maxX() - 16.0D);
        d1 = MathHelper.clamp_double(d1 / d2, p_82448_4_.getWorldBorder().minZ() + 16.0D, p_82448_4_.getWorldBorder().maxZ() - 16.0D);
        entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);

        if (entityIn.isEntityAlive())
        {
            p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
        }
    }
    else if (entityIn.dimension == 0)
    {
        d0 = MathHelper.clamp_double(d0 * d2, p_82448_4_.getWorldBorder().minX() + 16.0D, p_82448_4_.getWorldBorder().maxX() - 16.0D);
        d1 = MathHelper.clamp_double(d1 * d2, p_82448_4_.getWorldBorder().minZ() + 16.0D, p_82448_4_.getWorldBorder().maxZ() - 16.0D);
        entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);

        if (entityIn.isEntityAlive())
        {
            p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
        }
    }
    else
    {
        BlockPos blockpos;

        if (p_82448_2_ == 1)
        {
            blockpos = p_82448_4_.getSpawnPoint();
        }
        else
        {
            blockpos = p_82448_4_.getSpawnCoordinate();
        }

        d0 = (double)blockpos.getX();
        entityIn.posY = (double)blockpos.getY();
        d1 = (double)blockpos.getZ();
        entityIn.setLocationAndAngles(d0, entityIn.posY, d1, 90.0F, 0.0F);

        if (entityIn.isEntityAlive())
        {
            p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
        }
    }

    p_82448_3_.theProfiler.endSection();

    if (p_82448_2_ != 1)
    {
        p_82448_3_.theProfiler.startSection("placing");
        d0 = (double)MathHelper.clamp_int((int)d0, -29999872, 29999872);
        d1 = (double)MathHelper.clamp_int((int)d1, -29999872, 29999872);

        if (entityIn.isEntityAlive())
        {
            entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
            p_82448_4_.getDefaultTeleporter().placeInPortal(entityIn, f);
            p_82448_4_.spawnEntityInWorld(entityIn);
            p_82448_4_.updateEntityWithOptionalForce(entityIn, false);
        }

        p_82448_3_.theProfiler.endSection();
    }

    entityIn.setWorld(p_82448_4_);
}
 
Example 45
Project: BaseClient   File: RealmsMth.java   Source Code and License 4 votes vote down vote up
public static int clamp(int p_clamp_0_, int p_clamp_1_, int p_clamp_2_)
{
    return MathHelper.clamp_int(p_clamp_0_, p_clamp_1_, p_clamp_2_);
}
 
Example 46
Project: BaseClient   File: TileEntityFurnace.java   Source Code and License 4 votes vote down vote up
/**
 * Like the old updateEntity(), except more generic.
 */
public void update()
{
    boolean flag = this.isBurning();
    boolean flag1 = false;

    if (this.isBurning())
    {
        --this.furnaceBurnTime;
    }

    if (!this.worldObj.isRemote)
    {
        if (this.isBurning() || this.furnaceItemStacks[1] != null && this.furnaceItemStacks[0] != null)
        {
            if (!this.isBurning() && this.canSmelt())
            {
                this.currentItemBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);

                if (this.isBurning())
                {
                    flag1 = true;

                    if (this.furnaceItemStacks[1] != null)
                    {
                        --this.furnaceItemStacks[1].stackSize;

                        if (this.furnaceItemStacks[1].stackSize == 0)
                        {
                            Item item = this.furnaceItemStacks[1].getItem().getContainerItem();
                            this.furnaceItemStacks[1] = item != null ? new ItemStack(item) : null;
                        }
                    }
                }
            }

            if (this.isBurning() && this.canSmelt())
            {
                ++this.cookTime;

                if (this.cookTime == this.totalCookTime)
                {
                    this.cookTime = 0;
                    this.totalCookTime = this.getCookTime(this.furnaceItemStacks[0]);
                    this.smeltItem();
                    flag1 = true;
                }
            }
            else
            {
                this.cookTime = 0;
            }
        }
        else if (!this.isBurning() && this.cookTime > 0)
        {
            this.cookTime = MathHelper.clamp_int(this.cookTime - 2, 0, this.totalCookTime);
        }

        if (flag != this.isBurning())
        {
            flag1 = true;
            BlockFurnace.setState(this.isBurning(), this.worldObj, this.pos);
        }
    }

    if (flag1)
    {
        this.markDirty();
    }
}
 
Example 47
Project: BaseClient   File: RealmsMth.java   Source Code and License 4 votes vote down vote up
public static int roundUp(int p_roundUp_0_, int p_roundUp_1_)
{
    return MathHelper.func_154354_b(p_roundUp_0_, p_roundUp_1_);
}
 
Example 48
Project: BaseClient   File: RealmsMth.java   Source Code and License 4 votes vote down vote up
public static double nextDouble(Random p_nextDouble_0_, double p_nextDouble_1_, double p_nextDouble_3_)
{
    return MathHelper.getRandomDoubleInRange(p_nextDouble_0_, p_nextDouble_1_, p_nextDouble_3_);
}
 
Example 49
Project: BaseClient   File: RealmsMth.java   Source Code and License 4 votes vote down vote up
public static float clamp(float p_clamp_0_, float p_clamp_1_, float p_clamp_2_)
{
    return MathHelper.clamp_float(p_clamp_0_, p_clamp_1_, p_clamp_2_);
}
 
Example 50
Project: BaseClient   File: TileEntityEnchantmentTableRenderer.java   Source Code and License 4 votes vote down vote up
public void renderTileEntityAt(TileEntityEnchantmentTable te, double x, double y, double z, float partialTicks, int destroyStage)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)x + 0.5F, (float)y + 0.75F, (float)z + 0.5F);
    float f = (float)te.tickCount + partialTicks;
    GlStateManager.translate(0.0F, 0.1F + MathHelper.sin(f * 0.1F) * 0.01F, 0.0F);
    float f1;

    for (f1 = te.bookRotation - te.bookRotationPrev; f1 >= (float)Math.PI; f1 -= ((float)Math.PI * 2F))
    {
        ;
    }

    while (f1 < -(float)Math.PI)
    {
        f1 += ((float)Math.PI * 2F);
    }

    float f2 = te.bookRotationPrev + f1 * partialTicks;
    GlStateManager.rotate(-f2 * 180.0F / (float)Math.PI, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(80.0F, 0.0F, 0.0F, 1.0F);
    this.bindTexture(TEXTURE_BOOK);
    float f3 = te.pageFlipPrev + (te.pageFlip - te.pageFlipPrev) * partialTicks + 0.25F;
    float f4 = te.pageFlipPrev + (te.pageFlip - te.pageFlipPrev) * partialTicks + 0.75F;
    f3 = (f3 - (float)MathHelper.truncateDoubleToInt((double)f3)) * 1.6F - 0.3F;
    f4 = (f4 - (float)MathHelper.truncateDoubleToInt((double)f4)) * 1.6F - 0.3F;

    if (f3 < 0.0F)
    {
        f3 = 0.0F;
    }

    if (f4 < 0.0F)
    {
        f4 = 0.0F;
    }

    if (f3 > 1.0F)
    {
        f3 = 1.0F;
    }

    if (f4 > 1.0F)
    {
        f4 = 1.0F;
    }

    float f5 = te.bookSpreadPrev + (te.bookSpread - te.bookSpreadPrev) * partialTicks;
    GlStateManager.enableCull();
    this.field_147541_c.render((Entity)null, f, f3, f4, f5, 0.0F, 0.0625F);
    GlStateManager.popMatrix();
}
 
Example 51
Project: BaseClient   File: RenderXPOrb.java   Source Code and License 4 votes vote down vote up
/**
 * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
 * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
 * (Render<T extends Entity>) and this method has signature public void doRender(T entity, double d, double d1,
 * double d2, float f, float f1). But JAD is pre 1.5 so doe
 */
public void doRender(EntityXPOrb entity, double x, double y, double z, float entityYaw, float partialTicks)
{
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)x, (float)y, (float)z);
    this.bindEntityTexture(entity);
    int i = entity.getTextureByXP();
    float f = (float)(i % 4 * 16 + 0) / 64.0F;
    float f1 = (float)(i % 4 * 16 + 16) / 64.0F;
    float f2 = (float)(i / 4 * 16 + 0) / 64.0F;
    float f3 = (float)(i / 4 * 16 + 16) / 64.0F;
    float f4 = 1.0F;
    float f5 = 0.5F;
    float f6 = 0.25F;
    int j = entity.getBrightnessForRender(partialTicks);
    int k = j % 65536;
    int l = j / 65536;
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)k / 1.0F, (float)l / 1.0F);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    float f7 = 255.0F;
    float f8 = ((float)entity.xpColor + partialTicks) / 2.0F;
    l = (int)((MathHelper.sin(f8 + 0.0F) + 1.0F) * 0.5F * 255.0F);
    boolean flag = true;
    int i1 = (int)((MathHelper.sin(f8 + 4.1887903F) + 1.0F) * 0.1F * 255.0F);
    GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    float f9 = 0.3F;
    GlStateManager.scale(0.3F, 0.3F, 0.3F);
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
    int j1 = l;
    int k1 = 255;
    int l1 = i1;

    if (Config.isCustomColors())
    {
        int i2 = CustomColors.getXpOrbColor(f8);

        if (i2 >= 0)
        {
            j1 = i2 >> 16 & 255;
            k1 = i2 >> 8 & 255;
            l1 = i2 >> 0 & 255;
        }
    }

    worldrenderer.pos((double)(0.0F - f5), (double)(0.0F - f6), 0.0D).tex((double)f, (double)f3).color(j1, k1, l1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
    worldrenderer.pos((double)(f4 - f5), (double)(0.0F - f6), 0.0D).tex((double)f1, (double)f3).color(j1, k1, l1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
    worldrenderer.pos((double)(f4 - f5), (double)(1.0F - f6), 0.0D).tex((double)f1, (double)f2).color(j1, k1, l1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
    worldrenderer.pos((double)(0.0F - f5), (double)(1.0F - f6), 0.0D).tex((double)f, (double)f2).color(j1, k1, l1, 128).normal(0.0F, 1.0F, 0.0F).endVertex();
    tessellator.draw();
    GlStateManager.disableBlend();
    GlStateManager.disableRescaleNormal();
    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
 
Example 52
Project: BaseClient   File: NBTTagFloat.java   Source Code and License 4 votes vote down vote up
public int getInt()
{
    return MathHelper.floor_float(this.data);
}
 
Example 53
Project: BaseClient   File: TileEntityBannerRenderer.java   Source Code and License 4 votes vote down vote up
public void renderTileEntityAt(TileEntityBanner te, double x, double y, double z, float partialTicks, int destroyStage)
{
    boolean flag = te.getWorld() != null;
    boolean flag1 = !flag || te.getBlockType() == Blocks.standing_banner;
    int i = flag ? te.getBlockMetadata() : 0;
    long j = flag ? te.getWorld().getTotalWorldTime() : 0L;
    GlStateManager.pushMatrix();
    float f = 0.6666667F;

    if (flag1)
    {
        GlStateManager.translate((float)x + 0.5F, (float)y + 0.75F * f, (float)z + 0.5F);
        float f1 = (float)(i * 360) / 16.0F;
        GlStateManager.rotate(-f1, 0.0F, 1.0F, 0.0F);
        this.bannerModel.bannerStand.showModel = true;
    }
    else
    {
        float f2 = 0.0F;

        if (i == 2)
        {
            f2 = 180.0F;
        }

        if (i == 4)
        {
            f2 = 90.0F;
        }

        if (i == 5)
        {
            f2 = -90.0F;
        }

        GlStateManager.translate((float)x + 0.5F, (float)y - 0.25F * f, (float)z + 0.5F);
        GlStateManager.rotate(-f2, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(0.0F, -0.3125F, -0.4375F);
        this.bannerModel.bannerStand.showModel = false;
    }

    BlockPos blockpos = te.getPos();
    float f3 = (float)(blockpos.getX() * 7 + blockpos.getY() * 9 + blockpos.getZ() * 13) + (float)j + partialTicks;
    this.bannerModel.bannerSlate.rotateAngleX = (-0.0125F + 0.01F * MathHelper.cos(f3 * (float)Math.PI * 0.02F)) * (float)Math.PI;
    GlStateManager.enableRescaleNormal();
    ResourceLocation resourcelocation = this.func_178463_a(te);

    if (resourcelocation != null)
    {
        this.bindTexture(resourcelocation);
        GlStateManager.pushMatrix();
        GlStateManager.scale(f, -f, -f);
        this.bannerModel.renderBanner();
        GlStateManager.popMatrix();
    }

    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.popMatrix();
}
 
Example 54
Project: BaseClient   File: NaturalProperties.java   Source Code and License 4 votes vote down vote up
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_;
}
 
Example 55
Project: BaseClient   File: CommandHelp.java   Source Code and License 4 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    List<ICommand> list = this.getSortedPossibleCommands(sender);
    int i = 7;
    int j = (list.size() - 1) / 7;
    int k = 0;

    try
    {
        k = args.length == 0 ? 0 : parseInt(args[0], 1, j + 1) - 1;
    }
    catch (NumberInvalidException numberinvalidexception)
    {
        Map<String, ICommand> map = this.getCommands();
        ICommand icommand = (ICommand)map.get(args[0]);

        if (icommand != null)
        {
            throw new WrongUsageException(icommand.getCommandUsage(sender), new Object[0]);
        }

        if (MathHelper.parseIntWithDefault(args[0], -1) != -1)
        {
            throw numberinvalidexception;
        }

        throw new CommandNotFoundException();
    }

    int l = Math.min((k + 1) * 7, list.size());
    ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.help.header", new Object[] {Integer.valueOf(k + 1), Integer.valueOf(j + 1)});
    chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
    sender.addChatMessage(chatcomponenttranslation1);

    for (int i1 = k * 7; i1 < l; ++i1)
    {
        ICommand icommand1 = (ICommand)list.get(i1);
        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(icommand1.getCommandUsage(sender), new Object[0]);
        chatcomponenttranslation.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + icommand1.getCommandName() + " "));
        sender.addChatMessage(chatcomponenttranslation);
    }

    if (k == 0 && sender instanceof EntityPlayer)
    {
        ChatComponentTranslation chatcomponenttranslation2 = new ChatComponentTranslation("commands.help.footer", new Object[0]);
        chatcomponenttranslation2.getChatStyle().setColor(EnumChatFormatting.GREEN);
        sender.addChatMessage(chatcomponenttranslation2);
    }
}
 
Example 56
Project: BaseClient   File: RealmsMth.java   Source Code and License 4 votes vote down vote up
public static int smallestEncompassingPowerOfTwo(int p_smallestEncompassingPowerOfTwo_0_)
{
    return MathHelper.roundUpToPowerOfTwo(p_smallestEncompassingPowerOfTwo_0_);
}
 
Example 57
Project: BaseClient   File: NBTTagDouble.java   Source Code and License 4 votes vote down vote up
public byte getByte()
{
    return (byte)(MathHelper.floor_double(this.data) & 255);
}
 
Example 58
Project: BaseClient   File: EntityGuardian.java   Source Code and License 4 votes vote down vote up
public void onUpdateMoveHelper()
{
    if (this.update && !this.entityGuardian.getNavigator().noPath())
    {
        double d0 = this.posX - this.entityGuardian.posX;
        double d1 = this.posY - this.entityGuardian.posY;
        double d2 = this.posZ - this.entityGuardian.posZ;
        double d3 = d0 * d0 + d1 * d1 + d2 * d2;
        d3 = (double)MathHelper.sqrt_double(d3);
        d1 = d1 / d3;
        float f = (float)(MathHelper.func_181159_b(d2, d0) * 180.0D / Math.PI) - 90.0F;
        this.entityGuardian.rotationYaw = this.limitAngle(this.entityGuardian.rotationYaw, f, 30.0F);
        this.entityGuardian.renderYawOffset = this.entityGuardian.rotationYaw;
        float f1 = (float)(this.speed * this.entityGuardian.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue());
        this.entityGuardian.setAIMoveSpeed(this.entityGuardian.getAIMoveSpeed() + (f1 - this.entityGuardian.getAIMoveSpeed()) * 0.125F);
        double d4 = Math.sin((double)(this.entityGuardian.ticksExisted + this.entityGuardian.getEntityId()) * 0.5D) * 0.05D;
        double d5 = Math.cos((double)(this.entityGuardian.rotationYaw * (float)Math.PI / 180.0F));
        double d6 = Math.sin((double)(this.entityGuardian.rotationYaw * (float)Math.PI / 180.0F));
        this.entityGuardian.motionX += d4 * d5;
        this.entityGuardian.motionZ += d4 * d6;
        d4 = Math.sin((double)(this.entityGuardian.ticksExisted + this.entityGuardian.getEntityId()) * 0.75D) * 0.05D;
        this.entityGuardian.motionY += d4 * (d6 + d5) * 0.25D;
        this.entityGuardian.motionY += (double)this.entityGuardian.getAIMoveSpeed() * d1 * 0.1D;
        EntityLookHelper entitylookhelper = this.entityGuardian.getLookHelper();
        double d7 = this.entityGuardian.posX + d0 / d3 * 2.0D;
        double d8 = (double)this.entityGuardian.getEyeHeight() + this.entityGuardian.posY + d1 / d3 * 1.0D;
        double d9 = this.entityGuardian.posZ + d2 / d3 * 2.0D;
        double d10 = entitylookhelper.getLookPosX();
        double d11 = entitylookhelper.getLookPosY();
        double d12 = entitylookhelper.getLookPosZ();

        if (!entitylookhelper.getIsLooking())
        {
            d10 = d7;
            d11 = d8;
            d12 = d9;
        }

        this.entityGuardian.getLookHelper().setLookPosition(d10 + (d7 - d10) * 0.125D, d11 + (d8 - d11) * 0.125D, d12 + (d9 - d12) * 0.125D, 10.0F, 40.0F);
        this.entityGuardian.func_175476_l(true);
    }
    else
    {
        this.entityGuardian.setAIMoveSpeed(0.0F);
        this.entityGuardian.func_175476_l(false);
    }
}
 
Example 59
Project: OpenSensors   File: BlockSensor.java   Source Code and License 4 votes vote down vote up
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
	super.onBlockPlacedBy(world, x, y, z, player, stack);
	int dir = MathHelper.floor_double((double) ((player.rotationYaw * 4F) / 360F) + 0.5D) & 3;
	world.setBlockMetadataWithNotify(x, y, z, dir, 3);
}
 
Example 60
Project: BaseClient   File: TwitchStream.java   Source Code and License 4 votes vote down vote up
public static int formatStreamKbps(float p_152946_0_)
{
    return MathHelper.floor_float(230.0F + p_152946_0_ * 3270.0F);
}