use of com.bluepowermod.api.gate.IIntegratedCircuitPart 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.IIntegratedCircuitPart 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"));
}
}
use of com.bluepowermod.api.gate.IIntegratedCircuitPart in project BluePower by Qmunity.
the class GateIntegratedCircuit method tick.
@Override
public void tick() {
loadWorld();
for (IIntegratedCircuitPart part : allParts()) if (part instanceof IPartTicking)
((IPartTicking) part).update();
unloadWorld();
}
use of com.bluepowermod.api.gate.IIntegratedCircuitPart in project BluePower by Qmunity.
the class GateIntegratedCircuit method sendUpdatePacket.
public void sendUpdatePacket(IPart part, int channel) {
int x = 0;
int z = 0;
for (int x_ = 0; x_ < getSize(); x_++) {
boolean found = false;
for (int z_ = 0; z_ < getSize(); z_++) {
IIntegratedCircuitPart p = getPart(x_, z_);
if (p == part) {
found = true;
x = x_;
z = z_;
break;
}
}
if (found)
break;
}
int c = (z * getSize()) + x + 10;
updateChannel = channel;
sendUpdatePacket(c);
}
use of com.bluepowermod.api.gate.IIntegratedCircuitPart in project BluePower by Qmunity.
the class GateIntegratedCircuit method onActivated.
@Override
public boolean onActivated(final EntityPlayer player, QMovingObjectPosition hit, ItemStack item) {
Vec2d v = new Vec2d(hit.hitVec.xCoord - hit.blockX, hit.hitVec.zCoord - hit.blockZ).sub(0.5, 0.5).rotate(90 * -getRotation()).add(0.5, 0.5);
int x = (int) (v.getX() * getSize());
int z = (int) (v.getY() * getSize());
if (getPart(x, z) == null && item != null && item.getItem() instanceof ItemPart) {
IPart part = ((ItemPart) item.getItem()).createPart(item, player, getWorld(), hit);
if (part instanceof IIntegratedCircuitPart) {
if (!getWorld().isRemote) {
setPart(x, z, (IIntegratedCircuitPart) part);
sendUpdatePacket(part, -1);
}
return true;
}
}
return super.onActivated(player, hit, item);
}
Aggregations