Java Code Examples for net.minecraft.util.MathHelper#sin()

The following examples show how to use net.minecraft.util.MathHelper#sin() . 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
Source File: AACPort.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onUpdate() {
    if(!MovementUtils.isMoving())
        return;

    final float f = mc.thePlayer.rotationYaw * 0.017453292F;
    for (double d = 0.2; d <= ((Speed) LiquidBounce.moduleManager.getModule(Speed.class)).portMax.get(); d += 0.2) {
        final double x = mc.thePlayer.posX - MathHelper.sin(f) * d;
        final double z = mc.thePlayer.posZ + MathHelper.cos(f) * d;

        if(mc.thePlayer.posY < (int) mc.thePlayer.posY + 0.5 && !(BlockUtils.getBlock(new BlockPos(x, mc.thePlayer.posY, z)) instanceof BlockAir))
            break;

        mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(x, mc.thePlayer.posY, z, true));
    }
}
 
Example 2
Source File: General.java    From Chisel with GNU General Public License v2.0 6 votes vote down vote up
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
{
    float var4 = 1.0F;
    float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
    float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
    double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * var4;
    double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * var4 + 1.62D - par2EntityPlayer.yOffset;
    double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * var4;
    //TODO- 1.7.10 fix?
    Vec3 var13 = Vec3.createVectorHelper(var7, var9, var11);
    float var14 = MathHelper.cos(-var6 * 0.017453292F - (float) Math.PI);
    float var15 = MathHelper.sin(-var6 * 0.017453292F - (float) Math.PI);
    float var16 = -MathHelper.cos(-var5 * 0.017453292F);
    float var17 = MathHelper.sin(-var5 * 0.017453292F);
    float var18 = var15 * var16;
    float var20 = var14 * var16;
    double var21 = 5.0D;

    if(par2EntityPlayer instanceof EntityPlayerMP)
    {
        var21 = ((EntityPlayerMP) par2EntityPlayer).theItemInWorldManager.getBlockReachDistance();
    }

    Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);
    return par1World.rayTraceBlocks(var13, var23, par3);
}
 
Example 3
Source File: MoCEntityCrocodile.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void jump()
{

    if (isInsideOfMaterial(Material.water)) // super.jump();
    {
        if (getHasCaughtPrey() || (entityToAttack == null && rand.nextInt(20) != 0)) { return;
        // if (entityToAttack == null)
        }

        motionY = 0.3D;
        if (isSprinting())
        {
            float f = rotationYaw * 0.01745329F;
            motionX -= MathHelper.sin(f) * 0.2F;
            motionZ += MathHelper.cos(f) * 0.2F;
        }
        isAirBorne = true;

    }
    else if (entityToAttack != null || getHasCaughtPrey())
    {
        super.jump();
    }
}
 
Example 4
Source File: MoCModelElephant.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Used for trunk adjustment - lateral movement
 * 
 * @param target
 *            : target model
 * @param origin
 *            : origin model
 */
private void adjustYRotationPoints(ModelRenderer target, ModelRenderer origin)
{
    //rotation point Z and X adjusted for head =
    //Z rotation point = attached rotation point Z - cos(attached.rotateangleX) * distance 
    //Y rotation point = attached rotation point Y - sin(attached.rotateangleX) * distance 
    float distanceZ = 0F;
    if (target.rotationPointZ > origin.rotationPointZ)
    {
        distanceZ = target.rotationPointZ - origin.rotationPointZ;
    }
    else
    {
        distanceZ = origin.rotationPointZ - target.rotationPointZ;
    }
    /*float distanceZ = target.rotationPointZ - origin.rotationPointZ;
    if (distanceZ < 0F)
    {
        distanceZ *= -1F;
    }*/
    target.rotationPointZ = origin.rotationPointZ - (MathHelper.cos(origin.rotateAngleY) * distanceZ);
    target.rotationPointX = origin.rotationPointX - (MathHelper.sin(origin.rotateAngleY) * distanceZ);

}
 
Example 5
Source File: MixinEntityLivingBase.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @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 6
Source File: General.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3) {
	float var4 = 1.0F;
	float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
	float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
	double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * var4;
	double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * var4 + 1.62D - par2EntityPlayer.yOffset;
	double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * var4;
	// TODO- 1.7.10 fix?
	Vec3 var13 = Vec3.createVectorHelper(var7, var9, var11);
	float var14 = MathHelper.cos(-var6 * 0.017453292F - (float) Math.PI);
	float var15 = MathHelper.sin(-var6 * 0.017453292F - (float) Math.PI);
	float var16 = -MathHelper.cos(-var5 * 0.017453292F);
	float var17 = MathHelper.sin(-var5 * 0.017453292F);
	float var18 = var15 * var16;
	float var20 = var14 * var16;
	double var21 = 5.0D;

	if (par2EntityPlayer instanceof EntityPlayerMP) {
		var21 = ((EntityPlayerMP) par2EntityPlayer).theItemInWorldManager.getBlockReachDistance();
	}

	Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);
	return par1World.rayTraceBlocks(var13, var23, par3);
}
 
Example 7
Source File: MoCModelWraith.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity par7Entity)
{
    //super.setRotationAngles(f, f1, f2, f3, f4, f5);
    float f6 = MathHelper.sin(onGround * 3.141593F);
    float f7 = MathHelper.sin((1.0F - ((1.0F - onGround) * (1.0F - onGround))) * 3.141593F);
    bipedRightArm.rotateAngleZ = 0.0F;
    bipedLeftArm.rotateAngleZ = 0.0F;
    bipedRightArm.rotateAngleY = -(0.1F - (f6 * 0.6F));
    bipedLeftArm.rotateAngleY = 0.1F - (f6 * 0.6F);
    bipedRightArm.rotateAngleX = -1.570796F;
    bipedLeftArm.rotateAngleX = -1.570796F;
    bipedRightArm.rotateAngleX -= (f6 * 1.2F) - (f7 * 0.4F);
    bipedLeftArm.rotateAngleX -= (f6 * 1.2F) - (f7 * 0.4F);
    bipedRightArm.rotateAngleZ += (MathHelper.cos(f2 * 0.09F) * 0.05F) + 0.05F;
    bipedLeftArm.rotateAngleZ -= (MathHelper.cos(f2 * 0.09F) * 0.05F) + 0.05F;
    bipedRightArm.rotateAngleX += MathHelper.sin(f2 * 0.067F) * 0.05F;
    bipedLeftArm.rotateAngleX -= MathHelper.sin(f2 * 0.067F) * 0.05F;
}
 
Example 8
Source File: EntityLaser.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
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 9
Source File: MoCModelElephant.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Used for leg adjustment - anteroposterior movement
 * 
 * @param target
 * @param attached
 */
private void adjustXRotationPoints(ModelRenderer target, ModelRenderer origin)
{
    //rotation point Z and Y adjusted for legs =
    //Z rotation point = attached rotation point Z + sin(attached.rotateangleX) * distance 
    //Y rotation point = attached rotation point Y + cos(attached.rotateangleX) * distance 
    float distance = target.rotationPointY - origin.rotationPointY;
    if (distance < 0F)
    {
        distance *= -1F;
    }
    target.rotationPointZ = origin.rotationPointZ + (MathHelper.sin(origin.rotateAngleX) * distance);
    target.rotationPointY = origin.rotationPointY + (MathHelper.cos(origin.rotateAngleX) * distance);

}
 
Example 10
Source File: TileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
private void playEssentiaEffects() {
    if ((ClientHandler.ticks % 20 == 0) && (al.size() > 0)) {
        this.displayAspect = al.getAspects()[(ClientHandler.ticks / 20 % al.size())];
        Color c = new Color(this.displayAspect.getColor());
        this.tr = (c.getRed() / 255.0F);
        this.tg = (c.getGreen() / 255.0F);
        this.tb = (c.getBlue() / 255.0F);
        this.tri = ((this.cr - this.tr) / 20.0F);
        this.tgi = ((this.cg - this.tg) / 20.0F);
        this.tbi = ((this.cb - this.tb) / 20.0F);
    }
    if (this.displayAspect == null) {
        this.tr = (this.tg = this.tb = 1.0F);
        this.tri = (this.tgi = this.tbi = 0.0F);
    } else {
        this.cr -= this.tri;
        this.cg -= this.tgi;
        this.cb -= this.tbi;
    }
    int count = 1;
    cr = Math.min(1.0F, Math.max(0.0F, cr));
    cg = Math.min(1.0F, Math.max(0.0F, cg));
    cb = Math.min(1.0F, Math.max(0.0F, cb));
    FXEssentiaTrail essentiaTrail = new FXEssentiaTrail(worldObj, xCoord + 0.5, yCoord + 0.4, zCoord + 0.5, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, count, new Color(cr, cg, cb).getRGB(), 0.8F);
    essentiaTrail.noClip = true;
    essentiaTrail.motionY = (0.01F + MathHelper.sin(count / 3.0F) * 0.001F);
    essentiaTrail.motionX = (MathHelper.sin(count / 10.0F) * 0.01F + worldObj.rand.nextGaussian() * 0.01D);
    essentiaTrail.motionZ = (MathHelper.sin(count / 10.0F) * 0.01F + worldObj.rand.nextGaussian() * 0.01D);
    ParticleEngine.instance.addEffect(worldObj, essentiaTrail);

    essentiaTrail = new FXEssentiaTrail(worldObj, xCoord + 0.5, yCoord + 2.6, zCoord + 0.5, xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, count, new Color(cr, cg, cb).getRGB(), 0.8F);
    essentiaTrail.noClip = true;
    essentiaTrail.motionY = -(0.01F + MathHelper.sin(count / 3.0F) * 0.001F);
    essentiaTrail.motionX = (MathHelper.sin(count / 10.0F) * 0.01F + worldObj.rand.nextGaussian() * 0.01D);
    essentiaTrail.motionZ = (MathHelper.sin(count / 10.0F) * 0.01F + worldObj.rand.nextGaussian() * 0.01D);
    ParticleEngine.instance.addEffect(worldObj, essentiaTrail);
}
 
Example 11
Source File: SearchUpgradeHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void render3D(float partialTicks){
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderManager.instance.renderEngine.bindTexture(Textures.GLOW_RESOURCE);
    //  mc.func_110434_K().func_110577_a(Textures.GLOW_RESOURCE);
    for(Map.Entry<EntityItem, Integer> entry : searchedItems.entrySet()) {
        EntityItem item = entry.getKey();
        float height = MathHelper.sin((item.age + partialTicks) / 10.0F + item.hoverStart) * 0.1F + 0.2F;
        RenderSearchItemBlock.renderSearch(item.lastTickPosX + (item.posX - item.lastTickPosX) * partialTicks, item.lastTickPosY + (item.posY - item.lastTickPosY) * partialTicks + height, item.lastTickPosZ + (item.posZ - item.lastTickPosZ) * partialTicks, entry.getValue(), totalSearchedItemCount);
    }
    for(int i = 0; i < searchedBlocks.size(); i++) {
        if(!searchedBlocks.get(i).renderSearchBlock(totalSearchedItemCount)) {
            searchedBlocks.remove(i);
            i--;
        }
    }
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
}
 
Example 12
Source File: StaticTrailAnimation.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public List<Vec3> render(EntityPlayer player, double x, double y, double z) {
    ArrayList<Vec3> vec3s;
    float rotationYaw = player.rotationYawHead;
    rotationYaw -= 90;
    Vec3 base = new Vec3(x + MathHelper.cos((float) Math.toRadians(rotationYaw)), y + 1.8D, z + MathHelper.sin((float) Math.toRadians(rotationYaw)));
    ArrayList<Vec3> result = new ArrayList<>();
    for (int i = 0; i < 4; i++) {
        Vec3 vec3 = base.addVector(0, -.4 * i, 0);
        result.add(vec3);
    }
    vec3s = result;
    return vec3s;
}
 
Example 13
Source File: RenderUtils.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void drawFilledCircle(int x, int y, float radius, int color) {
    GlStateManager.pushAttrib();
    GlStateManager.pushMatrix();
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.disableTexture2D();

    GL11.glBegin(GL11.GL_TRIANGLE_FAN);

    for (int i = 0; i < 50; i++) {
        float px = x + radius * MathHelper.sin((float) (i * (6.28318530718 / 50)));
        float py = y + radius * MathHelper.cos((float) (i * (6.28318530718 / 50)));

        float alpha = (color >> 24 & 255) / 255.0F;
        float red = (color >> 16 & 255) / 255.0F;
        float green = (color >> 8 & 255) / 255.0F;
        float blue = (color & 255) / 255.0F;
        GL11.glColor4f(red, green, blue, alpha);

        GL11.glVertex2d(px, py);
    }

    GL11.glEnd();

    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
    GlStateManager.popAttrib();
    GlStateManager.popMatrix();
    GlStateManager.bindTexture(0);
    GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
}
 
Example 14
Source File: Phase.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@EventTarget
public void onPacket(final PacketEvent event) {
    final Packet<?> packet = event.getPacket();

    if(packet instanceof C03PacketPlayer) {
        final C03PacketPlayer packetPlayer = (C03PacketPlayer) packet;

        if(modeValue.get().equalsIgnoreCase("AAC3.5.0")) {
            final float yaw = (float) MovementUtils.getDirection();

            packetPlayer.x = packetPlayer.x - MathHelper.sin(yaw) * 0.00000001D;
            packetPlayer.z = packetPlayer.z + MathHelper.cos(yaw) * 0.00000001D;
        }
    }
}
 
Example 15
Source File: MoCModelElephant.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
private void adjustAllRotationPoints(ModelRenderer target, ModelRenderer origin)
{

    float distanceY = 0F;
    if (target.rotationPointY > origin.rotationPointY)
    {
        distanceY = target.rotationPointY - origin.rotationPointY;
    }
    else
    {
        distanceY = origin.rotationPointY - target.rotationPointY;
    }

    float distanceZ = 0F;
    if (target.rotationPointZ > origin.rotationPointZ)
    {
        distanceZ = target.rotationPointZ - origin.rotationPointZ;
    }
    else
    {
        distanceZ = origin.rotationPointZ - target.rotationPointZ;
    }

    target.rotationPointY = origin.rotationPointY + MathHelper.sin(origin.rotateAngleX) * distanceY;
    target.rotationPointZ = origin.rotationPointZ - MathHelper.cos(origin.rotateAngleY) * (MathHelper.cos(origin.rotateAngleX) * distanceY);
    target.rotationPointX = origin.rotationPointX - MathHelper.sin(origin.rotateAngleY) * (MathHelper.cos(origin.rotateAngleX) * distanceY);

    
}
 
Example 16
Source File: EntityTippedArrow.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public void readSpawnData(ByteBuf buffer) {
	rotationYaw = buffer.readFloat();
	shootingEntity = worldObj.getEntityByID(buffer.readInt());

	motionX = buffer.readDouble();
	motionY = buffer.readDouble();
	motionZ = buffer.readDouble();

	posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
	posY -= 0.10000000149011612D;
	posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;

	effect = new PotionEffect(buffer.readInt(), buffer.readInt(), buffer.readInt());
}
 
Example 17
Source File: AACHop3313.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUpdate() {
    if (!MovementUtils.isMoving() || mc.thePlayer.isInWater() || mc.thePlayer.isInLava() ||
            mc.thePlayer.isOnLadder() || mc.thePlayer.isRiding() || mc.thePlayer.hurtTime > 0)
        return;

    if (mc.thePlayer.onGround && mc.thePlayer.isCollidedVertically) {
        // MotionXYZ
        float yawRad = mc.thePlayer.rotationYaw * 0.017453292F;
        mc.thePlayer.motionX -= MathHelper.sin(yawRad) * 0.202F;
        mc.thePlayer.motionZ += MathHelper.cos(yawRad) * 0.202F;
        mc.thePlayer.motionY = 0.405F;
        LiquidBounce.eventManager.callEvent(new JumpEvent(0.405F));
        MovementUtils.strafe();
    } else if (mc.thePlayer.fallDistance < 0.31F) {
        if (BlockUtils.getBlock(mc.thePlayer.getPosition()) instanceof BlockCarpet) // why?
            return;

        // Motion XZ
        mc.thePlayer.jumpMovementFactor = mc.thePlayer.moveStrafing == 0F ? 0.027F : 0.021F;
        mc.thePlayer.motionX *= 1.001;
        mc.thePlayer.motionZ *= 1.001;

        // Motion Y
        if (!mc.thePlayer.isCollidedHorizontally)
            mc.thePlayer.motionY -= 0.014999993F;
    } else
        mc.thePlayer.jumpMovementFactor = 0.02F;
}
 
Example 18
Source File: ItemThorHammer.java    From Electro-Magic-Tools with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) {
    player.swingItem();
    float f = 1.0F;
    float f1 = player.prevRotationPitch + ((player.rotationPitch - player.prevRotationPitch) * f);
    float f2 = player.prevRotationYaw + ((player.rotationYaw - player.prevRotationYaw) * f);
    double d = player.prevPosX + ((player.posX - player.prevPosX) * f);
    double d1 = (player.prevPosY + ((player.posY - player.prevPosY) * f) + 1.6200000000000001D) - player.yOffset;
    double d2 = player.prevPosZ + ((player.posZ - player.prevPosZ) * f);
    Vec3 vec3d = Vec3.createVectorHelper(d, d1, d2);
    float f3 = MathHelper.cos((-f2 * 0.01745329F) - 3.141593F);
    float f4 = MathHelper.sin((-f2 * 0.01745329F) - 3.141593F);
    float f5 = -MathHelper.cos(-f1 * 0.01745329F);
    float f6 = MathHelper.sin(-f1 * 0.01745329F);
    float f7 = f4 * f5;
    float f8 = f6;
    float f9 = f3 * f5;
    double d3 = 5000D;
    Vec3 vec3d1 = vec3d.addVector(f7 * d3, f8 * d3, f9 * d3);
    MovingObjectPosition movingobjectposition = player.worldObj.rayTraceBlocks(vec3d, vec3d1, true);
    if (movingobjectposition == null) {
        return itemstack;
    }
    if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK) {
        int i = movingobjectposition.blockX;
        int j = movingobjectposition.blockY;
        int k = movingobjectposition.blockZ;
        world.spawnEntityInWorld(new EntityLightningBolt(world, i, j, k));
    } else if (movingobjectposition.typeOfHit == MovingObjectType.ENTITY) {
        Entity entityhit = movingobjectposition.entityHit;
        double x = entityhit.posX;
        double y = entityhit.posY;
        double z = entityhit.posZ;
        world.spawnEntityInWorld(new EntityLightningBolt(world, x, y, z));
    }
    if (player.capabilities.isCreativeMode) {
        return itemstack;
    } else {
        itemstack.damageItem(20, player);
        return itemstack;
    }
}
 
Example 19
Source File: ItemNodeRenderer.java    From Gadomancy with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void renderItemNode(INode node) {
    if (node.getAspects().size() > 0) {
        EntityLivingBase viewer = Minecraft.getMinecraft().renderViewEntity;
        float alpha = 0.5F;
        if (node.getNodeModifier() != null) {
            switch (node.getNodeModifier()) {
                case BRIGHT:
                    alpha *= 1.5F;
                    break;
                case PALE:
                    alpha *= 0.66F;
                    break;
                case FADING:
                    alpha *= (MathHelper.sin(viewer.ticksExisted / 3.0F) * 0.25F + 0.33F);
            }
        }
        GL11.glPushMatrix();
        GL11.glAlphaFunc(516, 0.003921569F);
        GL11.glDepthMask(false);
        GL11.glDisable(2884);
        long nt = System.nanoTime();
        long time = nt / 5000000L;
        float bscale = 0.25F;

        GL11.glPushMatrix();
        float rad = 6.283186F;
        GL11.glColor4f(1.0F, 1.0F, 1.0F, alpha);

        UtilsFX.bindTexture(TileNodeRenderer.nodetex);
        int frames = 32;
        int i = (int) ((nt / 40000000L + 1L) % frames);

        int count = 0;
        float scale = 0.0F;
        float average = 0.0F;
        for (Aspect aspect : node.getAspects().getAspects()) {
            if (aspect.getBlend() == 771) {
                alpha = (float) (alpha * 1.5D);
            }
            average += node.getAspects().getAmount(aspect);
            GL11.glPushMatrix();
            GL11.glEnable(3042);
            GL11.glBlendFunc(770, aspect.getBlend());
            scale = MathHelper.sin(viewer.ticksExisted / (14.0F - count)) * bscale + bscale * 2.0F;
            scale = 0.2F + scale * (node.getAspects().getAmount(aspect) / 50.0F);
            UtilsFX.renderAnimatedQuadStrip(scale, alpha / node.getAspects().size(), frames, 0, i, 0.0F, aspect.getColor());
            GL11.glDisable(3042);
            GL11.glPopMatrix();
            count++;
            if (aspect.getBlend() == 771) {
                alpha = (float) (alpha / 1.5D);
            }
        }
        average /= node.getAspects().size();
        GL11.glPushMatrix();
        GL11.glEnable(3042);
        i = (int) ((nt / 40000000L + 1L) % frames);
        scale = 0.1F + average / 150.0F;
        int strip = 1;
        switch (node.getNodeType()) {
            case NORMAL:
                GL11.glBlendFunc(770, 1);
                break;
            case UNSTABLE:
                GL11.glBlendFunc(770, 1);
                strip = 6;
                break;
            case DARK:
                GL11.glBlendFunc(770, 771);
                strip = 2;
                break;
            case TAINTED:
                GL11.glBlendFunc(770, 771);
                strip = 5;
                break;
            case PURE:
                GL11.glBlendFunc(770, 1);
                strip = 4;
                break;
            case HUNGRY:
                scale *= 0.75F;
                GL11.glBlendFunc(770, 1);
                strip = 3;
        }
        GL11.glColor4f(1.0F, 0.0F, 1.0F, alpha);
        UtilsFX.renderAnimatedQuadStrip(scale, alpha, frames, strip, i, 0.0F, 16777215);

        GL11.glDisable(3042);
        GL11.glPopMatrix();

        GL11.glPopMatrix();

        GL11.glEnable(2884);
        GL11.glDepthMask(true);
        GL11.glAlphaFunc(516, 0.1F);
        GL11.glPopMatrix();
    }
}
 
Example 20
Source File: ItemMaterials.java    From Electro-Magic-Tools with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (stack != null && stack.getItemDamage() == 6) {
        player.swingItem();
        float f = 1.0F;
        float f1 = player.prevRotationPitch + ((player.rotationPitch - player.prevRotationPitch) * f);
        float f2 = player.prevRotationYaw + ((player.rotationYaw - player.prevRotationYaw) * f);
        double d = player.prevPosX + ((player.posX - player.prevPosX) * f);
        double d1 = (player.prevPosY + ((player.posY - player.prevPosY) * f) + 1.6200000000000001D) - player.yOffset;
        double d2 = player.prevPosZ + ((player.posZ - player.prevPosZ) * f);
        Vec3 vec3d = Vec3.createVectorHelper(d, d1, d2);
        float f3 = MathHelper.cos((-f2 * 0.01745329F) - 3.141593F);
        float f4 = MathHelper.sin((-f2 * 0.01745329F) - 3.141593F);
        float f5 = -MathHelper.cos(-f1 * 0.01745329F);
        float f6 = MathHelper.sin(-f1 * 0.01745329F);
        float f7 = f4 * f5;
        float f8 = f6;
        float f9 = f3 * f5;
        double d3 = 5000D;
        Vec3 vec3d1 = vec3d.addVector(f7 * d3, f8 * d3, f9 * d3);
        MovingObjectPosition movingobjectposition = player.worldObj.rayTraceBlocks(vec3d, vec3d1, true);
        if (movingobjectposition == null) {
            return stack;
        }
        if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK) {
            int i = movingobjectposition.blockX;
            int j = movingobjectposition.blockY;
            int k = movingobjectposition.blockZ;
            world.spawnEntityInWorld(new EntityLightningBolt(world, i, j, k));
        } else if (movingobjectposition.typeOfHit == MovingObjectType.ENTITY) {
            Entity entityhit = movingobjectposition.entityHit;
            double x = entityhit.posX;
            double y = entityhit.posY;
            double z = entityhit.posZ;
            world.spawnEntityInWorld(new EntityLightningBolt(world, x, y, z));
        }
        if (player.capabilities.isCreativeMode) {
            return stack;
        } else {
            player.inventory.consumeInventoryItem(this);
            return stack;
        }
    }
    return stack;
}