Search in sources :

Example 6 with Vector3d

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

the class ConduitGeometryUtil method preInit.

@SubscribeEvent
public static void preInit(EnderIOLifecycleEvent.Config.Post event) {
    float size = (float) (0.075f + (0.175f * Config.conduitScale));
    WIDTH = size;
    HEIGHT = size;
    HWIDTH = WIDTH / 2;
    HHEIGHT = HEIGHT / 2;
    final Vector3d core_min = new Vector3d(0.5f - HWIDTH, 0.5 - HHEIGHT, 0.5 - HWIDTH);
    CORE_MIN = core_min;
    final Vector3d core_max = new Vector3d(CORE_MIN.x + WIDTH, CORE_MIN.y + HEIGHT, CORE_MIN.z + WIDTH);
    CORE_MAX = core_max;
    CORE_BOUNDS = new BoundingBox(core_min, core_max);
    float connectorWidth = (float) (0.25f + (Config.conduitScale * 0.5f));
    for (EnumFacing dir : EnumFacing.VALUES) {
        EXTERNAL_CONNECTOR_BOUNDS.put(dir, createExternalConnector(dir, CONNECTOR_DEPTH, connectorWidth));
    }
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox) EnumFacing(net.minecraft.util.EnumFacing) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 7 with Vector3d

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

the class ConduitGeometryUtil method createBoundsForConnectionController.

@Nonnull
public BoundingBox createBoundsForConnectionController(@Nonnull EnumFacing dir, @Nonnull Offset offset) {
    Vector3d nonUniformScale = ForgeDirectionOffsets.forDirCopy(dir);
    nonUniformScale.scale(0.5);
    nonUniformScale.x = 0.8 * (1 - Math.abs(nonUniformScale.x));
    nonUniformScale.y = 0.8 * (1 - Math.abs(nonUniformScale.y));
    nonUniformScale.z = 0.8 * (1 - Math.abs(nonUniformScale.z));
    BoundingBox bb = CORE_BOUNDS;
    bb = bb.scale(nonUniformScale.x, nonUniformScale.y, nonUniformScale.z);
    double offsetFromEnd = Math.min(bb.sizeX(), bb.sizeY());
    offsetFromEnd = Math.min(offsetFromEnd, bb.sizeZ());
    offsetFromEnd = Math.max(offsetFromEnd, 0.075);
    double transMag = 0.5 - (offsetFromEnd * 1.2);
    Vector3d trans = ForgeDirectionOffsets.forDirCopy(dir);
    trans.scale(transMag);
    bb = bb.translate(trans);
    bb = bb.translate(getTranslation(dir, offset));
    return bb;
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox) Nonnull(javax.annotation.Nonnull)

Example 8 with Vector3d

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

the class TileElectricLight method updateLightNodes.

private void updateLightNodes() {
    Set<BlockPos> before;
    if (lightNodes != null && !lightNodes.isEmpty()) {
        before = new HashSet<BlockPos>(lightNodes.size());
        before.addAll(lightNodes);
    } else {
        before = Collections.emptySet();
    }
    Set<BlockPos> after = new HashSet<BlockPos>(17);
    updatingLightNodes = true;
    try {
        if (lightNodes == null) {
            // just created
            lightNodes = new ArrayList<BlockPos>();
        }
        for (EnumFacing dir : EnumFacing.VALUES) {
            if (dir != face && dir != face.getOpposite()) {
                // skip the way we are facing
                // us
                Vector3d offset = ForgeDirectionOffsets.forDirCopy(dir);
                addNodeInDirection(new Vector3d(offset), after);
                addNodeInDirection(offset.add(ForgeDirectionOffsets.forDirCopy(face.getOpposite())), after);
            }
        }
        // don't project behind, just in front
        addNodeInDirection(ForgeDirectionOffsets.forDirCopy(face.getOpposite()), after);
        Vector3d[] diags = new Vector3d[2];
        if (face.getFrontOffsetX() != 0) {
            diags[0] = ForgeDirectionOffsets.forDirCopy(EnumFacing.UP);
            diags[1] = ForgeDirectionOffsets.forDirCopy(EnumFacing.SOUTH);
        } else if (face.getFrontOffsetY() != 0) {
            diags[0] = ForgeDirectionOffsets.forDirCopy(EnumFacing.EAST);
            diags[1] = ForgeDirectionOffsets.forDirCopy(EnumFacing.SOUTH);
        } else {
            diags[0] = ForgeDirectionOffsets.forDirCopy(EnumFacing.UP);
            diags[1] = ForgeDirectionOffsets.forDirCopy(EnumFacing.EAST);
        }
        addDiaganals(diags, new Vector3d(), after);
        addDiaganals(diags, ForgeDirectionOffsets.forDirCopy(face.getOpposite()), after);
        if (!before.equals(after)) {
            lightNodes.clear();
            for (BlockPos entry : after) {
                if (!before.contains(entry) && entry != null) {
                    world.setBlockState(entry, block_light_node.getBlockNN().getDefaultState(), 3);
                    TileEntity te = world.getTileEntity(entry);
                    if (te instanceof TileLightNode) {
                        ((TileLightNode) te).setParentPos(getPos());
                        lightNodes.add(entry);
                    }
                } else {
                    lightNodes.add(entry);
                }
            }
            for (BlockPos entry : before) {
                if (!after.contains(entry) && entry != null) {
                    TileEntity te = world.getTileEntity(entry);
                    if ((te instanceof TileLightNode) && (((TileLightNode) te).getParentPos().equals(getPos()))) {
                        world.setBlockToAir(entry);
                    }
                }
            }
        } else {
            init = false;
        }
    } finally {
        updatingLightNodes = false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Vector3d(com.enderio.core.common.vecmath.Vector3d) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) HandleBlockPos(info.loenwind.autosave.handlers.minecraft.HandleBlockPos) HashSet(java.util.HashSet)

Example 9 with Vector3d

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

the class TileKillerJoe method getKillBounds.

@Nonnull
private BoundingBox getKillBounds() {
    if (killBounds == NULL_AABB) {
        double killerJoeAttackHeight = KillerJoeConfig.killerJoeAttackHeight.get();
        double killerJoeAttackLength = KillerJoeConfig.killerJoeAttackLength.get();
        double killerJoeAttackWidth = KillerJoeConfig.killerJoeAttackWidth.get();
        BoundingBox bb = new BoundingBox(getLocation());
        Vector3d min = bb.getMin();
        Vector3d max = bb.getMax();
        max.y += killerJoeAttackHeight;
        min.y -= killerJoeAttackHeight;
        EnumFacing facingDir = facing;
        if (ForgeDirectionOffsets.isPositiveOffset(facingDir)) {
            max.add(ForgeDirectionOffsets.offsetScaled(facingDir, killerJoeAttackLength));
            min.add(ForgeDirectionOffsets.forDir(facingDir));
        } else {
            min.add(ForgeDirectionOffsets.offsetScaled(facingDir, killerJoeAttackLength));
            max.add(ForgeDirectionOffsets.forDir(facingDir));
        }
        if (facingDir.getFrontOffsetX() == 0) {
            min.x -= killerJoeAttackWidth;
            max.x += killerJoeAttackWidth;
        } else {
            min.z -= killerJoeAttackWidth;
            max.z += killerJoeAttackWidth;
        }
        killBounds = new BoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
    }
    return killBounds;
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) BoundingBox(com.enderio.core.client.render.BoundingBox) EnumFacing(net.minecraft.util.EnumFacing) Nonnull(javax.annotation.Nonnull)

Example 10 with Vector3d

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

the class IoConfigRenderer method handleMouseInput.

public void handleMouseInput() {
    if (Mouse.getEventButton() == 0) {
        dragging = Mouse.getEventButtonState();
    }
    if (dragging) {
        double dx = (Mouse.getEventDX() / (double) mc.displayWidth);
        double dy = (Mouse.getEventDY() / (double) mc.displayHeight);
        if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
            distance -= dy * 15;
        } else {
            yaw -= 4 * dx * 180;
            pitch += 2 * dy * 180;
            pitch = (float) VecmathUtil.clamp(pitch, -80, 80);
        }
    }
    distance -= Mouse.getEventDWheel() * 0.01;
    distance = VecmathUtil.clamp(distance, 0.01, 200);
    long elapsed = System.currentTimeMillis() - initTime;
    // Mouse Over
    int x = Mouse.getEventX();
    int y = Mouse.getEventY();
    Vector3d start = new Vector3d();
    Vector3d end = new Vector3d();
    if (camera.getRayForPixel(x, y, start, end)) {
        end.scale(distance * 2);
        end.add(start);
        updateSelection(start, end);
    }
    // Mouse pressed on configurable side
    if (!Mouse.getEventButtonState() && camera.isValid() && elapsed > 500) {
        if (Mouse.getEventButton() == 1) {
            if (selection != null) {
                selection.config.toggleIoModeForFace(selection.face);
                PacketHandler.INSTANCE.sendToServer(new PacketIoMode(selection.config, selection.face));
            }
        } else if (Mouse.getEventButton() == 0 && inNeigButBounds) {
            renderNeighbours = !renderNeighbours;
        }
    }
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) PacketIoMode(crazypants.enderio.base.machine.modes.PacketIoMode)

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