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++;
}
}
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;
}
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);
}
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;
}
Aggregations