Search in sources :

Example 6 with Vec3dCube

use of uk.co.qmunity.lib.vec.Vec3dCube in project BluePower by Qmunity.

the class GateNullCell method renderStatic.

// Rendering
@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
    super.renderStatic(translation, renderer, renderBlocks, pass);
    double height = 2 / 16D;
    IIcon wire = IconSupplier.wire;
    if (typeA != null) {
        // Flat
        renderer.setColor(WireHelper.getColorForPowerLevel(typeA, powerA));
        ForgeDirection dir = ForgeDirection.NORTH;
        for (int i = 0; i < getRotation(); i++) dir = dir.getRotation(getFace().getOpposite());
        dir = new Vec3d(0, 0, 0).add(dir).rotateUndo(getFace(), Vec3d.center).toForgeDirection();
        renderer.renderBox(new Vec3dCube(7 / 16D, 2 / 16D, 1 / 16D, 9 / 16D, 2 / 16D + height, 15 / 16D), wire);
        renderer.renderBox(new Vec3dCube(7 / 16D, 2 / 16D, 0 / 16D, 9 / 16D, 2 / 16D + (height / (nullcells[dir.ordinal()] ? 1 : 2)), 1 / 16D), wire);
        renderer.renderBox(new Vec3dCube(7 / 16D, 2 / 16D, 15 / 16D, 9 / 16D, 2 / 16D + (height / (nullcells[dir.getOpposite().ordinal()] ? 1 : 2)), 16 / 16D), wire);
    }
    if (typeB != null) {
        // Supported
        renderer.setColor(WireHelper.getColorForPowerLevel(typeB, powerB));
        ForgeDirection dir = ForgeDirection.WEST;
        for (int i = 0; i < getRotation(); i++) dir = dir.getRotation(getFace().getOpposite());
        dir = new Vec3d(0, 0, 0).add(dir).rotateUndo(getFace(), Vec3d.center).toForgeDirection();
        if (!nullcells[dir.ordinal()])
            renderer.renderBox(new Vec3dCube(0 / 16D, 2 / 16D, 7 / 16D, 2 / 16D, 10 / 16D, 9 / 16D), wire);
        if (!nullcells[dir.getOpposite().ordinal()])
            renderer.renderBox(new Vec3dCube(14 / 16D, 2 / 16D, 7 / 16D, 16 / 16D, 10 / 16D, 9 / 16D), wire);
        renderer.renderBox(new Vec3dCube(0 / 16D, 10 / 16D, 7 / 16D, 16 / 16D, 12 / 16D, 9 / 16D), wire);
    }
    renderer.setColor(0xFFFFFF);
    renderer.resetTransformations();
    return true;
}
Also used : IIcon(net.minecraft.util.IIcon) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Vec3d(uk.co.qmunity.lib.vec.Vec3d) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 7 with Vec3dCube

use of uk.co.qmunity.lib.vec.Vec3dCube in project BluePower by Qmunity.

the class GateSupported method addBoxes.

protected void addBoxes(List<Vec3dCube> boxes) {
    boxes.add(new Vec3dCube(2 / 16D, 2 / 16D, 2 / 16D, 3 / 16D, 10 / 16D, 3 / 16D));
    boxes.add(new Vec3dCube(2 / 16D, 2 / 16D, 13 / 16D, 3 / 16D, 10 / 16D, 14 / 16D));
    boxes.add(new Vec3dCube(2 / 16D, 9 / 16D, 3 / 16D, 3 / 16D, 10 / 16D, 13 / 16D));
    boxes.add(new Vec3dCube(13 / 16D, 2 / 16D, 2 / 16D, 14 / 16D, 10 / 16D, 3 / 16D));
    boxes.add(new Vec3dCube(13 / 16D, 2 / 16D, 13 / 16D, 14 / 16D, 10 / 16D, 14 / 16D));
    boxes.add(new Vec3dCube(13 / 16D, 9 / 16D, 3 / 16D, 14 / 16D, 10 / 16D, 13 / 16D));
}
Also used : Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube)

Example 8 with Vec3dCube

use of uk.co.qmunity.lib.vec.Vec3dCube in project BluePower by Qmunity.

the class GateSupported method renderStatic.

// Redwire connectivity
// Rendering
@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
    super.renderStatic(translation, renderer, renderBlocks, pass);
    IIcon planks = Blocks.planks.getIcon(0, 0);
    renderer.renderBox(new Vec3dCube(2 / 16D, 2 / 16D, 2 / 16D, 3 / 16D, 10 / 16D, 3 / 16D), planks);
    renderer.renderBox(new Vec3dCube(2 / 16D, 2 / 16D, 13 / 16D, 3 / 16D, 10 / 16D, 14 / 16D), planks);
    renderer.renderBox(new Vec3dCube(2 / 16D, 9 / 16D, 3 / 16D, 3 / 16D, 10 / 16D, 13 / 16D), planks);
    renderer.renderBox(new Vec3dCube(13 / 16D, 2 / 16D, 2 / 16D, 14 / 16D, 10 / 16D, 3 / 16D), planks);
    renderer.renderBox(new Vec3dCube(13 / 16D, 2 / 16D, 13 / 16D, 14 / 16D, 10 / 16D, 14 / 16D), planks);
    renderer.renderBox(new Vec3dCube(13 / 16D, 9 / 16D, 3 / 16D, 14 / 16D, 10 / 16D, 13 / 16D), planks);
    renderer.setColor(0xFFFFFF);
    return true;
}
Also used : IIcon(net.minecraft.util.IIcon) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 9 with Vec3dCube

use of uk.co.qmunity.lib.vec.Vec3dCube in project BluePower by Qmunity.

the class PneumaticTube method getTubeBoxes.

protected List<Vec3dCube> getTubeBoxes() {
    List<Vec3dCube> aabbs = getOcclusionBoxes();
    for (int i = 0; i < 6; i++) {
        ForgeDirection d = ForgeDirection.getOrientation(i);
        if (connections[i] || redstoneConnections[i] || getDeviceOnSide(d) != null) {
            Vec3dCube c = sideBB.clone().rotate(d, Vec3d.center);
            aabbs.add(c);
        }
    }
    return aabbs;
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube)

Example 10 with Vec3dCube

use of uk.co.qmunity.lib.vec.Vec3dCube in project BluePower by Qmunity.

the class PneumaticTube method onActivated.

/**
     * Event called when the part is activated (right clicked)
     *
     * @param player
     *            Player that right clicked the part
     * @param item
     *            Item that was used to click it
     * @return Whether or not an action occurred
     */
@Override
public boolean onActivated(EntityPlayer player, QMovingObjectPosition mop, ItemStack item) {
    if (getWorld() == null)
        return false;
    if (item != null) {
        TubeColor newColor = null;
        if (item.getItem() == BPItems.paint_brush && ((ItemDamageableColorableOverlay) BPItems.paint_brush).tryUseItem(item)) {
            newColor = TubeColor.values()[item.getItemDamage()];
        } else if (item.getItem() == Items.water_bucket || (item.getItem() == BPItems.paint_brush && item.getItemDamage() == 16)) {
            newColor = TubeColor.NONE;
        }
        if (newColor != null) {
            if (!getWorld().isRemote) {
                List<Vec3dCube> boxes = getTubeBoxes();
                Vec3dCube box = mop.getCube();
                int face = -1;
                if (box.equals(boxes.get(0))) {
                    face = mop.sideHit;
                } else {
                    face = getSideFromAABBIndex(boxes.indexOf(box));
                }
                color[face] = newColor;
                updateConnections();
                getLogic().clearNodeCaches();
                notifyUpdate();
            }
            return true;
        }
        if (item.getItem() instanceof ItemPart) {
            BPPart part = PartManager.getExample(item);
            if (redwireType == null && part instanceof PartRedwireFaceUninsulated) {
                if (!getWorld().isRemote) {
                    redwireType = ((IRedwire) part).getRedwireType(ForgeDirection.UNKNOWN);
                    if (!player.capabilities.isCreativeMode)
                        item.stackSize--;
                    // Redstone update
                    getRedstoneConnectionCache().recalculateConnections();
                    RedstoneApi.getInstance().getRedstonePropagator(this, ForgeDirection.DOWN).propagate();
                    updateConnections();
                    getLogic().clearNodeCaches();
                    notifyUpdate();
                    sendUpdatePacket();
                }
                return true;
            }
        }
        // Removing redwire
        if (redwireType != null && item.getItem() instanceof IScrewdriver && player.isSneaking()) {
            if (!getWorld().isRemote) {
                IOHelper.spawnItemInWorld(getWorld(), PartManager.getPartInfo("wire." + redwireType.getName()).getStack(), getX() + 0.5, getY() + 0.5, getZ() + 0.5);
                redwireType = null;
                // Redstone update
                getRedstoneConnectionCache().recalculateConnections();
                RedstoneApi.getInstance().getRedstonePropagator(this, ForgeDirection.DOWN).propagate();
                ((IScrewdriver) item.getItem()).damage(item, 1, player, false);
                updateConnections();
                getLogic().clearNodeCaches();
                notifyUpdate();
                sendUpdatePacket();
            }
            return true;
        }
    }
    return false;
}
Also used : TubeColor(com.bluepowermod.api.tube.IPneumaticTube.TubeColor) ItemPart(com.bluepowermod.item.ItemPart) IScrewdriver(com.bluepowermod.api.misc.IScrewdriver) BPPart(com.bluepowermod.part.BPPart) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) PartRedwireFaceUninsulated(com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)

Aggregations

Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)37 SideOnly (cpw.mods.fml.relauncher.SideOnly)13 IIcon (net.minecraft.util.IIcon)11 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)8 ArrayList (java.util.ArrayList)7 Rotation (uk.co.qmunity.lib.transform.Rotation)6 Translation (uk.co.qmunity.lib.transform.Translation)5 TubeColor (com.bluepowermod.api.tube.IPneumaticTube.TubeColor)3 RenderHelper (uk.co.qmunity.lib.client.render.RenderHelper)3 IScrewdriver (com.bluepowermod.api.misc.IScrewdriver)2 BlockLamp (com.bluepowermod.block.machine.BlockLamp)2 ItemPart (com.bluepowermod.item.ItemPart)2 PartRedwireFaceUninsulated (com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)2 ItemStack (net.minecraft.item.ItemStack)2 Vec3d (uk.co.qmunity.lib.vec.Vec3d)2 Vec3i (uk.co.qmunity.lib.vec.Vec3i)2 IGateComponent (com.bluepowermod.api.gate.IGateComponent)1 IIntegratedCircuitPart (com.bluepowermod.api.gate.IIntegratedCircuitPart)1 BPPart (com.bluepowermod.part.BPPart)1 GateComponentQuartzResonator (com.bluepowermod.part.gate.component.GateComponentQuartzResonator)1