Search in sources :

Example 11 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project BluePower by Qmunity.

the class GateConnectionBase method notifyUpdate.

@Override
public void notifyUpdate() {
    if (gate.getParent() == null || gate.getWorld() == null)
        return;
    ForgeDirection d = getForgeDirection();
    IConnection<? extends IRedstoneDevice> c = gate.getRedstoneConnectionCache().getConnectionOnSide(d);
    if (c == null || c.getB() instanceof DummyRedstoneDevice) {
        World world = gate.getWorld();
        int x = gate.getX(), y = gate.getY(), z = gate.getZ();
        RedstoneHelper.notifyRedstoneUpdate(world, x, y, z, d, true);
    } else {
        RedstoneApi.getInstance().getRedstonePropagator(getGate(), d).propagate();
    }
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) DummyRedstoneDevice(com.bluepowermod.redstone.DummyRedstoneDevice) World(net.minecraft.world.World)

Example 12 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection 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 13 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project BluePower by Qmunity.

the class GateNullCell method drawHighlight.

@Override
public boolean drawHighlight(QMovingObjectPosition mop, EntityPlayer player, float frame) {
    Vec3d hit = new Vec3d(mop.hitVec).sub(mop.blockX, mop.blockY, mop.blockZ).rotateUndo(getFace(), Vec3d.center);
    Vec3 pos = player.getPosition(frame);
    ItemStack held = player.getCurrentEquippedItem();
    if (held == null)
        return false;
    if (held.getItem() instanceof ItemPart) {
        IPart part = ((ItemPart) held.getItem()).createPart(held, player, null, null);
        if (part == null)
            return false;
        if (!(part instanceof PartRedwireFaceUninsulated))
            return false;
        PartRedwireFace wire = (PartRedwireFace) part;
        RenderHelper renderer = RenderHelper.instance;
        renderer.fullReset();
        renderer.setRenderCoords(getWorld(), getX(), getY(), getZ());
        double height = 2 / 16D;
        IIcon wireIcon = IconSupplier.wire;
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
        Tessellator.instance.startDrawingQuads();
        Tessellator.instance.addTranslation((float) -pos.xCoord, (float) -pos.yCoord, (float) -pos.zCoord);
        {
            switch(getFace()) {
                case DOWN:
                    break;
                case UP:
                    renderer.addTransformation(new Rotation(180, 180, 0, Vec3d.center));
                    break;
                case NORTH:
                    renderer.addTransformation(new Rotation(90, 0, 0, Vec3d.center));
                    break;
                case SOUTH:
                    renderer.addTransformation(new Rotation(-90, 0, 0, Vec3d.center));
                    break;
                case WEST:
                    renderer.addTransformation(new Rotation(0, 0, -90, Vec3d.center));
                    break;
                case EAST:
                    renderer.addTransformation(new Rotation(0, 0, 90, Vec3d.center));
                    break;
                default:
                    break;
            }
            int rotation = getRotation();
            if (rotation != -1)
                renderer.addTransformation(new Rotation(0, 90 * -rotation, 0));
            renderer.setOpacity(0.5);
            renderer.setColor(WireHelper.getColorForPowerLevel(wire.getRedwireType(ForgeDirection.UNKNOWN), (byte) (255 / 2)));
            ForgeDirection dir = ForgeDirection.NORTH;
            if (getRotation() % 2 == 1)
                dir = dir.getRotation(getFace());
            if (hit.getY() > 2 / 16D) {
                if (typeB == null) {
                    renderer.renderBox(new Vec3dCube(0 / 16D, 2 / 16D, 7 / 16D, 2 / 16D, 10 / 16D, 9 / 16D), wireIcon);
                    renderer.renderBox(new Vec3dCube(14 / 16D, 2 / 16D, 7 / 16D, 16 / 16D, 10 / 16D, 9 / 16D), wireIcon);
                    renderer.renderBox(new Vec3dCube(0 / 16D, 10 / 16D, 7 / 16D, 16 / 16D, 12 / 16D, 9 / 16D), wireIcon);
                }
            } else {
                if (typeA == null)
                    renderer.renderBox(new Vec3dCube(7 / 16D, 2 / 16D, 0 / 16D, 9 / 16D, 2 / 16D + height, 16 / 16D), wireIcon);
            }
            renderer.fullReset();
        }
        Tessellator.instance.addTranslation((float) pos.xCoord, (float) pos.yCoord, (float) pos.zCoord);
        Tessellator.instance.draw();
        GL11.glDisable(GL11.GL_BLEND);
        return true;
    } else if (held.getItem() instanceof IScrewdriver) {
    // List<Vec3dCube> l = new ArrayList<Vec3dCube>();
    // super.addBoxes(l);
    // boolean def = false;
    // for (Vec3dCube c : l)
    // if (mop.getCube().equals(c.clone().rotate(getFace(), Vec3d.center).rotate(0, 90 * -getRotation(), 0, Vec3d.center)))
    // def = true;
    // if (def || hit.getY() <= 2 / 16D) {
    // Vec3dCube c = Vec3dCube.merge(getSelectionBoxes()).expand(0.001);
    //
    // GL11.glEnable(GL11.GL_BLEND);
    // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    // GL11.glDisable(GL11.GL_TEXTURE_2D);
    // GL11.glColor4f(0, 0, 0, 0.4F);
    // GL11.glLineWidth(2);
    // GL11.glDepthMask(true);
    // GL11.glPushMatrix();
    //
    // Tessellator var2 = Tessellator.instance;
    // var2.startDrawing(3);
    // Tessellator.instance.addTranslation((float) -pos.xCoord + getX(), (float) -pos.yCoord + getY(), (float) -pos.zCoord
    // + getZ());
    // var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMinY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMinY(), c.getMaxZ());
    // var2.addVertex(c.getMinX(), c.getMinY(), c.getMaxZ());
    // var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
    // var2.draw();
    // var2.startDrawing(3);
    // var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMaxZ());
    // var2.addVertex(c.getMinX(), c.getMaxY(), c.getMaxZ());
    // var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
    // var2.draw();
    // var2.startDrawing(1);
    // var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
    // var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMinY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMinY(), c.getMaxZ());
    // var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMaxZ());
    // var2.addVertex(c.getMinX(), c.getMinY(), c.getMaxZ());
    // var2.addVertex(c.getMinX(), c.getMaxY(), c.getMaxZ());
    // Tessellator.instance.addTranslation((float) pos.xCoord - getX(), (float) pos.yCoord - getY(), (float) pos.zCoord - getZ());
    // var2.draw();
    //
    // GL11.glPopMatrix();
    // GL11.glDepthMask(false);
    // GL11.glEnable(GL11.GL_TEXTURE_2D);
    // GL11.glDisable(GL11.GL_BLEND);
    //
    // return true;
    // }
    //
    // return true;
    }
    return false;
}
Also used : ItemPart(com.bluepowermod.item.ItemPart) RenderHelper(uk.co.qmunity.lib.client.render.RenderHelper) IIcon(net.minecraft.util.IIcon) Rotation(uk.co.qmunity.lib.transform.Rotation) Vec3d(uk.co.qmunity.lib.vec.Vec3d) PartRedwireFaceUninsulated(com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated) IScrewdriver(com.bluepowermod.api.misc.IScrewdriver) IPart(uk.co.qmunity.lib.part.IPart) Vec3(net.minecraft.util.Vec3) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) PartRedwireFace(com.bluepowermod.part.wire.redstone.PartRedwireFace) ItemStack(net.minecraft.item.ItemStack) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube)

Example 14 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection 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 15 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project BluePower by Qmunity.

the class PneumaticTube method onRedstoneUpdate.

@Override
public void onRedstoneUpdate() {
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        IConnection<IRedstoneDevice> c = redConnections.getConnectionOnSide(dir);
        IRedstoneDevice dev = null;
        if (c != null)
            dev = c.getB();
        if (dev == null || dev instanceof DummyRedstoneDevice)
            RedstoneHelper.notifyRedstoneUpdate(getWorld(), getX(), getY(), getZ(), dir, false);
    }
    sendUpdatePacket();
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IRedstoneDevice(com.bluepowermod.api.wire.redstone.IRedstoneDevice) DummyRedstoneDevice(com.bluepowermod.redstone.DummyRedstoneDevice)

Aggregations

ForgeDirection (net.minecraftforge.common.util.ForgeDirection)242 TileEntity (net.minecraft.tileentity.TileEntity)80 ItemStack (net.minecraft.item.ItemStack)47 ArrayList (java.util.ArrayList)29 Block (net.minecraft.block.Block)28 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)24 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)21 IInventory (net.minecraft.inventory.IInventory)19 FluidStack (net.minecraftforge.fluids.FluidStack)18 SideOnly (cpw.mods.fml.relauncher.SideOnly)17 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)17 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)17 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)16 HashMap (java.util.HashMap)12 Pair (logisticspipes.utils.tuples.Pair)11 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)10 World (net.minecraft.world.World)10 IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)9 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)9 List (java.util.List)8