Search in sources :

Example 1 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class TravelController method getScaleForCandidate.

public double getScaleForCandidate(@Nonnull Vector3d loc) {
    if (!currentView.isValid()) {
        return 1;
    }
    BlockPos bc = new BlockPos(loc.x, loc.y, loc.z);
    float ratio = -1;
    Float r = candidates.get(bc);
    if (r != null) {
        ratio = r;
    }
    if (ratio < 0) {
        // no cached value
        addRatio(bc);
        ratio = candidates.get(bc);
    }
    // smoothly zoom to a larger size, starting when the point is the middle 20% of the screen
    float start = 0.2f;
    float end = 0.01f;
    double mix = MathHelper.clamp((start - ratio) / (start - end), 0, 1);
    double scale = 1;
    if (mix > 0) {
        Vector3d eyePoint = Util.getEyePositionEio(Minecraft.getMinecraft().player);
        scale = tanFovRad * eyePoint.distance(loc);
        // Using this scale will give us the block full screen, we will make it 20% of the screen
        scale *= Config.travelAnchorZoomScale;
        // only apply 70% of the scaling so more distance targets are still smaller than closer targets
        float nf = 1 - MathHelper.clamp((float) eyePoint.distanceSquared(loc) / TravelSource.STAFF.getMaxDistanceTravelledSq(), 0, 1);
        scale = scale * (0.3 + 0.7 * nf);
        scale = (scale * mix) + (1 - mix);
        scale = Math.max(1.01, scale);
    }
    return scale;
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class ItemRodOfReturn method onUsingClient.

@SideOnly(Side.CLIENT)
private void onUsingClient(ItemStack stack, EntityLivingBase player, int timeLeft) {
    if (timeLeft > (Config.rodOfReturnTicksToActivate - 2)) {
        return;
    }
    float progress = 1 - ((float) timeLeft / Config.rodOfReturnTicksToActivate);
    float spinSpeed = progress * 2;
    if (activeSound != null) {
        activeSound.setPitch(MathHelper.clamp(0.5f + (spinSpeed / 1.5f), 0.5f, 2));
    }
    if (activeSound == null) {
        BlockPos p = player.getPosition();
        activeSound = new MachineSound(ACTIVE_RES, p.getX(), p.getY(), p.getZ(), 0.3f, 1);
        playSound();
    }
    double dist = 2 - (progress * 1.5);
    Random rand = player.world.rand;
    for (int i = 0; i < 6; i++) {
        double xo = randomOffset(rand, dist);
        double yo = randomOffset(rand, dist);
        double zo = randomOffset(rand, dist);
        double x = player.posX + xo;
        double y = player.posY + yo + player.height / 2;
        double z = player.posZ + zo;
        Vector3d velocity = new Vector3d(xo, yo, zo);
        velocity.normalize();
        Particle fx = Minecraft.getMinecraft().effectRenderer.spawnEffectParticle(EnumParticleTypes.PORTAL.getParticleID(), x, y, z, 0, 0, 0, 0);
        if (fx != null) {
            // if(rand.nextInt(8) == 0) {
            // fx.setRBGColorF((rand.nextFloat() * 0.1f), 0.6f + (rand.nextFloat() * 0.15f), 0.75f + (rand.nextFloat() * 0.2f));
            // }
            ClientUtil.setParticleVelocity(fx, velocity.x, velocity.y, velocity.z);
            fx.setMaxAge(timeLeft + 2);
        }
    }
}
Also used : Particle(net.minecraft.client.particle.Particle) Random(java.util.Random) Vector3d(com.enderio.core.common.vecmath.Vector3d) BlockPos(net.minecraft.util.math.BlockPos) MachineSound(crazypants.enderio.base.machine.sound.MachineSound) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class ConnectionModeGeometry method addModeConnectorQuads.

public static void addModeConnectorQuads(EnumFacing dir, Offset offset, TextureAtlasSprite tex, Vector4f color, List<BakedQuad> quads) {
    List<Vertex> verts = VERTS.get(dir);
    if (verts == null) {
        return;
    }
    Vector3d trans = ConduitGeometryUtil.instance.getTranslation(dir, offset);
    List<Vertex> xFormed = new ArrayList<Vertex>(verts.size());
    for (Vertex v : verts) {
        Vertex xf = new Vertex(v);
        xf.xyz.add(trans);
        xFormed.add(xf);
    }
    BakedQuadBuilder.addBakedQuads(quads, xFormed, tex, color);
}
Also used : Vertex(com.enderio.core.common.vecmath.Vertex) Vector3d(com.enderio.core.common.vecmath.Vector3d) ArrayList(java.util.ArrayList)

Example 4 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class SoundDetector method onClientTick.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
    if (!enabled) {
        return;
    }
    List<SoundSource> sounds = new ArrayList<SoundSource>(MAX_PARTICLES);
    soundQueue.drainTo(sounds);
    try {
        final Minecraft minecraft = Minecraft.getMinecraft();
        Vector3d eye = Util.getEyePositionEio(minecraft.player);
        for (SoundSource ss : sounds) {
            double distSq = ss.pos.distanceSquared(eye);
            int minDist = ss.isEntity ? 4 : 49;
            if (distSq > minDist && distSq <= Config.darkSteelSoundLocatorRange * Config.darkSteelSoundLocatorRange) {
                minecraft.effectRenderer.addEffect(new SoundParticle(minecraft.player.world, ss));
            }
        }
    } catch (Exception ex) {
    // Probably not necessary anymore but safety first!
    }
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) ArrayList(java.util.ArrayList) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class ItemCoordSelector method printCoords.

private boolean printCoords(@Nonnull ItemStack stack, @Nonnull World world, @Nonnull EntityPlayer player) {
    Vector3d headVec = Util.getEyePositionEio(player);
    Vec3d start = headVec.getVec3();
    Vec3d lookVec = player.getLook(1.0F);
    double reach = 500;
    headVec.add(lookVec.x * reach, lookVec.y * reach, lookVec.z * reach);
    RayTraceResult mop = world.rayTraceBlocks(start, headVec.getVec3());
    if (mop == null) {
        return false;
    }
    BlockPos bc = BlockCoord.get(mop);
    if (!player.isSneaking()) {
        EnumFacing dir = mop.sideHit;
        bc = bc.offset(dir);
    }
    return ModObject.itemLocationPrintout.openClientGui(world, bc, player, null, ItemLocationPrintout.GUI_ID_LOCATION_PRINTOUT_CREATE);
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) EnumFacing(net.minecraft.util.EnumFacing) RayTraceResult(net.minecraft.util.math.RayTraceResult) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

Vector3d (com.enderio.core.common.vecmath.Vector3d)35 BoundingBox (com.enderio.core.client.render.BoundingBox)9 EnumFacing (net.minecraft.util.EnumFacing)7 BlockPos (net.minecraft.util.math.BlockPos)7 Nonnull (javax.annotation.Nonnull)6 Vertex (com.enderio.core.common.vecmath.Vertex)4 ArrayList (java.util.ArrayList)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 TileEntity (net.minecraft.tileentity.TileEntity)3 RayTraceResult (net.minecraft.util.math.RayTraceResult)3 Vec3d (net.minecraft.util.math.Vec3d)3 VertexRotationFacing (com.enderio.core.client.render.VertexRotationFacing)2 Vector2d (com.enderio.core.common.vecmath.Vector2d)2 Vector4f (com.enderio.core.common.vecmath.Vector4f)2 IBlockState (net.minecraft.block.state.IBlockState)2 Minecraft (net.minecraft.client.Minecraft)2 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2