Search in sources :

Example 1 with IPart

use of uk.co.qmunity.lib.part.IPart in project BluePower by Qmunity.

the class ItemPart method createPart.

@Override
public IPart createPart(ItemStack item, EntityPlayer player, World world, MovingObjectPosition mop) {
    IPart part = info.create();
    BPApi.getInstance().loadSilkySettings(part, item);
    return part;
}
Also used : IPart(uk.co.qmunity.lib.part.IPart)

Example 2 with IPart

use of uk.co.qmunity.lib.part.IPart in project BluePower by Qmunity.

the class WorldConverter method convertTile.

private boolean convertTile(NBTTagCompound tag) {
    NBTTagList parts = tag.getTagList("parts", new NBTTagCompound().getId());
    int count = parts.tagCount();
    FMPPart fmppart = new FMPPart(true);
    for (int i = 0; i < count; i++) {
        NBTTagCompound part = parts.getCompoundTagAt(i);
        String id = part.getString("id");
        for (IPartConverter c : converters) {
            if (c.matches(id)) {
                IPart p = c.convert(part);
                if (p == null)
                    continue;
                fmppart.addPart(p);
                parts.removeTag(i);
                i--;
                break;
            }
        }
        count = parts.tagCount();
    }
    if (fmppart.getParts().size() > 0) {
        NBTTagCompound part = new NBTTagCompound();
        fmppart.save(part);
        part.setString("id", fmppart.getType());
        parts.appendTag(part);
        return true;
    }
    return false;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) IPart(uk.co.qmunity.lib.part.IPart) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) FMPPart(uk.co.qmunity.lib.part.compat.fmp.FMPPart)

Example 3 with IPart

use of uk.co.qmunity.lib.part.IPart in project BluePower by Qmunity.

the class GateIntegratedCircuit method readParts.

private void readParts(NBTTagList l) {
    for (int i = 0; i < l.tagCount(); i++) {
        NBTTagCompound tag = l.getCompoundTagAt(i);
        int x = tag.getInteger("x");
        int z = tag.getInteger("z");
        IPart p = getPart(x, z);
        if (p == null) {
            p = PartRegistry.createPart(tag.getString("type"), false);
            if (p == null || !(p instanceof IIntegratedCircuitPart))
                continue;
            setPart(x, z, (IIntegratedCircuitPart) p);
        }
        p.readFromNBT(tag.getCompoundTag("data"));
    }
}
Also used : IPart(uk.co.qmunity.lib.part.IPart) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IIntegratedCircuitPart(com.bluepowermod.api.gate.IIntegratedCircuitPart)

Example 4 with IPart

use of uk.co.qmunity.lib.part.IPart in project BluePower by Qmunity.

the class GateIntegratedCircuit method setPart.

public void setPart(int x, int z, IIntegratedCircuitPart part) {
    loadWorld();
    FakeMultipartTileIC tmp = new FakeMultipartTileIC(this);
    tmp.setWorldObj(FakeWorldIC.getInstance());
    tmp.xCoord = x;
    tmp.yCoord = 64;
    tmp.zCoord = z;
    tiles[x][z] = tmp;
    parts[x][z] = part;
    if (part instanceof IPartFace)
        ((IPartFace) part).setFace(ForgeDirection.DOWN);
    tmp.addPart(part);
    for (int x_ = x - 1; x_ <= x + 1; x_++) {
        if (x_ == x)
            continue;
        IPart p = getPart(x_, z);
        if (p != null && p instanceof IPartUpdateListener)
            ((IPartUpdateListener) p).onNeighborBlockChange();
    }
    for (int z_ = z - 1; z_ <= z + 1; z_++) {
        if (z_ == z)
            continue;
        IPart p = getPart(x, z_);
        if (p != null && p instanceof IPartUpdateListener)
            ((IPartUpdateListener) p).onNeighborBlockChange();
    }
    unloadWorld();
}
Also used : IPartUpdateListener(uk.co.qmunity.lib.part.IPartUpdateListener) IPartFace(uk.co.qmunity.lib.part.IPartFace) IPart(uk.co.qmunity.lib.part.IPart)

Example 5 with IPart

use of uk.co.qmunity.lib.part.IPart 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)

Aggregations

IPart (uk.co.qmunity.lib.part.IPart)18 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 ItemPart (com.bluepowermod.item.ItemPart)4 Vec3d (uk.co.qmunity.lib.vec.Vec3d)4 IIntegratedCircuitPart (com.bluepowermod.api.gate.IIntegratedCircuitPart)3 IScrewdriver (com.bluepowermod.api.misc.IScrewdriver)3 PartRedwireFace (com.bluepowermod.part.wire.redstone.PartRedwireFace)3 PartRedwireFaceUninsulated (com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)3 ItemStack (net.minecraft.item.ItemStack)3 IRedstoneDevice (com.bluepowermod.api.wire.redstone.IRedstoneDevice)2 IPartUpdateListener (uk.co.qmunity.lib.part.IPartUpdateListener)2 ITilePartHolder (uk.co.qmunity.lib.part.ITilePartHolder)2 IAdvancedSilkyRemovable (com.bluepowermod.api.block.IAdvancedSilkyRemovable)1 ISilkyRemovable (com.bluepowermod.api.block.ISilkyRemovable)1 MinecraftColor (com.bluepowermod.api.misc.MinecraftColor)1 IBundledDevice (com.bluepowermod.api.wire.redstone.IBundledDevice)1 IInsulatedRedwire (com.bluepowermod.api.wire.redstone.IRedwire.IInsulatedRedwire)1 RedwireType (com.bluepowermod.api.wire.redstone.RedwireType)1 ItemScrewdriver (com.bluepowermod.item.ItemScrewdriver)1 PartInfo (com.bluepowermod.part.PartInfo)1