Java Code Examples for net.minecraft.util.MathHelper

The following examples show how to use net.minecraft.util.MathHelper. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * @author CCBlueX
 */
@Overwrite
protected void jump() {
    final JumpEvent jumpEvent = new JumpEvent(this.getJumpUpwardsMotion());
    LiquidBounce.eventManager.callEvent(jumpEvent);
    if(jumpEvent.isCancelled())
        return;

    this.motionY = jumpEvent.getMotion();

    if(this.isPotionActive(Potion.jump))
        this.motionY += (double) ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);

    if(this.isSprinting()) {
        float f = this.rotationYaw * 0.017453292F;
        this.motionX -= (double) (MathHelper.sin(f) * 0.2F);
        this.motionZ += (double) (MathHelper.cos(f) * 0.2F);
    }

    this.isAirBorne = true;
}
 
Example 2
Source Project: NEI-Integration   Source File: RailTools.java    License: MIT License 6 votes vote down vote up
/**
 * Checks to see if a cart is being held by a ITrackLockdown.
 *
 * @param cart The cart to check
 * @return True if being held
 */
public static boolean isCartLockedDown(EntityMinecart cart) {
    int x = MathHelper.floor_double(cart.posX);
    int y = MathHelper.floor_double(cart.posY);
    int z = MathHelper.floor_double(cart.posZ);

    if (BlockRailBase.func_150049_b_(cart.worldObj, x, y - 1, z))
        y--;

    TileEntity tile = cart.worldObj.getTileEntity(x, y, z);
    if (tile instanceof ITrackTile) {
        ITrackInstance track = ((ITrackTile) tile).getTrackInstance();
        return track instanceof ITrackLockdown && ((ITrackLockdown) track).isCartLockedDown(cart);
    } else if (tile instanceof ITrackLockdown)
        return ((ITrackLockdown) tile).isCartLockedDown(cart);
    return false;
}
 
Example 3
Source Project: mocreaturesdev   Source File: MoCTools.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void bigsmack(Entity entity, Entity entity1, float force)
{
    double d = entity.posX - entity1.posX;
    double d1 = entity.posZ - entity1.posZ;
    for (d1 = entity.posZ - entity1.posZ; ((d * d) + (d1 * d1)) < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D)
    {
        d = (Math.random() - Math.random()) * 0.01D;
    }

    float f = MathHelper.sqrt_double((d * d) + (d1 * d1));
    // float f1 = 0.25F;
    /*
     * if(getKittyState() == 10) { f1 = 0.1F; }
     */
    entity1.motionX /= 2D;
    entity1.motionY /= 2D;
    entity1.motionZ /= 2D;
    entity1.motionX -= (d / f) * force;
    entity1.motionY += force;// 0.300000005960465D;
    entity1.motionZ -= (d1 / f) * force;
    if (entity1.motionY > force)// 0.3D)
    {
        entity1.motionY = force;// 0.3D;
    }
}
 
Example 4
@Override
public void onPlayerStoppedUsingFocus(ItemStack itemstack, World world, EntityPlayer player, int count) {
    int x = MathHelper.floor_double(player.posX);
    int y = MathHelper.floor_double(player.posY);
    int z = MathHelper.floor_double(player.posZ);

    // Player Level
    if ((player.worldObj.getBlock(x + 1, y, z) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x - 1, y, z) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x, y, z + 1) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x, y, z - 1) == IC2BlockRegistry.shield)) {
        player.worldObj.setBlockToAir(x + 1, y, z);
        player.worldObj.setBlockToAir(x - 1, y, z);
        player.worldObj.setBlockToAir(x, y, z + 1);
        player.worldObj.setBlockToAir(x, y, z - 1);
    }

    // Above the player
    if ((player.worldObj.getBlock(x + 1, y + 1, z) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x - 1, y + 1, z) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x, y + 1, z + 1) == IC2BlockRegistry.shield) && (player.worldObj.getBlock(x, y + 1, z - 1) == IC2BlockRegistry.shield)) {
        player.worldObj.setBlockToAir(x + 1, y + 1, z);
        player.worldObj.setBlockToAir(x - 1, y + 1, z);
        player.worldObj.setBlockToAir(x, y + 1, z + 1);
        player.worldObj.setBlockToAir(x, y + 1, z - 1);
    }

    ItemStack milk = (new ItemStack(Items.milk_bucket));
    player.curePotionEffects(milk);
}
 
Example 5
public EntityLaser(World par1World, EntityLivingBase par2EntityLivingBase, float par3) {
	super(par1World);
	this.renderDistanceWeight = 10.0D;
	this.shootingEntity = par2EntityLivingBase;

	this.setSize(0.5F, 0.5F);
	this.setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY + (double) par2EntityLivingBase.getEyeHeight(), par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.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);
	this.yOffset = 0.0F;
	this.motionX = (double) (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
	this.motionZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
	this.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI));
	this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F);
}
 
Example 6
Source Project: Artifacts   Source File: PlaceTraps.java    License: MIT License 6 votes vote down vote up
private boolean simpleTrap(Random rand, World world, Vec3 c) {
	boolean nn = false; 
	if(world.isAirBlock(MathHelper.floor_double(c.xCoord), MathHelper.floor_double(c.yCoord), MathHelper.floor_double(c.zCoord))) {
		c.yCoord -=1;
		nn = true;
	}
	world.setBlock(MathHelper.floor_double(c.xCoord), MathHelper.floor_double(c.yCoord), MathHelper.floor_double(c.zCoord), BlockTrap.instance, 1, 3);
	world.setBlockMetadataWithNotify(MathHelper.floor_double(c.xCoord), MathHelper.floor_double(c.yCoord), MathHelper.floor_double(c.zCoord), 1, 3);
	world.setBlock(MathHelper.floor_double(c.xCoord), MathHelper.floor_double(c.yCoord+1), MathHelper.floor_double(c.zCoord), rand.nextInt(5) == 0 ? BlockArtifactsPressurePlate.camoObsidian : BlockArtifactsPressurePlate.invisObsidian);
	
	
	TileEntityTrap dis = (TileEntityTrap)world.getTileEntity(MathHelper.floor_double(c.xCoord), MathHelper.floor_double(c.yCoord), MathHelper.floor_double(c.zCoord));
	if(dis != null) {
		addTrapItem(rand, dis);
	}
	else {
		TileEntityDispenser dis2 = (TileEntityDispenser)world.getTileEntity(MathHelper.floor_double(c.xCoord), MathHelper.floor_double(c.yCoord), MathHelper.floor_double(c.zCoord));
		if(dis2 != null) {
			addTrapItem(rand, dis);
		}
	}
	if(nn) {
		c.yCoord +=1;
	}
	return true;
}
 
Example 7
/**
 * @author CCBlueX
 */
@Overwrite
protected void jump() {
    final JumpEvent jumpEvent = new JumpEvent(this.getJumpUpwardsMotion());
    LiquidBounce.eventManager.callEvent(jumpEvent);
    if(jumpEvent.isCancelled())
        return;

    this.motionY = jumpEvent.getMotion();

    if(this.isPotionActive(Potion.jump))
        this.motionY += (double) ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);

    if(this.isSprinting()) {
        float f = this.rotationYaw * 0.017453292F;
        this.motionX -= (double) (MathHelper.sin(f) * 0.2F);
        this.motionZ += (double) (MathHelper.cos(f) * 0.2F);
    }

    this.isAirBorne = true;
}
 
Example 8
@Override
public void render(int mouseX, int mouseY, float partialTick){
    GL11.glColor4d(1, 1, 1, 1);
    if(!Mouse.isButtonDown(0)) dragging = false;
    if(!wasClicking && Mouse.isButtonDown(0) && getBounds().contains(mouseX, mouseY)) {
        dragging = true;
    }
    if(!enabled) dragging = false;
    wasClicking = Mouse.isButtonDown(0);
    if(dragging) currentScroll = (float)(mouseY - 7 - getBounds().y) / (getBounds().height - 17);
    currentScroll = MathHelper.clamp_float(currentScroll, 0, 1);
    Minecraft.getMinecraft().getTextureManager().bindTexture(scrollTexture);
    Gui.func_146110_a(x, y, 12, 0, getBounds().width, 1, 26, 15);
    for(int i = 0; i < getBounds().height - 2; i++)
        Gui.func_146110_a(x, y + 1 + i, 12, 1, getBounds().width, 1, 26, 15);
    Gui.func_146110_a(x, y + getBounds().height - 1, 12, 14, getBounds().width, 1, 26, 15);

    if(!enabled) GL11.glColor4d(0.6, 0.6, 0.6, 1);
    Gui.func_146110_a(x + 1, y + 1 + (int)((getBounds().height - 17) * currentScroll), 0, 0, 12, 15, 26, 15);
    GL11.glColor4d(1, 1, 1, 1);
}
 
Example 9
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
    if (ConfigHandler.nightVisionOff == false) {
        if (ElectricItem.manager.canUse(itemStack, 1 / 1000)) {

            int x = MathHelper.floor_double(player.posX);
            int z = MathHelper.floor_double(player.posZ);
            int y = MathHelper.floor_double(player.posY);

            int lightlevel = player.worldObj.getBlockLightValue(x, y, z);
            if (lightlevel >= 0)
                player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300, -3));
            ElectricItem.manager.use(itemStack, 1 / 1000, player);
        } else {
            player.addPotionEffect(new PotionEffect(Potion.blindness.id, 300, 0, true));
        }
    }
}
 
Example 10
@SideOnly(Side.CLIENT)
private void doEssentiaTrail() {
    if((ticksExisted & 1) == 0) return;
    TileAuraPylon tile = getMasterTile();
    if(tile == null) return;
    TileAuraPylon inputTile = getInputTile();
    if(inputTile == null) return;
    Aspect a = inputTile.getAspectType();
    if(a == null) return;
    if(inputTile.amount <= 0) return;

    int count = 5;
    FXEssentiaTrail essentiaTrail = new FXEssentiaTrail(tile.getWorldObj(), inputTile.xCoord + 0.5, inputTile.yCoord + 0.2, inputTile.zCoord + 0.5, tile.xCoord + 0.5, tile.yCoord + 1.7, tile.zCoord + 0.5, count, a.getColor(), 1);
    essentiaTrail.noClip = true;
    essentiaTrail.motionY = (0.1F + MathHelper.sin(count / 3.0F) * 0.01F);
    essentiaTrail.motionX = (MathHelper.sin(count / 10.0F) * 0.001F + worldObj.rand.nextGaussian() * 0.002000000094994903D);
    essentiaTrail.motionZ = (MathHelper.sin(count / 10.0F) * 0.001F + worldObj.rand.nextGaussian() * 0.002000000094994903D);
    ParticleEngine.instance.addEffect(tile.getWorldObj(), essentiaTrail);
}
 
Example 11
public boolean NearSnowWithDistance(Entity entity, Double double1)
{
    AxisAlignedBB axisalignedbb = entity.boundingBox.expand(double1.doubleValue(), double1.doubleValue(), double1.doubleValue());
    int i = MathHelper.floor_double(axisalignedbb.minX);
    int j = MathHelper.floor_double(axisalignedbb.maxX + 1.0D);
    int k = MathHelper.floor_double(axisalignedbb.minY);
    int l = MathHelper.floor_double(axisalignedbb.maxY + 1.0D);
    int i1 = MathHelper.floor_double(axisalignedbb.minZ);
    int j1 = MathHelper.floor_double(axisalignedbb.maxZ + 1.0D);
    for (int k1 = i; k1 < j; k1++)
    {
        for (int l1 = k; l1 < l; l1++)
        {
            for (int i2 = i1; i2 < j1; i2++)
            {
                int j2 = worldObj.getBlockId(k1, l1, i2);
                if ((j2 != 0) && (Block.blocksList[j2].blockMaterial == Material.snow)) { return true; }
            }

        }

    }

    return false;
}
 
Example 12
@Override
public List<Vec3> render(EntityPlayer player, double x, double y, double z) {
    double l = (System.currentTimeMillis() % 1000) / 1000D;
    l *= Math.PI / 2;
    List<Vec3> list = new ArrayList<>();
    y += 1.8;
    Vec3 vec3 = new Vec3(x, y, z);
    list.add(vec3.addVector(MathHelper.cos((float) l), 0, MathHelper.sin(((float) l))));
    l += Math.PI / 2;
    list.add(vec3.addVector(MathHelper.cos((float) l), 0, MathHelper.sin(((float) l))));
    l += Math.PI / 2;
    list.add(vec3.addVector(MathHelper.cos((float) l), 0, MathHelper.sin(((float) l))));
    l += Math.PI / 2;
    list.add(vec3.addVector(MathHelper.cos((float) l), 0, MathHelper.sin(((float) l))));
    return list;
}
 
Example 13
@Override
public List<Vec3> render(EntityPlayer player, double x, double y, double z) {
    ArrayList<Vec3> vec3s = new ArrayList<>();
    Vec3 base = new Vec3(x, y + 1.7, z);
    double l = Math.abs(.5 - ((System.currentTimeMillis() % 10000D) / 10000D)) * 4;
    l = l <= 1 ? Math.pow(l, 2) / 2 : -(Math.pow(l - 2, 2) - 2) / 2;
    l *= 2;

    for (int i = 0; i < 40; i++) {
        double v = Math.PI / 40 * i * 2;

        for (int j = 0; j < 6; j++) {
            vec3s.add(base.addVector(MathHelper.sin((float) (v + l * j / 2.5D)), -.2 * j, MathHelper.cos((float) (v + l * j / 2.5D))));
        }
    }

    return vec3s;
}
 
Example 14
Source Project: ehacks-pro   Source File: Projectiles.java    License: GNU General Public License v3.0 6 votes vote down vote up
private boolean isInMaterial(AxisAlignedBB axisalignedBB, Material material) {
    int chunkMinX = MathHelper.floor_double(axisalignedBB.minX);
    int chunkMaxX = MathHelper.floor_double((axisalignedBB.maxX + 1.0));
    int chunkMinY = MathHelper.floor_double(axisalignedBB.minY);
    int chunkMaxY = MathHelper.floor_double((axisalignedBB.maxY + 1.0));
    int chunkMinZ = MathHelper.floor_double(axisalignedBB.minZ);
    int chunkMaxZ = MathHelper.floor_double((axisalignedBB.maxZ + 1.0));
    if (!Wrapper.INSTANCE.world().checkChunksExist(chunkMinX, chunkMinY, chunkMinZ, chunkMaxX, chunkMaxY, chunkMaxZ)) {
        return false;
    }
    boolean isWithin = false;
    for (int x = chunkMinX; x < chunkMaxX; ++x) {
        for (int y = chunkMinY; y < chunkMaxY; ++y) {
            for (int z = chunkMinZ; z < chunkMaxZ; ++z) {
                Block block = Block.getBlockById(Wrapper.INSTANCE.world().getBlockMetadata(x, y, z));
                if (block == null || block.getMaterial() != material || chunkMaxY < ((y + 1) - BlockLiquid.getLiquidHeightPercent(Wrapper.INSTANCE.world().getBlockMetadata(x, y, z)))) {
                    continue;
                }
                isWithin = true;
            }
        }
    }
    return isWithin;
}
 
Example 15
Source Project: mocreaturesdev   Source File: MoCModelMouse.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
{
    Head.rotateAngleX = -(f4 / 57.29578F);
    Head.rotateAngleY = f3 / 57.29578F;
    EarR.rotateAngleX = Head.rotateAngleX;
    EarR.rotateAngleY = Head.rotateAngleY;
    EarL.rotateAngleX = Head.rotateAngleX;
    EarL.rotateAngleY = Head.rotateAngleY;
    WhiskerR.rotateAngleX = Head.rotateAngleX;
    WhiskerR.rotateAngleY = Head.rotateAngleY;
    WhiskerL.rotateAngleX = Head.rotateAngleX;
    WhiskerL.rotateAngleY = Head.rotateAngleY;
    FrontL.rotateAngleX = MathHelper.cos(f * 0.6662F) * 0.6F * f1;
    RearL.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 0.8F * f1;
    RearR.rotateAngleX = MathHelper.cos(f * 0.6662F) * 0.6F * f1;
    FrontR.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 0.8F * f1;
    Tail.rotateAngleY = FrontL.rotateAngleX * 0.625F;
}
 
Example 16
Source Project: mocreaturesdev   Source File: MoCModelBunny.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
{
    part1.rotateAngleX = -(f4 / 57.29578F);
    part1.rotateAngleY = f3 / 57.29578F;
    part8.rotateAngleX = part1.rotateAngleX;
    part8.rotateAngleY = part1.rotateAngleY;
    part9.rotateAngleX = part1.rotateAngleX;
    part9.rotateAngleY = part1.rotateAngleY;
    part10.rotateAngleX = part1.rotateAngleX;
    part10.rotateAngleY = part1.rotateAngleY;
    part11.rotateAngleX = part1.rotateAngleX;
    part11.rotateAngleY = part1.rotateAngleY;
    part2.rotateAngleX = 1.570796F;
    part3.rotateAngleX = 1.570796F;
    part4.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.0F * f1;
    part6.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 1.2F * f1;
    part5.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.0F * f1;
    part7.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 1.2F * f1;
}
 
Example 17
Source Project: ExtraCells1   Source File: BlockWalrus.java    License: MIT License 6 votes vote down vote up
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack)
{
	int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;

	if (l == 0)
	{
		world.setBlockMetadataWithNotify(x, y, z, 2, 2);
	}

	if (l == 1)
	{
		world.setBlockMetadataWithNotify(x, y, z, 5, 2);
	}

	if (l == 2)
	{
		world.setBlockMetadataWithNotify(x, y, z, 3, 2);
	}

	if (l == 3)
	{
		world.setBlockMetadataWithNotify(x, y, z, 4, 2);
	}
}
 
Example 18
@Override
protected void attackEntity(Entity entity, float f)
{

    if ((f > 2.0F) && (f < 6F) && (rand.nextInt(30) == 0) && onGround)
    {
        double d = entity.posX - posX;
        double d1 = entity.posZ - posZ;
        float f1 = MathHelper.sqrt_double((d * d) + (d1 * d1));
        motionX = ((d / f1) * 0.5D * 0.8D) + (motionX * 0.2D);
        motionZ = ((d1 / f1) * 0.5D * 0.8D) + (motionZ * 0.2D);
        motionY = 0.4D;
    }
    if ((f < 2D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY))
    {
        attackTime = 20;
        if ((getKittyState() != 18) && (getKittyState() != 10))
        {
            swingArm();
        }
        if (((getKittyState() == 13) && (entity instanceof EntityPlayer)) || ((getKittyState() == 8) && (entity instanceof EntityItem)) || ((getKittyState() == 18) && (entity instanceof MoCEntityKitty)) || (getKittyState() == 10)) { return; }
        //if(worldObj.isRemote) 
        entity.attackEntityFrom(DamageSource.causeMobDamage(this), 1);
    }
}
 
Example 19
@SideOnly(Side.CLIENT)
public void setVelocity(double par1, double par3, double par5) {
	this.motionX = par1;
	this.motionY = par3;
	this.motionZ = par5;

	if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
		float f = MathHelper.sqrt_double(par1 + par5);
		this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) / Math.PI);
		this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, (double) f) / Math.PI);
		this.prevRotationPitch = this.rotationPitch;
		this.prevRotationYaw = this.rotationYaw;
		this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
		this.ticksInGround = 0;
	}
}
 
Example 20
Source Project: mocreaturesdev   Source File: MoCEntityMob.java    License: GNU General Public License v3.0 6 votes vote down vote up
public boolean getCanSpawnHereMob()
{
    int i = MathHelper.floor_double(posX);
    int j = MathHelper.floor_double(boundingBox.minY);
    int k = MathHelper.floor_double(posZ);
    if (worldObj.getSavedLightValue(EnumSkyBlock.Sky, i, j, k) > rand.nextInt(32)) { return false; }
    int l = worldObj.getBlockLightValue(i, j, k);
    if (worldObj.isThundering())
    {
        int i1 = worldObj.skylightSubtracted;
        worldObj.skylightSubtracted = 10;
        l = worldObj.getBlockLightValue(i, j, k);
        worldObj.skylightSubtracted = i1;
    }
    return l <= rand.nextInt(8);
}
 
Example 21
private void drawRune(double x, double y, double z, int rune, EntityPlayer player) {
    GL11.glPushMatrix();
    UtilsFX.bindTexture("textures/misc/script.png");
    float r = MathHelper.sin((player.ticksExisted + rune * 5) / 5.0F) * 0.1F + 0.88F;
    float g = MathHelper.sin((player.ticksExisted + rune * 5) / 7.0F) * 0.1F + 0.63F;
    float alpha = MathHelper.sin((player.ticksExisted + rune * 5) / 10.0F) * 0.2F;
    GL11.glColor4f(r, g, 0.2F, alpha + 0.6F);
    GL11.glRotated(90.0D, 0.0D, 0.0D, 1.0D);
    GL11.glTranslated(x, y, z);

    Tessellator tessellator = Tessellator.instance;
    float var8 = 0.0625F * rune;
    float var9 = var8 + 0.0625F;
    float var10 = 0.0F;
    float var11 = 1.0F;
    tessellator.startDrawingQuads();
    tessellator.setColorRGBA_F(r, g, 0.2F, alpha + 0.6F);
    tessellator.addVertexWithUV(-0.06D - alpha / 40.0F, 0.06D + alpha / 40.0F, 0.0D, var9, var11);
    tessellator.addVertexWithUV(0.06D + alpha / 40.0F, 0.06D + alpha / 40.0F, 0.0D, var9, var10);
    tessellator.addVertexWithUV(0.06D + alpha / 40.0F, -0.06D - alpha / 40.0F, 0.0D, var8, var10);
    tessellator.addVertexWithUV(-0.06D - alpha / 40.0F, -0.06D - alpha / 40.0F, 0.0D, var8, var11);
    tessellator.draw();
    GL11.glPopMatrix();
}
 
Example 22
public void faceLocation(int i, int j, int k, float f)
{
	double var4 = i + 0.5D - posX;
	double var8 = k + 0.5D - posZ;
	double var6 = j + 0.5D - posY;
	double var14 = (double) MathHelper.sqrt_double(var4 * var4 + var8 * var8);
	float var12 = (float) (Math.atan2(var8, var4) * 180.0D / Math.PI) - 90.0F;
	float var13 = (float) (-(Math.atan2(var6, var14) * 180.0D / Math.PI));
	this.rotationPitch = -this.updateRotation(this.rotationPitch, var13, f);
	this.rotationYaw = this.updateRotation(this.rotationYaw, var12, f);
}
 
Example 23
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
    int facing = MathHelper.floor_double(entity.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
    TileEntityEMT tile = (TileEntityEMT) world.getTileEntity(x, y, z);

    if (facing == 0)
        tile.facing = 2;
    else if (facing == 1)
        tile.facing = 5;
    else if (facing == 2)
        tile.facing = 3;
    else if (facing == 3)
        tile.facing = 4;
}
 
Example 24
Source Project: SkyblockAddons   Source File: ButtonGuiScale.java    License: MIT License 5 votes vote down vote up
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY) {
    if (this.visible) {
        if (this.dragging) {
            this.sliderValue = (float) (mouseX - (this.xPosition + 4)) / (float) (this.width - 8);
            this.sliderValue = MathHelper.clamp_float(sliderValue, 0.0F, 1.0F);
            main.getConfigValues().setGuiScale(feature, sliderValue);
            this.displayString = Message.SETTING_GUI_SCALE.getMessage(String.valueOf(getRoundedValue(main.getConfigValues().getGuiScale(feature))));
        }

        mc.getTextureManager().bindTexture(buttonTextures);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        drawRect(this.xPosition + (int) (this.sliderValue * (float) (this.width - 8))+1, this.yPosition, this.xPosition + (int) (this.sliderValue * (float) (this.width - 8))+7, this.yPosition + this.height, ChatFormatting.GRAY.getRGB());
    }
}
 
Example 25
Source Project: SkyblockAddons   Source File: ButtonSlider.java    License: MIT License 5 votes vote down vote up
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY) {
    if (this.visible) {
        if (this.dragging) {
            this.sliderValue = (float) (mouseX - (this.xPosition + 4)) / (float) (this.width - 8);
            this.sliderValue = MathHelper.clamp_float(sliderValue, 0.0F, 1.0F);
            valueUpdated();
        }

        mc.getTextureManager().bindTexture(buttonTextures);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        drawRect(this.xPosition + (int) (this.sliderValue * (float) (this.width - 8))+1, this.yPosition, this.xPosition + (int) (this.sliderValue * (float) (this.width - 8))+7, this.yPosition + this.height, ChatFormatting.GRAY.getRGB());
    }
}
 
Example 26
Source Project: mocreaturesdev   Source File: MoCEntityMob.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void getPathOrWalkableBlock(Entity entity, float f)
{
    PathEntity pathentity = worldObj.getPathEntityToEntity(this, entity, 16F, true, false, false, true);
    if ((pathentity == null) && (f > 12F))
    {
        int i = MathHelper.floor_double(entity.posX) - 2;
        int j = MathHelper.floor_double(entity.posZ) - 2;
        int k = MathHelper.floor_double(entity.boundingBox.minY);
        for (int l = 0; l <= 4; l++)
        {
            for (int i1 = 0; i1 <= 4; i1++)
            {
                if (((l < 1) || (i1 < 1) || (l > 3) || (i1 > 3)) && worldObj.isBlockNormalCube(i + l, k - 1, j + i1) && !worldObj.isBlockNormalCube(i + l, k, j + i1) && !worldObj.isBlockNormalCube(i + l, k + 1, j + i1))
                {
                    setLocationAndAngles((i + l) + 0.5F, k, (j + i1) + 0.5F, rotationYaw, rotationPitch);
                    return;
                }
            }

        }

    }
    else
    {
        setPathToEntity(pathentity);
    }
}
 
Example 27
public void faceItem(int i, int j, int k, float f)
{
	double d = i - posX;
	double d1 = k - posZ;
	double d2 = j - posY;
	double d3 = MathHelper.sqrt_double((d * d) + (d1 * d1));
	float f1 = (float) ((Math.atan2(d1, d) * 180D) / 3.1415927410125728D) - 90F;
	float f2 = (float) ((Math.atan2(d2, d3) * 180D) / 3.1415927410125728D);
	rotationPitch = -adjustRotation(rotationPitch, f2, f);
	rotationYaw = adjustRotation(rotationYaw, f1, f);
}
 
Example 28
public boolean getCanSpawnHereCreature()
{
	int i = MathHelper.floor_double(posX);
	int j = MathHelper.floor_double(boundingBox.minY);
	int k = MathHelper.floor_double(posZ);
	return getBlockPathWeight(i, j, k) >= 0.0F;
}
 
Example 29
Source Project: TickDynamic   Source File: Entity.java    License: MIT License 5 votes vote down vote up
protected void func_145775_I()
{
    int i = MathHelper.floor_double(this.boundingBox.minX + 0.001D);
    int j = MathHelper.floor_double(this.boundingBox.minY + 0.001D);
    int k = MathHelper.floor_double(this.boundingBox.minZ + 0.001D);
    int l = MathHelper.floor_double(this.boundingBox.maxX - 0.001D);
    int i1 = MathHelper.floor_double(this.boundingBox.maxY - 0.001D);
    int j1 = MathHelper.floor_double(this.boundingBox.maxZ - 0.001D);

    if (this.worldObj.checkChunksExist(i, j, k, l, i1, j1))
    {
        for (int k1 = i; k1 <= l; ++k1)
        {
            for (int l1 = j; l1 <= i1; ++l1)
            {
                for (int i2 = k; i2 <= j1; ++i2)
                {
                    Block block = this.worldObj.getBlock(k1, l1, i2);

                    try
                    {
                        block.onEntityCollidedWithBlock(this.worldObj, k1, l1, i2, this);
                    }
                    catch (Throwable throwable)
                    {
                        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Colliding entity with block");
                        CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being collided with");
                        CrashReportCategory.func_147153_a(crashreportcategory, k1, l1, i2, block, this.worldObj.getBlockMetadata(k1, l1, i2));
                        throw new ReportedException(crashreport);
                    }
                }
            }
        }
    }
}
 
Example 30
public void faceLocation(int i, int j, int k, float f)
{
	double var4 = i + 0.5D - posX;
	double var8 = k + 0.5D - posZ;
	double var6 = j + 0.5D - posY;
	double var14 = (double) MathHelper.sqrt_double(var4 * var4 + var8 * var8);
	float var12 = (float) (Math.atan2(var8, var4) * 180.0D / Math.PI) - 90.0F;
	float var13 = (float) (-(Math.atan2(var6, var14) * 180.0D / Math.PI));
	this.rotationPitch = -this.updateRotation(this.rotationPitch, var13, f);
	this.rotationYaw = this.updateRotation(this.rotationYaw, var12, f);
}