Search in sources :

Example 76 with Vector3

use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.

the class NetworkRenderer method renderNetworks.

public static void renderNetworks(World world, float partialTicks) {
    List<TileEntityBeamOutput> nodes = new ArrayList<TileEntityBeamOutput>();
    for (Object o : new ArrayList<TileEntity>(world.loadedTileEntityList)) {
        if (o instanceof TileEntityBeamOutput) {
            nodes.add((TileEntityBeamOutput) o);
        }
    }
    if (nodes.isEmpty()) {
        return;
    }
    Tessellator tess = Tessellator.getInstance();
    EntityPlayerSP player = FMLClientHandler.instance().getClient().thePlayer;
    double interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
    double interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
    double interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    for (TileEntityBeamOutput tileEntity : nodes) {
        if (tileEntity.getTarget() == null) {
            continue;
        }
        GL11.glPushMatrix();
        Vector3 outputPoint = tileEntity.getOutputPoint(true);
        Vector3 targetInputPoint = tileEntity.getTarget().getInputPoint();
        Vector3 direction = Vector3.subtract(outputPoint, targetInputPoint);
        float directionLength = (float) direction.getMagnitude();
        float posX = (float) (tileEntity.getPos().getX() - interpPosX);
        float posY = (float) (tileEntity.getPos().getY() - interpPosY);
        float posZ = (float) (tileEntity.getPos().getZ() - interpPosZ);
        GL11.glTranslatef(posX, posY, posZ);
        GL11.glTranslatef(outputPoint.floatX() - tileEntity.getPos().getX(), outputPoint.floatY() - tileEntity.getPos().getY(), outputPoint.floatZ() - tileEntity.getPos().getZ());
        GL11.glRotatef(tileEntity.yaw + 180, 0, 1, 0);
        GL11.glRotatef(-tileEntity.pitch, 1, 0, 0);
        GL11.glRotatef(tileEntity.ticks * 10, 0, 0, 1);
        tess.getWorldRenderer().begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
        for (EnumFacing dir : EnumFacing.VALUES) {
            tess.getWorldRenderer().pos(dir.getFrontOffsetX() / 40.0F, dir.getFrontOffsetY() / 40.0F, dir.getFrontOffsetZ() / 40.0F).color(tileEntity.getColor().floatX(), tileEntity.getColor().floatY(), tileEntity.getColor().floatZ(), 1.0F).endVertex();
            tess.getWorldRenderer().pos(dir.getFrontOffsetX() / 40.0F, dir.getFrontOffsetY() / 40.0F, directionLength + dir.getFrontOffsetZ() / 40.0F).color(tileEntity.getColor().floatX(), tileEntity.getColor().floatY(), tileEntity.getColor().floatZ(), 1.0F).endVertex();
        }
        tess.draw();
        GL11.glPopMatrix();
    }
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glColor4f(1, 1, 1, 1);
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) TileEntityBeamOutput(micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityBeamOutput) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Example 77 with Vector3

use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.

the class ColorUtil method interpolateInArray.

private static Vector3 interpolateInArray(Vector3[] array, int i, double mu) {
    Vector3 point0 = array[i + 1];
    Vector3 point1 = array[i];
    Vector3 point2 = array[i - 1];
    Vector3 point3 = array[i - 2];
    double x = cubicInterpolate(point0.x, point1.x, point2.x, point3.x, mu);
    double y = cubicInterpolate(point0.y, point1.y, point2.y, point3.y, mu);
    double z = cubicInterpolate(point0.z, point1.z, point2.z, point3.z, mu);
    return new Vector3(x, y, z);
}
Also used : Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 78 with Vector3

use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.

the class TileEntityBeamReceiver method getOutputPoint.

@Override
public Vector3 getOutputPoint(boolean offset) {
    Vector3 headVec = new Vector3(this.getPos().getX() + 0.5, this.getPos().getY() + 0.5, this.getPos().getZ() + 0.5);
    if (this.facing != null) {
        headVec.x += this.facing.getFrontOffsetX() * 0.1F;
        headVec.y += this.facing.getFrontOffsetY() * 0.1F;
        headVec.z += this.facing.getFrontOffsetZ() * 0.1F;
    }
    return headVec;
}
Also used : Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 79 with Vector3

use of micdoodle8.mods.galacticraft.api.vector.Vector3 in project Galacticraft by micdoodle8.

the class EntityTier2Rocket method spawnParticles.

protected void spawnParticles(boolean launched) {
    if (!this.isDead) {
        double sinPitch = Math.sin(this.rotationPitch / Constants.RADIANS_TO_DEGREES_D);
        double x1 = 2.9 * Math.cos(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * sinPitch;
        double z1 = 2.9 * Math.sin(this.rotationYaw / Constants.RADIANS_TO_DEGREES_D) * sinPitch;
        double y1 = 2.9 * Math.cos((this.rotationPitch - 180) / Constants.RADIANS_TO_DEGREES_D);
        if (this.launchPhase == EnumLaunchPhase.LANDING.ordinal() && this.targetVec != null) {
            double modifier = this.posY - this.targetVec.getY();
            modifier = Math.min(Math.max(modifier, 80.0), 200.0);
            x1 *= modifier / 100.0D;
            y1 *= modifier / 100.0D;
            z1 *= modifier / 100.0D;
        }
        final double y = this.prevPosY + (this.posY - this.prevPosY) + y1 - this.motionY + (!this.getLaunched() ? 1.2D : 0D);
        ;
        final double x2 = this.posX + x1 - this.motionX;
        final double z2 = this.posZ + z1 - this.motionZ;
        final double x3 = x2 + x1 / 2D;
        final double y3 = y + y1 / 2D;
        final double z3 = z2 + z1 / 2D;
        Vector3 motionVec = new Vector3(x1, y1, z1);
        if (this.ticksExisted % 2 == 0 && !this.getLaunched())
            return;
        String flame = this.getLaunched() ? "launchFlameLaunched" : "launchFlameIdle";
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2 + 0.4 - this.rand.nextDouble() / 10, y, z2 + 0.4 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2 - 0.4 + this.rand.nextDouble() / 10, y, z2 + 0.4 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2 - 0.4 + this.rand.nextDouble() / 10, y, z2 - 0.4 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2 + 0.4 - this.rand.nextDouble() / 10, y, z2 - 0.4 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2, y, z2), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2 + 0.4, y, z2), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2 - 0.4, y, z2), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2, y, z2 + 0.4D), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x2, y, z2 - 0.4D), motionVec, new Object[] { riddenByEntity });
        // Larger flameball for T2 - positioned behind the smaller one
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.2 - this.rand.nextDouble() / 8, y3 + 0.4, z3 + 0.2 - this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.2 + this.rand.nextDouble() / 8, y3 + 0.4, z3 + 0.2 - this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.2 + this.rand.nextDouble() / 8, y3 + 0.4, z3 - 0.2 + this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.2 - this.rand.nextDouble() / 8, y3 + 0.4, z3 - 0.2 + this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.2 - this.rand.nextDouble() / 8, y3 - 0.4, z3 + 0.2 - this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.2 + this.rand.nextDouble() / 8, y3 - 0.4, z3 + 0.2 - this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.2 + this.rand.nextDouble() / 8, y3 - 0.4, z3 - 0.2 + this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.2 - this.rand.nextDouble() / 8, y3 - 0.4, z3 - 0.2 + this.rand.nextDouble() / 8), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.7 - this.rand.nextDouble() / 10, y3, z3 + 0.7 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.7 + this.rand.nextDouble() / 10, y3, z3 + 0.7 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.7 + this.rand.nextDouble() / 10, y3, z3 - 0.7 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.7 - this.rand.nextDouble() / 10, y3, z3 - 0.7 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + 0.7 - this.rand.nextDouble() / 10, y3, z3 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - 0.7 + this.rand.nextDouble() / 10, y3, z3 - this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 + this.rand.nextDouble() / 10, y3, z3 + 0.7 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle(flame, new Vector3(x3 - this.rand.nextDouble() / 10, y3, z3 - 0.7 + this.rand.nextDouble() / 10), motionVec, new Object[] { riddenByEntity });
        GalacticraftCore.proxy.spawnParticle("blueflame", new Vector3(x2 - 0.8, y, z2), motionVec, new Object[] {});
        GalacticraftCore.proxy.spawnParticle("blueflame", new Vector3(x2 + 0.8, y, z2), motionVec, new Object[] {});
        GalacticraftCore.proxy.spawnParticle("blueflame", new Vector3(x2, y, z2 - 0.8), motionVec, new Object[] {});
        GalacticraftCore.proxy.spawnParticle("blueflame", new Vector3(x2, y, z2 + 0.8), motionVec, new Object[] {});
    }
}
Also used : Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Aggregations

Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)74 BlockPos (net.minecraft.util.BlockPos)13 Entity (net.minecraft.entity.Entity)12 TileEntity (net.minecraft.tileentity.TileEntity)11 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)8 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)6 IBlockState (net.minecraft.block.state.IBlockState)6 EntityLivingBase (net.minecraft.entity.EntityLivingBase)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)6 ItemStack (net.minecraft.item.ItemStack)6 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)4 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)4 FlagData (micdoodle8.mods.galacticraft.core.wrappers.FlagData)4 WorldServer (net.minecraft.world.WorldServer)4 GameProfile (com.mojang.authlib.GameProfile)3