net.minecraft.util.MathHelper Java Examples

The following examples show how to use net.minecraft.util.MathHelper. 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: MoCEntityKitty.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@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 #2
Source File: MoCModelBunny.java    From mocreaturesdev with 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 #3
Source File: MoCModelMouse.java    From mocreaturesdev with 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 #4
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 #5
Source File: ModelWandPart.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #6
Source File: RailTools.java    From NEI-Integration with 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 #7
Source File: QuadTwirlAnimation.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #8
Source File: MoCTools.java    From mocreaturesdev with 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 #9
Source File: VortexOfDoomAnimation.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #10
Source File: MoCEntityBigCat.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
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 #11
Source File: ItemShieldFocus.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@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 #12
Source File: BlockWalrus.java    From ExtraCells1 with 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 #13
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 #14
Source File: PlaceTraps.java    From Artifacts with 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 #15
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 #16
Source File: WidgetVerticalScrollbar.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@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 #17
Source File: MoCEntityMob.java    From mocreaturesdev with 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 #18
Source File: EntityLaser.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@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 #19
Source File: TileAuraPylon.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #20
Source File: ItemNanoGoggles.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@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 #21
Source File: Projectiles.java    From ehacks-pro with 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 #22
Source File: ModelEndermite.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
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 p_78087_7_) {
	for (int i = 0; i < field_178713_d.length; ++i) {
		field_178713_d[i].rotateAngleY = MathHelper.cos(p_78087_3_ * 0.9F + i * 0.15F * (float) Math.PI) * (float) Math.PI * 0.01F * (1 + Math.abs(i - 2));
		field_178713_d[i].rotationPointX = MathHelper.sin(p_78087_3_ * 0.9F + i * 0.15F * (float) Math.PI) * (float) Math.PI * 0.1F * Math.abs(i - 2);
	}
}
 
Example #23
Source File: EntityChaosMonkey.java    From mobycraft with Apache License 2.0 5 votes vote down vote up
protected void updateAITasks() {
	super.updateAITasks();
	{
		if (this.spawnPosition != null
				&& (!this.worldObj.isAirBlock(this.spawnPosition) || this.spawnPosition
						.getY() < 1)) {
			this.spawnPosition = null;
		}

		if (this.spawnPosition == null
				|| this.rand.nextInt(30) == 0
				|| this.spawnPosition.distanceSq(
						(double) ((int) this.posX),
						(double) ((int) this.posY),
						(double) ((int) this.posZ)) < 4.0D) {
			this.spawnPosition = new BlockPos((int) this.posX
					+ this.rand.nextInt(7) - this.rand.nextInt(7),
					(int) this.posY + this.rand.nextInt(6) - 2,
					(int) this.posZ + this.rand.nextInt(7)
							- this.rand.nextInt(7));
		}

		double d0 = (double) this.spawnPosition.getX() + 0.5D - this.posX;
		double d1 = (double) this.spawnPosition.getY() + 0.1D - this.posY;
		double d2 = (double) this.spawnPosition.getZ() + 0.5D - this.posZ;
		this.motionX += (Math.signum(d0) * 0.5D - this.motionX) * 0.10000000149011612D;
		this.motionY += (Math.signum(d1) * 0.699999988079071D - this.motionY) * 0.10000000149011612D;
		this.motionZ += (Math.signum(d2) * 0.5D - this.motionZ) * 0.10000000149011612D;
		float f = (float) (MathHelper.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) - 90.0F;
		float f1 = MathHelper.wrapAngleTo180_float(f - this.rotationYaw);
		this.moveForward = 0.5F;
		this.rotationYaw += f1;
	}
}
 
Example #24
Source File: MoCEntityAmbient.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
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 #25
Source File: DoubleHelix.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) {
    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);

    for (int i = 0; i < 50; i++) {
        l += Math.PI / 500 * i;
        list.add(vec3.addVector(MathHelper.cos((float) l), -.03D * i, MathHelper.sin(((float) l))));
    }

    return list;
}
 
Example #26
Source File: RenderUtils.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void drawArc(float cx, float cy, float r, float startAngle, float angle, int segments, int color) {
    float red = (float) (color >> 16 & 0xFF) / 255F;
    float green = (float) (color >> 8 & 0xFF) / 255F;
    float blue = (float) (color & 0xFF) / 255F;
    float alpha = (float) (color >> 24 & 0xFF) / 255F;

    float theta = angle / (float) (segments - 1);

    double tf = Math.tan(theta);
    float rf = MathHelper.cos(theta);

    float x = r * MathHelper.cos(startAngle);
    float y = r * MathHelper.sin(startAngle);

    GlStateManager.pushMatrix();
    GlStateManager.color(red, green, blue, alpha);
    GL11.glBegin(GL_LINE_STRIP);
    for (int ii = 0; ii < segments; ii++) {
        GL11.glVertex2f(x + cx, y + cy);

        float tx = -y;
        float ty = x;

        x += tx * tf;
        y += ty * tf;

        x *= rf;
        y *= rf;
    }
    GL11.glEnd();
    GlStateManager.popMatrix();
}
 
Example #27
Source File: MoCModelCricket.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, boolean isFlying)
{

    float legMov = 0F;
    float legMovB = 0F;

    float frontLegAdj = 0F;

    if (isFlying)
    {
        float WingRot = MathHelper.cos((f2 * 2.0F)) * 0.7F;
        RightWing.rotateAngleZ = WingRot;
        LeftWing.rotateAngleZ = -WingRot;
        legMov = (f1 * 1.5F);
        legMovB = legMov;
        frontLegAdj = 1.4F;

    }
    else
    {
        legMov = MathHelper.cos((f * 1.5F) + 3.141593F) * 2.0F * f1;
        legMovB = MathHelper.cos(f * 1.5F) * 2.0F * f1;
    }

    AntennaB.rotateAngleX = 2.88506F - legMov;

    FrontLegs.rotateAngleX = -0.8328009F + frontLegAdj + legMov;
    MidLegs.rotateAngleX = 1.070744F + legMovB;

}
 
Example #28
Source File: BlockArcaneDropper.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
    int metadata = world.getBlockMetadata(x, y, z);

    ForgeDirection side = ForgeDirection.getOrientation(metadata);

    float yaw = MathHelper.wrapAngleTo180_float(entity.rotationYaw);
    float pitch = entity.rotationPitch;

    boolean flipped;
    if(side == ForgeDirection.UP || side == ForgeDirection.DOWN) {
        yaw += 180;
        flipped = yaw > 315 || yaw < 45 || (yaw < 225 && yaw > 135);
    } else {
        switch (side.getOpposite()) {
            case WEST:
                yaw -= 90;
                break;
            case NORTH:
                yaw = (180 - Math.abs(yaw)) * (yaw < 0 ? 1 : -1);
                break;
            case EAST:
                yaw += 90;
                break;
        }
        flipped = Math.abs(yaw) < Math.abs(pitch);
    }

    metadata |= flipped ? 8 : 0;
    world.setBlockMetadataWithNotify(x, y, z, metadata, 2);
}
 
Example #29
Source File: MoCRenderCrocodile.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
protected void spinCroc(MoCEntityCrocodile croc, EntityLiving prey)
{
    int intSpin = croc.spinInt;

    int direction = 1;
    if (intSpin > 40)
    {
        intSpin -= 40;
        direction = -1;
    }
    int intEndSpin = intSpin;
    if (intSpin >= 20)
    {
        intEndSpin = (20 - (intSpin - 20));
    }
    if (intEndSpin == 0)
    {
        intEndSpin = 1;
    }
    float f3 = ((((float) intEndSpin) - 1.0F) / 20F) * 1.6F;
    f3 = MathHelper.sqrt_float(f3);
    if (f3 > 1.0F)
    {
        f3 = 1.0F;
    }
    f3 *= direction;
    GL11.glRotatef(f3 * 90F, 0.0F, 0.0F, 1.0F);

    if (prey != null)
    {
        prey.deathTime = intEndSpin;
    }
}
 
Example #30
Source File: OverlayChecker.java    From mapwriter with MIT License 5 votes vote down vote up
@Override
public ArrayList<IMwChunkOverlay> getChunksOverlay(int dim, double centerX, double centerZ, double minX, double minZ, double maxX, double maxZ) {
	
	// We should pass the center of the map too to reduce the display like in this case
	// and the zoom lvl, to provide higher level informations
	
	int minChunkX = (MathHelper.ceiling_double_int(minX) >> 4) - 1;
	int minChunkZ = (MathHelper.ceiling_double_int(minZ) >> 4) - 1;
	int maxChunkX = (MathHelper.ceiling_double_int(maxX) >> 4) + 1;
	int maxChunkZ = (MathHelper.ceiling_double_int(maxZ) >> 4) + 1;
	int cX = (MathHelper.ceiling_double_int(centerX) >> 4) + 1;
	int cZ = (MathHelper.ceiling_double_int(centerZ) >> 4) + 1;
	
	int limitMinX = Math.max(minChunkX, cX - 100);
	int limitMaxX = Math.min(maxChunkX, cX + 100);
	int limitMinZ = Math.max(minChunkZ, cZ - 100);
	int limitMaxZ = Math.min(maxChunkZ, cZ + 100);
	
	ArrayList<IMwChunkOverlay> chunks = new ArrayList<IMwChunkOverlay>();
	for (int x = limitMinX; x <= limitMaxX; x++)
		for (int z = limitMinZ; z <= limitMaxZ; z++){
				if ((x+z)%2 == 0)
					chunks.add(new ChunkOverlay(x, z));	
			};				
			
	return chunks;
}