Search in sources :

Example 1 with IGateComponent

use of com.bluepowermod.api.gate.IGateComponent in project BluePower by Qmunity.

the class GateBase method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);
    NBTTagCompound connections = tag.getCompoundTag("connections");
    for (GateConnectionBase c : getConnections()) if (c != null)
        c.readFromNBT(connections.getCompoundTag(c.getDirection().name()));
    NBTTagCompound components = tag.getCompoundTag("components");
    int i = 0;
    for (IGateComponent c : getComponents()) {
        c.readFromNBT(components.getCompoundTag(i + ""));
        i++;
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IGateComponent(com.bluepowermod.api.gate.IGateComponent) GateConnectionBase(com.bluepowermod.part.gate.connection.GateConnectionBase)

Example 2 with IGateComponent

use of com.bluepowermod.api.gate.IGateComponent in project BluePower by Qmunity.

the class GateIntegratedCircuit method renderStatic.

// Rendering
@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
    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));
    IIcon[] icons = new IIcon[] { getIcon(ForgeDirection.DOWN), getIcon(ForgeDirection.UP), getIcon(ForgeDirection.WEST), getIcon(ForgeDirection.EAST), getIcon(ForgeDirection.NORTH), getIcon(ForgeDirection.SOUTH) };
    renderer.renderBox(new Vec3dCube(0, 0, 0, 1, 1 / 16D, 1), icons);
    renderer.renderBox(new Vec3dCube(0, 1 / 16D, 0, 1, 2 / 16D, 1 / 16D), icons);
    renderer.renderBox(new Vec3dCube(0, 1 / 16D, 15 / 16D, 1, 2 / 16D, 1), icons);
    renderer.renderBox(new Vec3dCube(0, 1 / 16D, 0, 1 / 16D, 2 / 16D, 1), icons);
    renderer.renderBox(new Vec3dCube(15 / 16D, 1 / 16D, 0, 1, 2 / 16D, 1), icons);
    for (IGateComponent c : getComponents()) c.renderStatic(translation, renderer, pass);
    double scale = (1 - border * 2D) / getSize();
    renderer.addTransformation(new Scale(scale, scale, scale));
    for (int x = 0; x < getSize(); x++) {
        for (int z = 0; z < getSize(); z++) {
            IIntegratedCircuitPart part = getPart(x, z);
            if (part == null)
                continue;
            int s = getSize();
            if (s % 2 == 1)
                s -= 1;
            double a = (getSize() - 1) / 2D;
            renderer.addTransformation(new Translation(-(s - x - a), -a, -(s - z - a)));
            part.renderStatic(translation, renderer, renderBlocks, pass);
            renderer.addTransformation(new Translation(s - x - a, a, s - z - a));
        }
    }
    renderer.removeTransformation();
    return true;
}
Also used : Translation(uk.co.qmunity.lib.transform.Translation) IIcon(net.minecraft.util.IIcon) IGateComponent(com.bluepowermod.api.gate.IGateComponent) IIntegratedCircuitPart(com.bluepowermod.api.gate.IIntegratedCircuitPart) Scale(uk.co.qmunity.lib.transform.Scale) Rotation(uk.co.qmunity.lib.transform.Rotation) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 3 with IGateComponent

use of com.bluepowermod.api.gate.IGateComponent in project BluePower by Qmunity.

the class GateBase method writeToNBT.

// NBT and update packets
@Override
public void writeToNBT(NBTTagCompound tag) {
    super.writeToNBT(tag);
    NBTTagCompound connections = new NBTTagCompound();
    for (GateConnectionBase c : getConnections()) {
        if (c == null)
            continue;
        NBTTagCompound data = new NBTTagCompound();
        c.writeToNBT(data);
        connections.setTag(c.getDirection().name(), data);
    }
    tag.setTag("connections", connections);
    NBTTagCompound t = new NBTTagCompound();
    int i = 0;
    for (IGateComponent c : getComponents()) {
        NBTTagCompound data = new NBTTagCompound();
        c.writeToNBT(data);
        t.setTag(i + "", data);
        i++;
    }
    tag.setTag("components", t);
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IGateComponent(com.bluepowermod.api.gate.IGateComponent) GateConnectionBase(com.bluepowermod.part.gate.connection.GateConnectionBase)

Example 4 with IGateComponent

use of com.bluepowermod.api.gate.IGateComponent in project BluePower by Qmunity.

the class GateBase method renderStatic.

@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
    Transformation t = null;
    if (getFace() == ForgeDirection.UP)
        t = new Rotation(180, 180, 0, Vec3d.center);
    if (getFace() == ForgeDirection.NORTH)
        t = new Rotation(90, 0, 0, Vec3d.center);
    if (getFace() == ForgeDirection.SOUTH)
        t = new Rotation(-90, 0, 0, Vec3d.center);
    if (getFace() == ForgeDirection.WEST)
        t = new Rotation(0, 0, -90, Vec3d.center);
    if (getFace() == ForgeDirection.EAST)
        t = new Rotation(0, 0, 90, Vec3d.center);
    if (t != null)
        renderer.addTransformation(t);
    int rotation = getRotation();
    if (rotation != -1)
        renderer.addTransformation(new Rotation(0, 90 * -rotation, 0));
    renderer.renderBox(BOX, getIcon(ForgeDirection.DOWN), getIcon(ForgeDirection.UP), getIcon(ForgeDirection.WEST), getIcon(ForgeDirection.EAST), getIcon(ForgeDirection.NORTH), getIcon(ForgeDirection.SOUTH));
    for (IGateComponent c : getComponents()) c.renderStatic(translation, renderer, pass);
    return true;
}
Also used : Transformation(uk.co.qmunity.lib.transform.Transformation) IGateComponent(com.bluepowermod.api.gate.IGateComponent) Rotation(uk.co.qmunity.lib.transform.Rotation) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

IGateComponent (com.bluepowermod.api.gate.IGateComponent)4 GateConnectionBase (com.bluepowermod.part.gate.connection.GateConnectionBase)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 Rotation (uk.co.qmunity.lib.transform.Rotation)2 IIntegratedCircuitPart (com.bluepowermod.api.gate.IIntegratedCircuitPart)1 IIcon (net.minecraft.util.IIcon)1 Scale (uk.co.qmunity.lib.transform.Scale)1 Transformation (uk.co.qmunity.lib.transform.Transformation)1 Translation (uk.co.qmunity.lib.transform.Translation)1 Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)1