Block block = worldObj.getBlock(x, y, z);
if (block == null || block.isAir(worldObj, x, y, z)) {
Block blockToStickTo = worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
if (blockToStickTo.isNormalCube(worldObj, x, y, z)) {
worldObj.setBlock(x, y, z, MPSItems.luxCapacitor(), 0, 7);
worldObj.setTileEntity(x, y, z, new TileEntityLuxCapacitor(dir, red, green, blue));
} else {
for (ForgeDirection d : ForgeDirection.values()) {
int xo = x + d.offsetX;
int yo = y + d.offsetY;
int zo = z + d.offsetZ;
blockToStickTo = worldObj.getBlock(xo, yo, zo);
if (blockToStickTo.isNormalCube(worldObj, x, y, z)) {
worldObj.setBlock(x, y, z, MPSItems.luxCapacitor(), 0, 7);
worldObj.setTileEntity(x, y, z, new TileEntityLuxCapacitor(d, red, green, blue));
}
}
}
}
}