Search in sources :

Example 1 with Vec3i

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

the class BundledDeviceCCComputer method getDeviceAt.

public static BundledDeviceCCComputer getDeviceAt(World world, int x, int y, int z) {
    Vec3i loc = new Vec3i(x, y, z, world);
    for (BundledDeviceCCComputer c : list) if (c.loc.equals(loc))
        return c;
    BundledDeviceCCComputer c = new BundledDeviceCCComputer(loc);
    list.add(c);
    return c;
}
Also used : Vec3i(uk.co.qmunity.lib.vec.Vec3i)

Example 2 with Vec3i

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

the class GateComparator method doLogic.

@Override
public void doLogic() {
    byte power = back().getInput();
    ForgeDirection d = back().getDirection().toForgeDirection(getFace(), getRotation());
    Vec3i a = new Vec3i(getX(), getY(), getZ(), getWorld()).add(d);
    Block ba = a.getBlock(false);
    if (ba.hasComparatorInputOverride())
        power = (byte) MathHelper.map(ba.getComparatorInputOverride(getWorld(), a.getX(), a.getY(), a.getZ(), d.getOpposite().ordinal()), 0, 15, 0, 255);
    if (ba instanceof IAnalogueComparatorReadout && ((IAnalogueComparatorReadout) ba).hasAnalogueComparatorInputOverride())
        power = ((IAnalogueComparatorReadout) ba).getAnalogueComparatorInputOverride(getWorld(), a.getX(), a.getY(), a.getZ(), d.getOpposite().ordinal());
    if (ba.isOpaqueCube()) {
        Vec3i b = a.getRelative(d);
        Block bb = b.getBlock(false);
        if (bb.hasComparatorInputOverride())
            power = (byte) MathHelper.map(bb.getComparatorInputOverride(getWorld(), b.getX(), b.getY(), b.getZ(), d.getOpposite().ordinal()), 0, 15, 0, 255);
        if (bb instanceof IAnalogueComparatorReadout && ((IAnalogueComparatorReadout) bb).hasAnalogueComparatorInputOverride())
            power = ((IAnalogueComparatorReadout) bb).getAnalogueComparatorInputOverride(getWorld(), b.getX(), b.getY(), b.getZ(), d.getOpposite().ordinal());
    }
    t1.setState(left().getInput() == 0);
    t2.setState(right().getInput() == 0);
    w.setPower((byte) (255 - (power & 0xFF)));
    t3.setState(power != 0);
    front().setOutput((byte) Math.max((power & 0xFF) - Math.max(left().getInput() & 0xFF, right().getInput() & 0xFF), 0));
}
Also used : Vec3i(uk.co.qmunity.lib.vec.Vec3i) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block) IAnalogueComparatorReadout(com.bluepowermod.api.gate.IAnalogueComparatorReadout)

Example 3 with Vec3i

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

the class PneumaticTube method rayTrace.

@Override
public QMovingObjectPosition rayTrace(Vec3d start, Vec3d end) {
    QMovingObjectPosition mop = super.rayTrace(start, end);
    if (mop == null)
        return null;
    EntityPlayer player = BluePower.proxy.getPlayer();
    if (redwireType != null && player != null && player.isSneaking()) {
        double wireSize = getSize() / 16D;
        double frameSeparation = 4 / 16D - (wireSize - 2 / 16D);
        double frameThickness = 1 / 16D;
        frameThickness /= 1.5;
        frameSeparation -= 1 / 32D;
        QMovingObjectPosition wire = RayTracer.instance().rayTraceCubes(getFrameBoxes(wireSize, frameSeparation, frameThickness, shouldRenderConnection(ForgeDirection.DOWN), shouldRenderConnection(ForgeDirection.UP), shouldRenderConnection(ForgeDirection.WEST), shouldRenderConnection(ForgeDirection.EAST), shouldRenderConnection(ForgeDirection.NORTH), shouldRenderConnection(ForgeDirection.SOUTH), redstoneConnections[ForgeDirection.DOWN.ordinal()], redstoneConnections[ForgeDirection.UP.ordinal()], redstoneConnections[ForgeDirection.WEST.ordinal()], redstoneConnections[ForgeDirection.EAST.ordinal()], redstoneConnections[ForgeDirection.NORTH.ordinal()], redstoneConnections[ForgeDirection.SOUTH.ordinal()], getParent() != null && getWorld() != null), start, end, new Vec3i(this));
        QMovingObjectPosition frame = RayTracer.instance().rayTraceCubes(getFrameBoxes(), start, end, new Vec3i(this));
        if (wire != null) {
            if (frame != null) {
                if (wire.hitVec.distanceTo(start.toVec3()) < frame.hitVec.distanceTo(start.toVec3()))
                    mop.hitInfo = PartManager.getPartInfo("wire." + redwireType.getName()).getStack();
            } else {
                mop.hitInfo = PartManager.getPartInfo("wire." + redwireType.getName()).getStack();
            }
        }
    }
    return mop;
}
Also used : Vec3i(uk.co.qmunity.lib.vec.Vec3i) EntityPlayer(net.minecraft.entity.player.EntityPlayer) QMovingObjectPosition(uk.co.qmunity.lib.raytrace.QMovingObjectPosition)

Example 4 with Vec3i

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

the class PneumaticTube method canConnect.

@Override
public boolean canConnect(ForgeDirection side, IRedstoneDevice device, ConnectionType type) {
    if (type == ConnectionType.STRAIGHT) {
        if (getRedwireType(side) == null)
            return false;
        if (device instanceof IRedwire) {
            RedwireType rwt = getRedwireType(side);
            if (type == null)
                return false;
            RedwireType rwt_ = ((IRedwire) device).getRedwireType(type == ConnectionType.STRAIGHT ? side.getOpposite() : side.getOpposite());
            if (rwt_ == null)
                return false;
            if (!rwt.canConnectTo(rwt_))
                return false;
        }
        if (device instanceof IFace)
            return ((IFace) device).getFace() == side.getOpposite();
        if (!OcclusionHelper.microblockOcclusionTest(new Vec3i(this), MicroblockShape.FACE_HOLLOW, 8, side))
            return false;
        if (device instanceof PneumaticTube)
            if (device instanceof MagTube != this instanceof MagTube)
                return false;
        return true;
    }
    return false;
}
Also used : RedwireType(com.bluepowermod.api.wire.redstone.RedwireType) Vec3i(uk.co.qmunity.lib.vec.Vec3i) IFace(com.bluepowermod.api.misc.IFace) IRedwire(com.bluepowermod.api.wire.redstone.IRedwire)

Example 5 with Vec3i

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

the class RenderLamp method renderTileEntityAt.

/******* TESR ***********/
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
    if (!(te.getBlockType() instanceof BlockLamp))
        return;
    if (pass != 0) {
        BlockLamp bLamp = (BlockLamp) te.getBlockType();
        int power = ((TileLamp) te).getPower();
        int color = bLamp.getColor(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);
        int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
        int r = (color & redMask) >> 16;
        int g = (color & greenMask) >> 8;
        int b = (color & blueMask);
        if (bLamp.isInverted()) {
            power = 15 - power;
        }
        // power = 15;
        Vec3i vector = new Vec3i(te);
        Vec3dCube box = new Vec3dCube(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5).expand(0.8 / 16D);
        boolean[] renderFaces = new boolean[] { true, true, true, true, true, true };
        for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            Vec3i v = vector.getRelative(d);
            Block bl = v.getBlock();
            if (bl instanceof BlockLamp && ((BlockLamp) bl).getPower(v.getWorld(), v.getX(), v.getY(), v.getZ()) > 0) {
                if (d.offsetX < 0) {
                    box.getMin().setX(-0.5);
                    renderFaces[2] = false;
                } else if (d.offsetY < 0) {
                    box.getMin().setY(-0.5);
                    renderFaces[1] = false;
                } else if (d.offsetZ < 0) {
                    box.getMin().setZ(-0.5);
                    renderFaces[4] = false;
                } else if (d.offsetX > 0) {
                    box.getMax().setX(0.5);
                    renderFaces[3] = false;
                } else if (d.offsetY > 0) {
                    box.getMax().setY(0.5);
                    renderFaces[0] = false;
                } else if (d.offsetZ > 0) {
                    box.getMax().setZ(0.5);
                    renderFaces[5] = false;
                }
            }
        }
        box.getMin().add(0.5, 0.5, 0.5);
        box.getMax().add(0.5, 0.5, 0.5);
        GL11.glTranslated(x, y, z);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        // GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glBegin(GL11.GL_QUADS);
        double powerDivision = power / 18D;
        com.bluepowermod.client.render.RenderHelper.drawColoredCube(box, r / 256D, g / 256D, b / 256D, powerDivision * 0.625D, renderFaces);
        GL11.glEnd();
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        // GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glTranslated(-x, -y, -z);
    }
}
Also used : Vec3i(uk.co.qmunity.lib.vec.Vec3i) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) TileLamp(com.bluepowermod.tile.tier1.TileLamp) Block(net.minecraft.block.Block) BlockLamp(com.bluepowermod.block.machine.BlockLamp) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube)

Aggregations

Vec3i (uk.co.qmunity.lib.vec.Vec3i)10 RenderHelper (uk.co.qmunity.lib.client.render.RenderHelper)4 SideOnly (cpw.mods.fml.relauncher.SideOnly)3 Block (net.minecraft.block.Block)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 IFace (com.bluepowermod.api.misc.IFace)2 Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)2 IAdvancedSilkyRemovable (com.bluepowermod.api.block.IAdvancedSilkyRemovable)1 ISilkyRemovable (com.bluepowermod.api.block.ISilkyRemovable)1 ConnectionType (com.bluepowermod.api.connect.ConnectionType)1 IAnalogueComparatorReadout (com.bluepowermod.api.gate.IAnalogueComparatorReadout)1 IRedwire (com.bluepowermod.api.wire.redstone.IRedwire)1 RedwireType (com.bluepowermod.api.wire.redstone.RedwireType)1 BlockLamp (com.bluepowermod.block.machine.BlockLamp)1 GateComponentQuartzResonator (com.bluepowermod.part.gate.component.GateComponentQuartzResonator)1 GateComponentSiliconChip (com.bluepowermod.part.gate.component.GateComponentSiliconChip)1 GateComponentTaintedSiliconChip (com.bluepowermod.part.gate.component.GateComponentTaintedSiliconChip)1 TileLamp (com.bluepowermod.tile.tier1.TileLamp)1 GuiScreen (net.minecraft.client.gui.GuiScreen)1 GuiContainer (net.minecraft.client.gui.inventory.GuiContainer)1